Skip to content

GenAIwithMS/LMS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

71 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Learning Management System (LMS) Agentic

A modern, comprehensive Learning Management System built with Flask (backend) and React 18 + TypeScript (frontend), featuring role-based access control, assignment management, attendance tracking, and an AI-powered chatbot assistant with LangGraph.

✨ Key Highlights

  • Modern UI/UX: Gradient-based design with smooth animations and responsive layouts
  • Unified Dashboard: All users (Admin, Teacher, Student) land on a centralized dashboard after login
  • Static Navigation: Fixed sidebar and navbar with scrollable content area for better UX
  • AI-Powered Assistant: Built-in chatbot widget accessible from any page
  • Real-time Notifications: Toast notifications and notification center
  • Expandable Features: Interactive feature cards with detailed descriptions on homepage

πŸš€ Features

UI/UX Features

  • Modern Homepage:
    • Gradient hero section with animated backgrounds
    • Expandable feature cards with detailed capability lists
    • Problem-solution narrative layout
    • Role-based feature showcase
    • Security highlights section
  • Unified Dashboard: Single dashboard for all user roles with role-specific quick actions
  • Static Layout: Fixed sidebar and navbar, scrollable content area only
  • Responsive Design: Mobile-first approach with collapsible sidebar
  • Enhanced Visuals: Gradient cards, hover animations, shadow effects
  • Toast Notifications: Real-time user feedback
  • Notification Center: Bell icon with dropdown for announcements and events

Core Features

  • Role-Based Access Control: Three distinct user roles (Admin, Teacher, Student) with different permissions
  • User Management: Create, update, and manage students, teachers, and admins
  • Course Management: Create and manage courses, subjects, and sections
  • Assignment System: Create assignments, submit work, and grade submissions
  • Attendance Tracking: Mark and track student attendance
  • Results Management: Record and manage student results
  • Announcements: Post announcements to specific sections
  • Events: Create and manage school events
  • Enrollment: Enroll students in courses
  • AI Chatbot: Intelligent assistant powered by LangGraph and Groq API

User Roles

Admin

  • Manage all users (students, teachers, admins)
  • Create and manage sections
  • Create and manage courses
  • Create and manage subjects
  • Manage enrollments
  • View all system data

Teacher

  • Create and manage assignments
  • View and grade student submissions
  • Mark attendance
  • Record results
  • Create announcements
  • View assigned courses and subjects

Student

  • View assigned courses and subjects
  • View and submit assignments
  • View attendance records
  • View results
  • View announcements
  • Access AI chatbot

πŸ› οΈ Tech Stack

Backend

  • Flask: Lightweight Python web framework
  • SQLAlchemy: ORM for database operations with relationship mapping
  • PyMySQL: MySQL database connector
  • Flask-JWT-Extended: JWT-based authentication and authorization
  • Flask-Bcrypt: Secure password hashing
  • Marshmallow: Data validation, serialization, and deserialization
  • Flask-CORS: Cross-origin resource sharing configuration
  • LangGraph: State-based AI agent orchestration framework
  • LangChain: LLM integration and prompt management
  • LangChain-Groq: Groq API integration for fast LLM inference
  • python-dotenv: Environment variable management

Frontend

  • React 18: Latest React with hooks and concurrent features
  • TypeScript: Full type safety and better developer experience
  • Vite: Lightning-fast build tool and HMR dev server
  • React Router DOM v6: Modern client-side routing
  • Axios: Promise-based HTTP client with interceptors
  • Tailwind CSS 3: Utility-first CSS with custom design system
  • Lucide React: Modern icon library (350+ icons)
  • React Hot Toast: Beautiful toast notifications
  • React Markdown: Markdown rendering for chatbot responses
  • Remark GFM: GitHub Flavored Markdown support

Database

  • MySQL: Relational database

πŸ“ Project Structure

