Skip to content

chandanjainhp/TMS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

21 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TMS - Teacher Management System

client/public/logo.png

A modern, full-stack web application for managing teachers, students, and educational records with role-based access control and comprehensive administrative features.


πŸš€ Features

πŸ‘₯ User Management

  • Multi-Role Authentication: Users, Teachers, and Admins
  • Email Verification: Secure account creation with email verification
  • Password Reset: OTP-based password reset system (15 min expiry)
  • Session Management: Auto-logout after inactivity (30 min for users, 15 min for admins)
  • Profile Settings: Update profile information and change passwords

πŸ“Š Student Records

  • CSV Upload: Bulk import student data via CSV files
  • Record Management: View, edit, and delete student records
  • Search & Filter: Advanced filtering and search capabilities
  • Data Export: Export records in various formats

πŸ‘¨β€πŸ« Teacher Features

  • Form Submission: Submit and manage educational forms
  • Form Data Management: Track and edit submitted forms
  • Teacher Logs: Activity tracking and logging system
  • Dashboard: Personalized teacher dashboard

πŸ” Admin Panel

  • Admin Dashboard: Comprehensive overview of system metrics
  • User Management: Manage teachers and user accounts
  • Records Overview: Access to all system records
  • Teacher Log Monitoring: Track teacher activities
  • Admin Settings: System configuration and management
  • Separate Admin Authentication: Dedicated admin login system

🎨 Modern UI/UX

  • Gradient Theme: Beautiful indigo β†’ purple β†’ pink gradient design
  • Responsive Design: Mobile-friendly interface with Tailwind CSS
  • Smooth Animations: Framer Motion animations throughout
  • Toast Notifications: Real-time user feedback with react-hot-toast
  • Header Navigation: Clean, intuitive navigation system

πŸ› οΈ Technology Stack

Frontend

  • React 18 - Modern UI library
  • Vite - Fast build tool and dev server
  • React Router - Client-side routing
  • Tailwind CSS - Utility-first CSS framework
  • Framer Motion - Animation library
  • Zustand - State management
  • Axios - HTTP client
  • React Hot Toast - Notifications
  • Lucide React - Icon library

Backend

  • Node.js - JavaScript runtime
  • Express.js - Web application framework
  • MongoDB - NoSQL database
  • Mongoose - MongoDB ODM
  • JWT - Authentication tokens
  • bcryptjs - Password hashing
  • Nodemailer - Email sending
  • Cookie Parser - Cookie handling
  • CORS - Cross-origin resource sharing

πŸ“ Project Structure

