All projects
Web AppWebSource code

School CRM โ€” Multi-role school management

One system for directors, principals, front office, accounts, teachers, parents and students.

Private repository

A school management frontend with a separate workspace for each role. Staff handle admissions, students, attendance, fees, exams, timetable, homework and leave; parents and students get their own portal for fees, results, attendance and notices.

8
roles
60
pages
20+
staff modules
MySQL
backend database

What it does

A workspace per role

Director, principal, front office, accounts, teacher and staff each get their own base route and menu.

Admissions to fees

Enquiries, follow-ups, admissions, fee structures, payments, defaulters and online payments.

Academics

Classes, exams, marks, report cards, timetable, homework and attendance.

Parent and student portal

Fees, results, attendance, homework, notices, calendar and leave in one place.

Permission model

Grants come from the API and are mirrored locally, so the UI hides what a role cannot do.

Documents and charts

Print-ready student certificates and dashboards drawn with Recharts.

Architecture at a glance

  1. 1A dynamic [base] segment serves every staff role from one set of pages, wrapped in RoleGuard and AppShell.
  2. 2lib/roles.js maps each role to its home path and permission grants, with the API as the authority.
  3. 3The portal for parents and students lives under /portal with its own shell.
  4. 4The backend is an Express API on MySQL with JWT auth and role checks.

README

The repository's own README.md, with its diagrams, folder structure and setup steps.

README.md ยท Gautam5514/school_frontend

๐Ÿซ School CRM - Phase 1 (Next.js)

A complete School CRM foundation for managing students, staff, activities, and operations.

๐Ÿ“‹ Features (Phase 1)

โœ… Implemented

  • Authentication: JWT-based login system
  • User Management: CRUD operations for staff/teachers
  • Student Management: Complete student profiles
  • Student Remarks: Behavioral and academic tracking
  • Student Activities: Sports, cultural, competitions tracking
  • Director Reports: Dashboard overview with key metrics
  • Role-Based Access: Director, Principal, Admin, Manager, Teacher, Staff

๐Ÿ“Š Database

  • Schools
  • Users (with roles)
  • Students
  • Admissions
  • Fees
  • Student Remarks
  • Student Activities
  • Staff Activities

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+
  • MySQL 8+
  • npm or yarn

1๏ธโƒฃ Database Setup

# Run the database schema
mysql -u your_user -p your_database < database/schema.sql

# Or connect to MySQL and run the schema manually

The schema file is located at: database/schema.sql

2๏ธโƒฃ Backend Setup

cd backend

# Install dependencies
npm install

# Configure environment variables
# The .env file is already configured with your database credentials

# Create admin user (IMPORTANT!)
node scripts/createAdmin.js

# Start the server
npm start

# Or for development with auto-reload
npm run dev

Backend will run on: http://localhost:8080

3๏ธโƒฃ Frontend Setup (Next.js)

cd frontend

# Install dependencies (if not already installed)
npm install

# Create .env.local file
echo "NEXT_PUBLIC_API_URL=http://localhost:8080/api" > .env.local

# Start development server
npm run dev

Frontend will run on: http://localhost:3000


๐Ÿ“ก API Endpoints

Authentication

  • POST /api/auth/login - Login
  • GET /api/auth/me - Get current user

Users

  • GET /api/users - List all users
  • GET /api/users/:id - Get user
  • POST /api/users - Create user
  • PATCH /api/users/:id - Update user
  • DELETE /api/users/:id - Deactivate user

Students

  • GET /api/students - List students (with filters)
  • GET /api/students/:id - Get student
  • POST /api/students - Create student
  • PATCH /api/students/:id - Update student

Student Remarks

  • POST /api/students/:id/remarks - Add remark
  • GET /api/students/:id/remarks - Get remarks

Student Activities

  • POST /api/students/:id/activities - Add activity
  • GET /api/students/:id/activities - Get activities

Reports

  • GET /api/reports/overview - Dashboard statistics

๐Ÿ‘ฅ User Roles & Permissions

RolePermissions
DirectorView all data, oversight reports (read-only)
PrincipalView students, activities, remarks, teacher activities
AdminFull CRUD access (students, users, fees, admissions)
ManagerFull CRUD access (students, users, fees, admissions)
TeacherAdd remarks & activities for students
StaffProfile exists, activities can be logged

๐Ÿ—๏ธ Project Structure (Next.js)

school/
โ”œโ”€โ”€ database/
โ”‚   โ””โ”€โ”€ schema.sql              # Complete database schema
โ”‚
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ config/
โ”‚   โ”‚   โ””โ”€โ”€ db.js              # MySQL connection
โ”‚   โ”œโ”€โ”€ middleware/
โ”‚   โ”‚   โ””โ”€โ”€ auth.js            # JWT + role check
โ”‚   โ”œโ”€โ”€ routes/
โ”‚   โ”‚   โ”œโ”€โ”€ auth.routes.js
โ”‚   โ”‚   โ”œโ”€โ”€ users.routes.js
โ”‚   โ”‚   โ”œโ”€โ”€ students.routes.js
โ”‚   โ”‚   โ”œโ”€โ”€ remarks.routes.js
โ”‚   โ”‚   โ””โ”€โ”€ reports.routes.js
โ”‚   โ”œโ”€โ”€ scripts/
โ”‚   โ”‚   โ””โ”€โ”€ createAdmin.js     # Admin user generator
โ”‚   โ”œโ”€โ”€ .env                   # Environment variables
โ”‚   โ”œโ”€โ”€ index.js               # Server entry point
โ”‚   โ””โ”€โ”€ package.json
โ”‚
โ””โ”€โ”€ frontend/ (Next.js App Router)
    โ”œโ”€โ”€ app/
    โ”‚   โ”œโ”€โ”€ layout.js          # Root layout
    โ”‚   โ”œโ”€โ”€ page.js            # Home (redirects)
    โ”‚   โ”œโ”€โ”€ globals.css        # Global styles
    โ”‚   โ”œโ”€โ”€ login/
    โ”‚   โ”‚   โ””โ”€โ”€ page.js        # Login page
    โ”‚   โ””โ”€โ”€ dashboard/
    โ”‚       โ””โ”€โ”€ page.js        # Dashboard page
    โ”œโ”€โ”€ lib/
    โ”‚   โ””โ”€โ”€ api.js             # Axios + auth utilities
    โ”œโ”€โ”€ next.config.mjs
    โ”œโ”€โ”€ tailwind.config.js
    โ”œโ”€โ”€ jsconfig.json          # Path aliases (@/)
    โ””โ”€โ”€ package.json

๐Ÿงช Testing

Test Backend

# Health check
curl http://localhost:8080/health

# Login
curl -X POST http://localhost:8080/api/auth/login \
  -H "Content-Type: application/json" \
  -d '{"email":"<admin-email>","password":"<admin-password>"}'

# Get students (with token)
curl http://localhost:8080/api/students \
  -H "Authorization: Bearer YOUR_TOKEN"

Test Frontend

  1. Open browser to http://localhost:3000
  2. Should redirect to /login
  3. Login with admin credentials
  4. Should redirect to /dashboard
  5. View dashboard with statistics
  6. Test logout functionality

๐Ÿ”’ Security Notes

  1. Change default passwords immediately after setup
  2. Update JWT_SECRET in backend/.env to a strong random string
  3. Use HTTPS in production
  4. Enable CORS properly for your domain
  5. Implement rate limiting for production
  6. Regular database backups

๐Ÿ›ฃ๏ธ Phase 2 Roadmap

  • Staff Activity Management (UI)
  • Admissions Management (UI)
  • Fees Management (UI)
  • Advanced Reporting
  • Bulk Operations
  • Excel Import/Export
  • Email Notifications
  • WhatsApp Integration

๐Ÿ› Troubleshooting

Database Connection Failed

  • Check MySQL is running
  • Verify credentials in backend/.env
  • Ensure database exists

Cannot Login

  • Run createAdmin.js script first
  • Check backend console for errors
  • Verify JWT_SECRET is set

Frontend API Errors

  • Ensure backend is running on port 8080
  • Check .env.local has NEXT_PUBLIC_API_URL=http://localhost:8080/api
  • Open browser console for detailed errors

Next.js Build Errors

  • Delete .next folder and node_modules
  • Run npm install again
  • Ensure Node.js version is 18+

๐Ÿ“ Next.js Specific Notes

SSR Considerations

  • Authentication check runs on client-side only
  • localStorage access is wrapped in typeof window !== 'undefined'
  • All auth-dependent pages use 'use client' directive

Environment Variables

  • Use NEXT_PUBLIC_ prefix for client-side variables
  • Create .env.local file (gitignored by default)

Path Aliases

  • Use @/ to import from root (configured in jsconfig.json)
  • Example: import api from '@/lib/api'

๐Ÿ“„ License

Private - School Management System


๐Ÿ‘จโ€๐Ÿ’ป Support

For issues or questions, contact your development team.

Built with โค๏ธ for Modern School Management