LMS Agentic/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ app.py                 # Flask application entry point
β”‚   β”œβ”€β”€ requirements.txt       # Python dependencies
β”‚   β”œβ”€β”€ .env.example          # Environment variables template
β”‚   └── src/
β”‚       β”œβ”€β”€ __init__.py        # Flask app factory with CORS config
β”‚       β”œβ”€β”€ db.py              # Database configuration
β”‚       β”œβ”€β”€ extention.py       # Flask extensions (JWT, Bcrypt)
β”‚       β”œβ”€β”€ models/            # SQLAlchemy models (14 models)
β”‚       β”‚   β”œβ”€β”€ admin.py
β”‚       β”‚   β”œβ”€β”€ student.py
β”‚       β”‚   β”œβ”€β”€ teacher.py
β”‚       β”‚   β”œβ”€β”€ course.py
β”‚       β”‚   β”œβ”€β”€ assignment.py
β”‚       β”‚   └── ... (9 more)
β”‚       β”œβ”€β”€ routes/            # API route handlers (15 blueprints)
β”‚       β”‚   β”œβ”€β”€ auth.py
β”‚       β”‚   β”œβ”€β”€ admin.py
β”‚       β”‚   β”œβ”€β”€ student.py
β”‚       β”‚   β”œβ”€β”€ chatbot.py
β”‚       β”‚   └── ... (11 more)
β”‚       β”œβ”€β”€ schemas/           # Marshmallow schemas for validation
β”‚       β”œβ”€β”€ services/          # Business logic layer
β”‚       └── agent/             # AI chatbot implementation
β”‚           β”œβ”€β”€ main.py        # LangGraph agent workflow
β”‚           β”œβ”€β”€ tools.py       # 26 AI tools for database operations
β”‚           β”œβ”€β”€ tools_list.py  # Tool registry
β”‚           └── prompts.py     # System and role-specific prompts
β”‚
└── frontend/
    β”œβ”€β”€ package.json           # Node.js dependencies
    β”œβ”€β”€ vite.config.ts         # Vite configuration
    β”œβ”€β”€ tailwind.config.js     # Tailwind CSS with custom colors
    β”œβ”€β”€ tsconfig.json          # TypeScript configuration
    └── src/
        β”œβ”€β”€ main.tsx           # React entry point
        β”œβ”€β”€ App.tsx            # Main app with routing (20+ routes)
        β”œβ”€β”€ index.css          # Global styles with custom animations
        β”œβ”€β”€ components/        # Reusable components
        β”‚   β”œβ”€β”€ Layout.tsx     # Main layout with sidebar & navbar
        β”‚   β”œβ”€β”€ ProtectedRoute.tsx
        β”‚   β”œβ”€β”€ ChatbotWidget.tsx
        β”‚   └── ...
        β”œβ”€β”€ contexts/          # React contexts
        β”‚   └── AuthContext.tsx
        β”œβ”€β”€ pages/             # Page components
        β”‚   β”œβ”€β”€ Homepage.tsx   # Landing page with features
        β”‚   β”œβ”€β”€ Login.tsx      # Authentication page
        β”‚   β”œβ”€β”€ Dashboard.tsx  # Unified dashboard
        β”‚   β”œβ”€β”€ admin/         # Admin pages (7 pages)
        β”‚   β”œβ”€β”€ teacher/       # Teacher pages (5 pages)
        β”‚   └── student/       # Student pages (4 pages)
        β”œβ”€β”€ services/          # API service layer
        β”‚   └── api.ts         # Axios instance with interceptors
        β”œβ”€β”€ types/             # TypeScript type definitions
        β”‚   └── index.ts
        └── utils/             # Utility functions
            β”œβ”€β”€ jwt.ts
            └── errorHandler.ts

πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

  • Python 3.13
  • Node.js 16+ and npm or yarn
  • MySQL 5.7+ or MariaDB 10.3+
  • Git

πŸ”§ Installation & Setup

1. Clone the Repository

git clone https://github.com/GenAIwithMS/LMS
cd "LMS Agentic"

2. Backend Setup

Install Python Dependencies

cd backend
pip install -r requirements.txt

Database Configuration

  1. Create a MySQL database:
CREATE DATABASE llm_LMS;
  1. Create a .env file in the backend/ directory:
# Database Configuration
DATABASE_URI=mysql+pymysql://username:password@localhost/llm_LMS

# JWT Configuration
JWT_SECRET_KEY=your-secret-key-here

# Flask Configuration
FLASK_DEBUG=True
PORT=5000

# Groq API (Optional - for chatbot)
GROQ_API_KEY=your-groq-api-key-here

Note: Replace username and password with your MySQL credentials.

Run Database Migrations

The database tables will be created automatically when you first run the application.

Start the Backend Server

python app.py

The backend will run on http://localhost:5000

3. Frontend Setup

Install Dependencies

cd frontend
npm install

Start the Development Server

npm run dev

The frontend will run on http://localhost:5173 (or another port if 5173 is busy)

🌐 API Endpoints

The API is organized by resource. All endpoints are prefixed with /api/.

Authentication

  • POST /api/login - User login
  • POST /api/logout - User logout (if implemented)

Admin Endpoints

  • POST /api/add/admin - Create admin
  • GET /api/get/admin - Get admin(s)
  • PUT /api/update/admin - Update admin
  • DELETE /api/delete/admin - Delete admin

Student Endpoints

  • POST /api/add/student - Create student
  • GET /api/get/student - Get student(s)
  • PUT /api/update/student - Update student
  • DELETE /api/delete/student - Delete student

Teacher Endpoints

  • POST /api/add/teacher - Create teacher
  • GET /api/get/teacher - Get teacher(s)
  • PUT /api/update/teacher - Update teacher
  • DELETE /api/delete/teacher - Delete teacher

Course Endpoints

  • POST /api/add/course - Create course
  • GET /api/get/courses - Get course(s)
  • PUT /api/update/course - Update course
  • DELETE /api/delete/course - Delete course

Assignment Endpoints

  • POST /api/create/assignments - Create assignment
  • GET /api/get/assignments - Get assignment(s)
  • PUT /api/update/assignments/ - Update assignment
  • DELETE /api/delete/assignments/ - Delete assignment

Submission Endpoints

  • POST /api/submit/assignment - Submit assignment (Student only)
  • GET /api/get/submissions/by/student - Get student submissions
  • GET /api/get/submissions/by/assignment - Get assignment submissions
  • PUT /api/update/submission - Update submission (Teacher only)
  • DELETE /api/delete/submission - Delete submission

Other Endpoints

  • Sections, Subjects, Enrollments, Attendance, Results, Announcements, Events
  • See backend/API_DOCUMENTATION.md for complete API documentation

Note: Most endpoints require JWT authentication. Include the token in the Authorization header:

Authorization: Bearer <your-jwt-token>

πŸ” Authentication

The application uses JWT (JSON Web Tokens) for authentication:

  1. Login with Email and password
  2. Receive a JWT token
  3. Include the token in subsequent requests via the Authorization header
  4. Tokens are stored in localStorage on the frontend

🎨 Frontend Features

  • Modern Design System:
    • Gradient backgrounds and cards
    • Custom animations (fade-in-up, shimmer, pulse)
    • Glassmorphism effects
    • Smooth hover transitions
  • Responsive Layout: Works seamlessly on desktop, tablet, and mobile
  • Fixed Navigation: Sidebar and navbar stay static while content scrolls
  • Unified Dashboard: Single landing page for all user roles after login
  • Interactive Homepage: Expandable feature cards with detailed information
  • Toast Notifications: Instant user feedback for all actions
  • Notification Center: Real-time announcements and events dropdown
  • Protected Routes: Role-based route protection with automatic redirects
  • Error Handling: Comprehensive error handling with user-friendly messages
  • Type Safety: Full TypeScript coverage for better developer experience
  • Loading States: Skeleton loaders and spinners for better UX
  • Form Validation: Client-side validation before API calls

πŸ€– AI Chatbot

The system includes an intelligent AI-powered chatbot accessible from any page via a floating button:

Features

  • Role-Aware Context: Chatbot adapts responses based on user role
  • 26 Database Tools: Complete CRUD operations via natural language
  • LangGraph Workflow: State-based agent with tool calling
  • Markdown Rendering: Rich formatting for chatbot responses
  • Persistent Widget: Accessible from any page without navigation
  • Conversation History: Maintains context within session

Capabilities by Role

Admin Tools

  • User management (create, update, delete students/teachers)
  • Course and subject creation
  • Section and enrollment management
  • Event creation and management
  • System-wide data queries

Teacher Tools

  • Assignment creation and management
  • Submission grading and feedback
  • Attendance marking and tracking
  • Result recording
  • Announcement posting

Student Tools

  • Assignment submission
  • Grade and attendance viewing
  • Course information queries
  • Announcement viewing
  • Schedule information

Technical Implementation

  • LangGraph: Orchestrates agent workflow with state management
  • Groq API: Fast LLM inference (llama-3.3-70b-versatile model)
  • Tool Binding: 26 Python functions exposed as tools
  • Error Handling: Graceful fallbacks and error messages

Note: Requires GROQ_API_KEY in environment variables. Application runs without it, but chatbot will be unavailable.

🚦 Running the Application