TMS/
β”œβ”€β”€ client/                    # Frontend React application
β”‚   β”œβ”€β”€ public/               # Static assets
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ assets/          # Images, icons
β”‚   β”‚   β”œβ”€β”€ components/      # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ admin/      # Admin-specific components
β”‚   β”‚   β”‚   β”œβ”€β”€ common/     # Shared components (Header, etc.)
β”‚   β”‚   β”‚   β”œβ”€β”€ editing/    # Edit functionality components
β”‚   β”‚   β”‚   β”œβ”€β”€ form/       # Form components
β”‚   β”‚   β”‚   β”œβ”€β”€ landing/    # Landing page components
β”‚   β”‚   β”‚   β”œβ”€β”€ login/      # Authentication components
β”‚   β”‚   β”‚   β”œβ”€β”€ records/    # Record management components
β”‚   β”‚   β”‚   β”œβ”€β”€ settings/   # Settings components
β”‚   β”‚   β”‚   β”œβ”€β”€ student/    # Student-related components
β”‚   β”‚   β”‚   β”œβ”€β”€ teacher/    # Teacher-specific components
β”‚   β”‚   β”‚   └── teacherlog/ # Teacher log components
β”‚   β”‚   β”œβ”€β”€ hooks/          # Custom React hooks
β”‚   β”‚   β”œβ”€β”€ pages/          # Page components
β”‚   β”‚   β”œβ”€β”€ services/       # API services
β”‚   β”‚   β”œβ”€β”€ store/          # Zustand state stores
β”‚   β”‚   β”‚   β”œβ”€β”€ authStore.js       # User authentication
β”‚   β”‚   β”‚   β”œβ”€β”€ adminAuthStore.js  # Admin authentication
β”‚   β”‚   β”‚   └── studentStore.js    # Student data
β”‚   β”‚   β”œβ”€β”€ styles/         # Global styles
β”‚   β”‚   β”œβ”€β”€ utils/          # Utility functions
β”‚   β”‚   β”œβ”€β”€ App.jsx         # Main App component
β”‚   β”‚   └── main.jsx        # Entry point
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ postcss.config.js
β”‚   β”œβ”€β”€ tailwind.config.js
β”‚   └── vite.config.js
β”‚
β”œβ”€β”€ server/                   # Backend Node.js application
β”‚   β”œβ”€β”€ config/              # Configuration files
β”‚   β”œβ”€β”€ controllers/         # Route controllers
β”‚   β”‚   β”œβ”€β”€ auth.controller.js
β”‚   β”‚   β”œβ”€β”€ EditingStudentController.js
β”‚   β”‚   β”œβ”€β”€ from.controller.js
β”‚   β”‚   β”œβ”€β”€ student.controller.js
β”‚   β”‚   β”œβ”€β”€ user.controller.js
β”‚   β”‚   └── userActivity.controller.js
β”‚   β”œβ”€β”€ db/                  # Database connection
β”‚   β”‚   └── connectDB.js
β”‚   β”œβ”€β”€ email/               # Email templates and configuration
β”‚   β”‚   β”œβ”€β”€ email.config.js
β”‚   β”‚   β”œβ”€β”€ emails.js
β”‚   β”‚   β”œβ”€β”€ emailTemplates.js
β”‚   β”‚   └── testEmail.js
β”‚   β”œβ”€β”€ middleware/          # Express middleware
β”‚   β”‚   β”œβ”€β”€ authMiddleware.js
β”‚   β”‚   β”œβ”€β”€ uploadMiddleware.js
β”‚   β”‚   └── verifyToken.js
β”‚   β”œβ”€β”€ models/              # Mongoose models
β”‚   β”‚   β”œβ”€β”€ EditingStudent.model.js
β”‚   β”‚   β”œβ”€β”€ form.models.js
β”‚   β”‚   β”œβ”€β”€ Student.model.js
β”‚   β”‚   β”œβ”€β”€ user.model.js
β”‚   β”‚   └── userActivity.model.js
β”‚   β”œβ”€β”€ routes/              # API routes
β”‚   β”‚   β”œβ”€β”€ admin.auth.route.js
β”‚   β”‚   β”œβ”€β”€ auth.route.js
β”‚   β”‚   β”œβ”€β”€ EditingStudentRoutes.js
β”‚   β”‚   β”œβ”€β”€ formRoutes.js
β”‚   β”‚   β”œβ”€β”€ passwordReset.js
β”‚   β”‚   β”œβ”€β”€ studentRoutes.js
β”‚   β”‚   β”œβ”€β”€ user.route.js
β”‚   β”‚   β”œβ”€β”€ user.routes.js
β”‚   β”‚   └── userActivity.routes.js
β”‚   β”œβ”€β”€ scripts/             # Utility scripts
β”‚   β”‚   β”œβ”€β”€ createAdmin.js
β”‚   β”‚   β”œβ”€β”€ findAdmins.js
β”‚   β”‚   β”œβ”€β”€ makeAdmin.js
β”‚   β”‚   β”œβ”€β”€ resetAdminPassword.js
β”‚   β”‚   └── setupBackupAdmin.js
β”‚   β”œβ”€β”€ services/            # Business logic services
β”‚   β”œβ”€β”€ Student/             # Student-related utilities
β”‚   β”œβ”€β”€ uploads/             # File upload directory
β”‚   β”œβ”€β”€ utils/               # Utility functions
β”‚   β”‚   └── generateTokenAndSetCookie.js
β”‚   β”œβ”€β”€ index.js             # Server entry point
β”‚   └── package.json
β”‚
β”œβ”€β”€ student_data.csv         # Sample CSV data
β”œβ”€β”€ docker-compose.yaml      # Docker Compose configuration
β”œβ”€β”€ .gitignore
β”œβ”€β”€ package.json
└── README.md

πŸ”§ Installation & Setup

1. Using Docker (Recommended)

  1. Ensure Docker and Docker Compose are installed.
  2. Run the application:
    docker-compose up --build
  3. Access the application:
    • Frontend: http://localhost:5173
    • Backend: http://localhost:5000
    • MongoDB: mongodb://localhost:27017

2. Manual Installation

Prerequisites

  • Node.js (v18 or higher) or Bun
  • MongoDB (local or MongoDB Atlas)
  • npm, yarn, or bun

1. Clone the Repository

git clone https://github.com/your-username/TMS.git
cd TMS

2. Backend Setup

# Navigate to server directory
cd server

# Install dependencies
bun install
# or
npm install

# Create .env file
cp .env.example .env

# Edit .env file with your configuration
# For Docker, this is handled automatically

Required Environment Variables:

# MongoDB
MONGODB_URI=mongodb://127.0.0.1:27017/TMS

# Server
PORT=5000
NODE_ENV=development

# JWT Secret
JWT_SECRET=your_super_secret_jwt_key_here

# Frontend URL
FRONTEND_URL=http://localhost:5173

