School CRM โ Multi-role school management
One system for directors, principals, front office, accounts, teachers, parents and students.
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
- 1A dynamic [base] segment serves every staff role from one set of pages, wrapped in RoleGuard and AppShell.
- 2lib/roles.js maps each role to its home path and permission grants, with the API as the authority.
- 3The portal for parents and students lives under /portal with its own shell.
- 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.
๐ซ 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- LoginGET /api/auth/me- Get current user
Users
GET /api/users- List all usersGET /api/users/:id- Get userPOST /api/users- Create userPATCH /api/users/:id- Update userDELETE /api/users/:id- Deactivate user
Students
GET /api/students- List students (with filters)GET /api/students/:id- Get studentPOST /api/students- Create studentPATCH /api/students/:id- Update student
Student Remarks
POST /api/students/:id/remarks- Add remarkGET /api/students/:id/remarks- Get remarks
Student Activities
POST /api/students/:id/activities- Add activityGET /api/students/:id/activities- Get activities
Reports
GET /api/reports/overview- Dashboard statistics
๐ฅ User Roles & Permissions
| Role | Permissions |
|---|---|
| Director | View all data, oversight reports (read-only) |
| Principal | View students, activities, remarks, teacher activities |
| Admin | Full CRUD access (students, users, fees, admissions) |
| Manager | Full CRUD access (students, users, fees, admissions) |
| Teacher | Add remarks & activities for students |
| Staff | Profile 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
- Open browser to http://localhost:3000
- Should redirect to /login
- Login with admin credentials
- Should redirect to /dashboard
- View dashboard with statistics
- Test logout functionality
๐ Security Notes
- Change default passwords immediately after setup
- Update JWT_SECRET in
backend/.envto a strong random string - Use HTTPS in production
- Enable CORS properly for your domain
- Implement rate limiting for production
- 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.jsscript first - Check backend console for errors
- Verify JWT_SECRET is set
Frontend API Errors
- Ensure backend is running on port 8080
- Check
.env.localhasNEXT_PUBLIC_API_URL=http://localhost:8080/api - Open browser console for detailed errors
Next.js Build Errors
- Delete
.nextfolder andnode_modules - Run
npm installagain - Ensure Node.js version is 18+
๐ Next.js Specific Notes
SSR Considerations
- Authentication check runs on client-side only
localStorageaccess is wrapped intypeof window !== 'undefined'- All auth-dependent pages use
'use client'directive
Environment Variables
- Use
NEXT_PUBLIC_prefix for client-side variables - Create
.env.localfile (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