Development Mode

  1. Start the Backend (Terminal 1):

    cd backend
    python app.py

    Backend runs on http://localhost:5000

  2. Start the Frontend (Terminal 2):

    cd frontend
    npm run dev

    Frontend runs on http://localhost:5173

  3. Access the Application:

    • Open http://localhost:5173 in your browser
    • Login redirects all users to /dashboard
    • Navigate using the fixed sidebar

First-Time Setup

  1. Create Admin User (via API or database):

    # Use API endpoint or insert directly into database
    # Default credentials should be created in database
  2. Login Flow:

    • Visit homepage β†’ Click "Get Started" or "Login"
    • Enter credentials
    • Automatically redirected to unified dashboard
    • Access role-specific features from sidebar

Production Build

Backend

The Flask app can be deployed using:

  • Gunicorn
  • uWSGI
  • Docker
  • Any WSGI-compatible server

Frontend

Build the frontend for production:

cd frontend
npm run build

The built files will be in the dist/ directory.

πŸ§ͺ Testing

Backend Testing

cd backend
flask run --debug

Frontend Testing

cd frontend
npm run dev

πŸ“ Environment Variables

Backend (.env)

# Database Configuration
DATABASE_URI=mysql+pymysql://username:password@localhost/llm_LMS

# JWT Configuration
JWT_SECRET_KEY=your-secret-key-here-change-this-in-production

# Flask Configuration
FLASK_DEBUG=True
PORT=5000

# Groq API (Required for AI Chatbot)
GROQ_API_KEY=your-groq-api-key-here

Frontend (No .env needed)

Frontend uses Vite's default configuration. API base URL is set in src/services/api.ts:

const API_BASE_URL = 'http://localhost:5000/api';

πŸ› Troubleshooting

Backend Issues

  1. Database Connection Error:

    • Verify MySQL is running
    • Check database credentials in .env
    • Ensure the database exists
  2. Import Errors:

    • Ensure all dependencies are installed: pip install -r requirements.txt
    • Check Python version (3.13 recommended, 3.8+ minimum)
    • Install python-dotenv separately if needed: pip install python-dotenv
  3. Port Already in Use:

    • Change the port in .env or app.py
    • Kill the process using the port

Frontend Issues

  1. Cannot Connect to Backend:

    • Verify backend is running on http://localhost:5000
    • Check CORS configuration in backend/src/__init__.py
    • Verify API base URL in frontend/src/services/api.ts
    • Ensure no proxy/firewall blocking localhost connections
  2. Build Errors:

    • Clear node_modules and reinstall: rm -rf node_modules package-lock.json && npm install
    • Check Node.js version (16+ required, 18+ recommended)
    • Clear Vite cache: rm -rf node_modules/.vite
  3. Login Issues:

    • Check browser console for errors
    • Verify JWT token is being stored in localStorage
    • Clear localStorage and try again: localStorage.clear()
    • Check Network tab for API response status
  4. Styling Issues:

    • Ensure Tailwind CSS is properly configured
    • Check index.css is imported in main.tsx
    • Rebuild with npm run build and restart dev server

πŸ“š Additional Documentation

  • Backend API Documentation: backend/API_DOCUMENTATION.md
  • Frontend API Documentation: frontend/API_DOCUMENTATION.md
  • AI Agent Prompts: backend/src/agent/prompts.py
  • Database Models: backend/src/models/

πŸ”„ Recent Updates

UI/UX Improvements

  • βœ… Modern gradient-based design system
  • βœ… Unified dashboard for all user roles
  • βœ… Fixed sidebar and navbar with scrollable content
  • βœ… Expandable feature cards on homepage
  • βœ… Enhanced notification system
  • βœ… Improved responsive design
  • βœ… Custom animations and transitions

Features Added

  • βœ… AI chatbot widget with 26 database tools
  • βœ… Role-based dashboard quick actions
  • βœ… Real-time notification center
  • βœ… Toast notification system
  • βœ… Markdown rendering for chatbot
  • βœ… System status indicators (removed from dashboard)

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘₯ Authors

  • Your Name - Initial work

πŸ™ Acknowledgments

  • Flask community
  • React community
  • Tailwind CSS
  • LangChain and LangGraph teams

Note: This is a development version. For production deployment, ensure proper security measures, environment variable management, and database backups.

About

A modern, AI-powered Learning Management System (LMS) featuring role-based access and an agentic chatbot built with LangGraph for natural language database operations.

Topics

Resources

License

Stars

Watchers

Forks

Contributors