# Email Configuration (Gmail SMTP)
EMAIL_USER=your-email@gmail.com
EMAIL_PASSWORD=your-app-specific-password
EMAIL_FROM=TMS <your-email@gmail.com>
SMTP_HOST=smtp.gmail.com
SMTP_PORT=465
SMTP_SECURE=true

3. Frontend Setup

# Navigate to client directory
cd ../client

# Install dependencies
bun install
# or
npm install

# Start development server
bun run dev
# or
npm run dev

4. Start the Application

Terminal 1 - Backend:

cd server
bun run dev

Terminal 2 - Frontend:

cd client
bun run dev

5. Create Admin Account

cd server
node scripts/setupBackupAdmin.js

Default Admin Credentials:

  • Email: backupid849@gmail.com
  • Password: BackupAdmin@123

🌐 API Endpoints

Authentication Routes (/api/auth)

Method Endpoint Description Access
POST /signup Register new user Public
POST /login User login Public
POST /logout User logout Private
POST /verify-email Verify email with code Public
POST /forgot-password Request password reset OTP Public
POST /reset-password Reset password with OTP Public
POST /change-password Change password Private
GET /check-auth Verify authentication Private

Admin Authentication Routes (/api/admin/auth)

Method Endpoint Description Access
POST /login Admin login Public
POST /logout Admin logout Private
GET /check-auth Verify admin authentication Private
POST /admin/forgot-password Admin password reset OTP Public
POST /admin/reset-password-otp Reset admin password Public

Student Routes (/api/students)

Method Endpoint Description Access
GET / Get all students Private
POST / Create new student Private
PUT /:id Update student Private
DELETE /:id Delete student Private
POST /upload Upload CSV file Private

Form Routes (/api/form)

Method Endpoint Description Access
GET / Get all forms Private
POST / Create new form Private
PUT /:id Update form Private
DELETE /:id Delete form Private

User Activity Routes (/api/user-activity)

Method Endpoint Description Access
GET / Get user activities Admin
POST / Log user activity Private

🎨 Design System

Color Palette

