AI Internship LMS - Phase 1 Implementation by MAZHAR KHANAI Internship LMS - Phase 1 Implementation by MAZHAR KHAN

AI Internship LMS - Phase 1 Implementation

MAZHAR KHAN

MAZHAR KHAN

AI Internship LMS - Phase 1 Implementation

Complete, production-ready Learning Management System for AI Internship Program with authentication, RBAC, and professional React frontend.

Project Overview

This is Phase 1: Foundation implementing:
✅ Complete authentication system (login, register, logout)
✅ JWT-based token management with refresh tokens
✅ Role-Based Access Control (RBAC)
✅ Audit logging
✅ Email verification & password reset
✅ Professional React UI with Tailwind CSS
✅ MySQL database with Sequelize ORM
✅ Express.js REST API
✅ Error handling & validation
✅ Rate limiting & security

Project Structure


Prerequisites

Node.js 16+ & npm
MySQL 8.0+
Git

Installation & Setup

Step 1: Backend Setup


Step 2: Database Setup


Default Admin Account:
Email: admin@ailms.com
Password: Admin@2026

Step 3: Start Backend Server


Step 4: Frontend Setup


Step 5: Start Frontend Development Server


Testing the System

1. Access the Application

2. Login with Default Admin Account

Email: admin@ailms.com
Password: Admin@2026

3. Register a New User

Click "Sign up" on login page
Choose role: Intern, Mentor, or Trainer
Verify email (in development, check console for verification link)

4. Test Core Features

Authentication: Login/logout, token refresh
RBAC: View permissions based on role
Dashboard: Access personal dashboard
Profile: View user profile information
Navigation: Sidebar navigation between sections

API Endpoints

Authentication Routes


User Management Routes


Health Check


Database Schema

Key Tables

users - User accounts
roles - User roles (super_admin, program_manager, mentor, trainer, intern, etc.)
permissions - Resource-action permissions
user_roles - Many-to-many user-role relationship
role_permissions - Many-to-many role-permission relationship
intern_profiles - Extended intern information
audit_logs - Action tracking and audit trail
sessions - Active user sessions
password_resets - Password reset tokens

Role-Based Permissions

Pre-configured Roles:

super_admin - Full system access
program_manager - Manage interns, cohorts, programs
mentor - Guide and review interns
trainer - Deliver training
intern - Student/participant
product_specialist - Manage solutions
commercial - Business relationships
talent_hr - Talent pool management
management_viewer - Read-only analytics

Default Permissions:

Users: create, read, update, delete
Interns: create, read, update, delete, approve
Cohorts: create, read, update, delete
Hours: create, read, update, approve, delete
Learning: create, read, update, delete
Business: create, read, update, delete, approve
Projects: create, read, update, delete
Reports: create, read, update, delete

Environment Variables

Backend (.env)


Frontend (.env)


Security Features

✅ Authentication
JWT tokens with expiration
Refresh token rotation
Password hashing with bcrypt (12 rounds)
✅ Authorization
Role-based access control (RBAC)
Permission validation on each endpoint
Ownership verification for resources
✅ API Security
CORS configuration
Helmet.js security headers
Rate limiting (15 min/100 requests)
Input validation & sanitization
SQL injection prevention (Sequelize ORM)
✅ Data Protection
Passwords never returned in API responses
Sensitive data logged safely
Session management with token expiry
✅ Audit Trail
All actions logged in audit_logs table
User, IP, user-agent tracking
Before/after values for changes

Frontend Architecture

Technologies

React 18 - UI library
React Router 6 - Routing
React Hook Form - Form management
Yup - Schema validation
Axios - HTTP client
React Query - Data fetching
Tailwind CSS - Styling
React Hot Toast - Notifications

Key Components

AuthContext - Global authentication state
ProtectedRoute - Route-level access control
Layout - Main navigation structure
Login/Register - Authentication pages
Dashboard - Main user interface

State Management

React Context API for auth state
React Query for API data caching
LocalStorage for tokens

Logging

Logs are stored in backend/logs/:
combined.log - All logs
error.log - Errors only

Troubleshooting

Database Connection Error


Ensure MySQL is running: mysql --version
Check credentials in .env file
Verify database exists: Run migration again

Port Already in Use


Change PORT in .env
OR kill process: lsof -i :5000 | grep LISTEN | awk '{print $2}' | xargs kill -9

CORS Error

Verify FRONTEND_URL matches your frontend URL
Check backend .env FRONTEND_URL setting
Ensure backend is running on correct port

Email Not Sending

Use test account in .env instead of personal email
Enable "Less secure app access" for Gmail
Check EMAIL_USER and EMAIL_PASS in .env

Next Steps (Phase 2)

After Phase 1 is stable, Phase 2 will include:
Intern profile completion flow
Cohort management system
Department configuration
Profile builder UI
Onboarding workflow
Intern journey tracking
Practical hours logging
Learning modules
Business project management

Contributing

This is a demonstration project. For production use:
Change JWT_SECRET to a strong random string
Set NODE_ENV=production
Use environment-specific .env files
Set up HTTPS/SSL
Configure proper email service
Set up backup strategy for database

Support

For issues or questions:
Check logs in backend/logs/
Review API response errors
Check browser console for frontend errors
Verify .env configuration

License

This project is part of the AI Internship Program.
Ready to start?

Then open http://localhost:3000 and log in with:
Password: Admin@2026
Like this project

Posted Sep 24, 2026

Developed LMS for AI Internship with React frontend and secure backend.

Likes

1

Views

1

Timeline

Aug 1, 2026 - Aug 24, 2026

Clients

company