Loading repository data…
Loading repository data…
hamidukarimi / repository
Backend API for SchoolOS, a modern School Management System handling authentication, users, academic data, and core business logic.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A comprehensive, open-source School Management Information System (MIS) REST API built with Node.js, Express, TypeScript, and MongoDB.
SchoolOS is a production-ready backend system designed for schools of all sizes. It provides a complete REST API for managing every aspect of a school, from students and teachers to exams, fees, attendance, and more.
The authentication system is powered by Authforge-Express, a robust JWT-based auth system with access/refresh token rotation, session management, and role-based access control.
| Layer | Technology |
|---|---|
| Runtime | Node.js |
| Framework | Express.js |
| Language | TypeScript |
| Database | MongoDB + Mongoose |
| Authentication | JWT (Access + Refresh tokens) |
| Validation | Zod |
| Password Hashing | bcrypt |
| Environment | dotenv |
src/
├── config/
│ ├── db.ts # MongoDB connection
│ └── env.ts # Environment variables
├── controllers/
│ ├── user.controller.ts # Auth: register, profile
│ ├── session.controller.ts # Auth: login
│ ├── logout.controller.ts # Auth: logout
│ ├── refresh.controller.ts # Auth: token refresh
│ ├── student.controller.ts
│ ├── teacher.controller.ts
│ ├── class.controller.ts
│ ├── attendance.controller.ts
│ ├── exam.controller.ts
│ ├── grade.controller.ts
│ ├── timetable.controller.ts
│ ├── fee.controller.ts
│ ├── announcement.controller.ts
│ ├── message.controller.ts
│ ├── library.controller.ts
│ └── hr.controller.ts
├── middlewares/
│ ├── auth.middleware.ts # JWT verification
│ ├── adminOnly.middleware.ts # Admin role guard
│ ├── role.middleware.ts # Role-based guard
│ ├── validate.middleware.ts # Zod request validation
│ ├── error.middleware.ts # Global error handler
│ └── rateLimit.middleware.ts # Rate limiting
├── models/
│ ├── User.model.ts
│ ├── Session.model.ts
│ ├── Student.model.ts
│ ├── Teacher.model.ts
│ ├── Class.model.ts
│ ├── Attendance.model.ts
│ ├── Exam.model.ts
│ ├── Grade.model.ts
│ ├── Timetable.model.ts
│ ├── Fee.model.ts
│ ├── Announcement.model.ts
│ ├── Message.model.ts
│ ├── Book.model.ts
│ ├── BookBorrow.model.ts
│ └── Staff.model.ts
├── routes/
│ ├── index.ts # Route aggregator
│ ├── user.routes.ts
│ ├── session.routes.ts
│ ├── logout.routes.ts
│ ├── refresh.routes.ts
│ ├── student.routes.ts
│ ├── teacher.routes.ts
│ ├── class.routes.ts
│ ├── attendance.routes.ts
│ ├── exam.routes.ts
│ ├── grade.routes.ts
│ ├── timetable.routes.ts
│ ├── fee.routes.ts
│ ├── announcement.routes.ts
│ ├── message.routes.ts
│ ├── library.routes.ts
│ └── hr.routes.ts
├── services/
│ ├── user.service.ts
│ ├── session.service.ts
│ ├── refresh.service.ts
│ ├── student.service.ts
│ ├── teacher.service.ts
│ ├── class.service.ts
│ ├── attendance.service.ts
│ ├── exam.service.ts
│ ├── grade.service.ts
│ ├── timetable.service.ts
│ ├── fee.service.ts
│ ├── announcement.service.ts
│ ├── message.service.ts
│ ├── library.service.ts
│ └── hr.service.ts
├── types/
│ └── express.d.ts # Express type extensions
├── utils/
│ ├── ApiError.ts # Custom error class
│ └── jwt.ts # JWT helpers
├── validators/
│ ├── user.validator.ts
│ ├── session.validator.ts
│ ├── student.validator.ts
│ ├── teacher.validator.ts
│ ├── class.validator.ts
│ ├── attendance.validator.ts
│ ├── exam.validator.ts
│ ├── grade.validator.ts
│ ├── timetable.validator.ts
│ ├── fee.validator.ts
│ ├── announcement.validator.ts
│ ├── message.validator.ts
│ ├── library.validator.ts
│ └── hr.validator.ts
├── app.ts # Express app setup
└── server.ts # Server entry point
1. Clone the repository
git clone https://github.com/hamidukarimi/SchoolOS-backend.git
cd SchoolOS-backend
2. Install dependencies
npm install
3. Set up environment variables
cp .env.example .env
Fill in your values in the .env file (see Environment Variables).
4. Build the project
npm run build
5. Start the server
# Development
npm run dev
# Production
npm start
The server will start on the port defined in your .env file (default: 5000).
After starting the server, register a user via the API and then manually update their role to admin in MongoDB:
db.users.updateOne(
{ email: "your@email.com" },
{ $set: { role: "admin" } }
)
Create a .env file in the root directory with the following variables:
# Server
PORT=5000
NODE_ENV=development
# Database
MONGO_URI=mongodb://localhost:27017/schoolos
# JWT
JWT_ACCESS_SECRET=your_access_secret_here
JWT_REFRESH_SECRET=your_refresh_secret_here
JWT_ACCESS_EXPIRES_IN=1d
JWT_REFRESH_EXPIRES_IN=7d
All endpoints are prefixed with /api.
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| POST | /api/users | Register a new user | Public |
| POST | /api/sessions | Login | Public |
| POST | /api/logout | Logout | Required |
| POST | /api/token/refresh | Refresh access token | Public |
| GET | /api/users/me | Get my profile | Required |
| PUT | /api/users/me | Update my profile | Required |
| PUT | /api/users/me/password | Change password | Required |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/students | Get all students | Required |
| GET | /api/students/:id | Get student by ID | Required |
| POST | /api/students | Create a student | Admin |
| PUT | /api/students/:id | Update a student | Admin |
| DELETE | /api/students/:id | Delete a student | Admin |
Query Parameters (GET /api/students)
| Param | Type | Description |
|---|---|---|
| status | string | Filter by status (active, inactive, suspended, graduated) |
| classId | string | Filter by class |
| search | string | Search by name or studentId |
| page | number | Page number (default: 1) |
| limit | number | Results per page (default: 20) |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/teachers | Get all teachers | Required |
| GET | /api/teachers/:id | Get teacher by ID | Required |
| POST | /api/teachers | Create a teacher | Admin |
| PUT | /api/teachers/:id | Update a teacher | Admin |
| DELETE | /api/teachers/:id | Delete a teacher | Admin |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/classes | Get all classes | Required |
| GET | /api/classes/:id | Get class by ID | Required |
| POST | /api/classes | Create a class | Admin |
| PUT | /api/classes/:id | Update a class | Admin |
| DELETE | /api/classes/:id | Delete a class | Admin |
| POST | /api/classes/:id/students | Add student to class | Admin |
| DELETE | /api/classes/:id/students/:studentId | Remove student from class | Admin |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/timetables | Get all timetable entries | Required |
| GET | /api/timetables/:id | Get timetable entry by ID | Required |
| POST | /api/timetables | Create timetable entry | Admin |
| PUT | /api/timetables/:id | Update timetable entry | Admin |
| DELETE | /api/timetables/:id | Delete timetable entry | Admin |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/attendance | Get all attendance records | Required |
| GET | /api/attendance/:id | Get attendance by ID | Required |
| GET | /api/attendance/summary/:studentId | Get student attendance summary | Required |
| POST | /api/attendance | Record single attendance | Admin |
| POST | /api/attendance/bulk | Record bulk attendance | Admin |
| PUT | /api/attendance/:id | Update attendance | Admin |
| DELETE | /api/attendance/:id | Delete attendance record | Admin |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/exams | Get all exams | Required |
| GET | /api/exams/:id | Get exam by ID | Required |
| POST | /api/exams | Create an exam | Admin |
| PUT | /api/exams/:id | Update an exam | Admin |
| DELETE | /api/exams/:id | Delete an exam | Admin |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/grades | Get all grades | Required |
| GET | /api/grades/:id | Get grade by ID | Required |
| GET | /api/grades/summary/:studentId | Get student grade summary | Required |
| POST | /api/grades | Create a grade | Admin |
| POST | /api/grades/bulk | Bulk create grades | Admin |
| PUT | /api/grades/:id | Update a grade | Admin |
| DELETE | /api/grades/:id | Delete a grade | Admin |
Grade Scale
| Percentage | Grade |
|---|---|
| 90% and above | A+ |
| 80% – 89% | A |
| 70% – 79% | B |
| 60% – 69% | C |
| 50% – 59% | D |
| Below 50% | F |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/fees | Get all fees | Required |
| GET | /api/fees/:id | Get fee by ID | Required |
| GET | /api/fees/summary/:studentId | Get student fee summary | Required |
| POST | /api/fees | Create a fee | Admin |
| POST | /api/fees/:id/payment | Record a payment | Admin |
| PUT | /api/fees/:id | Update a fee | Admin |
| DELETE | /api/fees/:id | Delete a fee | Admin |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/announcements | Get all announcements | Required |
| GET | /api/announcements/:id | Get announcement by ID | Required |
| POST | /api/announcements | Create an announcement | Admin |
| PUT | /api/announcements/:id | Update an announcement | Admi |