/* Primary Gradient */
--gradient-primary: linear-gradient(135deg, #4f46e5 0%, #9333ea 50%, #ec4899 100%);

/* Background Gradient */
--gradient-bg: linear-gradient(to bottom right, 
  rgb(238 242 255), rgb(243 232 255), rgb(252 231 243));

/* Text Colors */
--text-primary: #111827;
--text-secondary: #6b7280;
--text-light: #9ca3af;

/* Status Colors */
--success: #10b981;
--error: #ef4444;
--warning: #f59e0b;
--info: #3b82f6;

Typography

  • Font Family: Segoe UI, Tahoma, Geneva, Verdana, sans-serif
  • Headings: Bold, gradient text
  • Body: Regular, dark gray

Components

  • Buttons: Gradient background with hover effects
  • Inputs: Bordered with icons
  • Cards: White background with shadow
  • Modals: Centered with backdrop
  • Toast: Top-right notifications

πŸ” Authentication Flow

User Registration

1. User submits email, password, name
2. Server validates input
3. Password hashed with bcryptjs
4. Verification code generated (6-digit)
5. Verification email sent
6. User record created (isVerified: false)
7. JWT token set in cookie
8. Redirect to verification page

Email Verification

1. User receives 6-digit code via email
2. User enters code on verification page
3. Server validates code
4. User.isVerified set to true
5. Welcome email sent
6. Redirect to dashboard

Password Reset (OTP-based)

1. User enters email on forgot password page
2. Server generates 6-digit OTP
3. OTP saved with 15-minute expiry
4. OTP sent via email
5. User enters OTP and new password
6. Server validates OTP and expiry
7. Password updated
8. Success email sent
9. Redirect to login

Session Management

1. JWT token stored in httpOnly cookie
2. Token verified on protected routes
3. Auto-logout after inactivity:
   - Regular users: 30 minutes
   - Admin users: 15 minutes
4. Activity tracking resets timeout
5. Manual logout clears cookie and session

πŸ“§ Email Templates

Available Templates

  1. Verification Email - Account email verification
  2. Welcome Email - Sent after successful verification
  3. Password Reset OTP - Password reset with OTP code
  4. Admin Password Reset OTP - Admin-specific password reset
  5. Reset Success - Password reset confirmation

Email Configuration

  • Provider: Gmail SMTP
  • Port: 465 (SSL)
  • Host: smtp.gmail.com
  • From: TMS System

Email Features

  • Beautiful gradient-themed HTML templates
  • Responsive design
  • Security warnings
  • Expiration notices
  • Support contact information

πŸ›‘οΈ Security Features

Authentication

  • βœ… JWT-based authentication
  • βœ… httpOnly cookies (prevents XSS)
  • βœ… Password hashing (bcryptjs)
  • βœ… Email verification required
  • βœ… OTP-based password reset (15 min expiry)
  • βœ… Separate admin authentication

Authorization

  • βœ… Role-based access control (User, Teacher, Admin)
  • βœ… Protected routes with middleware
  • βœ… Admin-only endpoints
  • βœ… Token verification on each request

Session Security

  • βœ… Auto-logout on inactivity
  • βœ… Session timeout (30 min users, 15 min admins)
  • βœ… Activity tracking
  • βœ… Secure cookie settings

Data Protection

  • βœ… Input validation
  • βœ… SQL injection prevention (Mongoose)
  • βœ… XSS protection
  • βœ… CORS configuration
  • βœ… Environment variables for secrets

πŸ“± Routes & Pages

Public Routes

  • / - Landing Page
  • /login - User Login
  • /signup - User Registration
  • /verify-email - Email Verification
  • /forgot-password - Request Password Reset
  • /reset-password - Reset Password with OTP
  • /admin-login - Admin Login
  • /admin/forgot-password - Admin Password Reset Request
  • /admin/reset-password-otp - Admin Password Reset with OTP

Protected Routes (User)

  • /settings - User Settings & Profile
  • /upload - Upload Student Data (CSV)
  • /form-data - View Form Submissions
  • /from - Submit New Form
  • /records - View Student Records

Protected Routes (Admin)

  • /admin/dashboard - Admin Dashboard
  • /admin/records - All Student Records
  • /admin/teacher-log - Teacher Activity Logs
  • /admin/settings - Admin Settings

πŸ§ͺ Testing

Run Tests

# Backend tests
cd server
npm test

# Frontend tests
cd client
npm test

Manual Testing Checklist

Authentication

  • User registration with email verification
  • User login with valid credentials
  • Password reset with OTP
  • Admin login
  • Session timeout (30 min for users, 15 min for admins)
  • Auto-logout on inactivity

Student Management

  • Upload CSV file
  • View student records
  • Edit student record
  • Delete student record
  • Search and filter students

Form Management

  • Submit new form
  • View submitted forms
  • Edit form data
  • Delete form

Admin Features

  • Access admin dashboard
  • View all records
  • Monitor teacher logs
  • Admin settings management

πŸš€ Deployment

Backend Deployment (Node.js)

Option 1: Heroku

# Login to Heroku
heroku login

# Create app
heroku create tms-backend

# Set environment variables
heroku config:set MONGODB_URI=your_mongodb_uri
heroku config:set JWT_SECRET=your_jwt_secret
# ... set other env variables

# Deploy
git push heroku main

Option 2: DigitalOcean/AWS/Azure

  1. Set up Node.js server
  2. Install PM2 for process management
  3. Configure Nginx reverse proxy
  4. Set up SSL certificate
  5. Deploy code and run with PM2

Frontend Deployment (React)

Option 1: Vercel

# Install Vercel CLI
npm i -g vercel

# Deploy
cd client
vercel

Option 2: Netlify

  1. Build the project: npm run build
  2. Drag and drop dist folder to Netlify
  3. Configure environment variables

Database

  • Use MongoDB Atlas for cloud database
  • Or set up MongoDB on your server

🀝 Contributing

We welcome contributions! Please follow these steps:

  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

Coding Standards

  • Use ES6+ syntax
  • Follow Airbnb style guide
  • Write meaningful commit messages
  • Add comments for complex logic
  • Update documentation

πŸ“„ License

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


πŸ‘¨β€πŸ’» Authors


πŸ™ Acknowledgments

  • React team for the amazing framework
  • Tailwind CSS for the utility-first CSS
  • Framer Motion for smooth animations
  • MongoDB for the flexible database
  • Express.js for the robust backend framework
  • All contributors and testers

πŸ“ž Support

For support, email backupid849@gmail.com or open an issue in the GitHub repository.


πŸ“Š Project Status

Current Version: 1.0.0

Status: βœ… Production Ready

Recent Updates

  • βœ… Header navigation system implemented
  • βœ… Email templates with gradient theme
  • βœ… OTP-based password reset (users & admins)
  • βœ… Session timeout feature (30 min users, 15 min admins)
  • βœ… Activity tracking for session management
  • βœ… Admin authentication system
  • βœ… Admin settings page
  • βœ… Separate admin and user flows

Roadmap

  • Two-factor authentication
  • Advanced analytics dashboard
  • Export to PDF functionality
  • Bulk user management
  • Email notification preferences
  • Dark mode support
  • Mobile app (React Native)

About

The Teacher Management System (TMS) is a web application designed for teachers to manage student marks effectively. This system prioritizes concurrency control to ensure smooth operation and data integrity. It features:

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages