A modular Node.js REST API built with NestJS, Drizzle ORM, and PostgreSQL.
This project implements a Mini School Management API with:
- ✅ Authentication & Authorization using JWT + role-based guards (
admin,teacher,student) - ✅ Students & Classes Management with enrollments
- ✅ PostgreSQL + Drizzle ORM for schema & migrations
- ✅ Validation using
class-validatorDTOs - ✅ Secure Cookies for access/refresh tokens
- ✅ Optional Docker setup for database
git clone https://github.com/<your-repo>/school-management-api.git
cd school-management-api
pnpm installdocker compose up -dGenerate schema & migrations:
pnpm drizzle-kit generate
pnpm drizzle-kit migrate
pnpm drizzle-kit studioSeed database with dummy data:
pnpm run db:seed# development
pnpm run start:dev
# production
pnpm run start:prodAPI will be available at:
👉 http://localhost:3000/api
users– Authentication + roles (admin, teacher, student)students– Student recordsclasses– Class records
POST /auth/signup– Register user (admin/teacher/student)POST /auth/login– Login and receive JWT tokensPOST /auth/refresh– Refresh access tokenPOST /auth/logout– Logout and clear cookiesGET /auth/me– Get logged-in user
POST /students– Create student (admin only)GET /students– List students (admin/teacher)GET /students/:id– Get student details
POST /classes– Create class (admin only)POST /classes/:id/enroll– Enroll student in class (admin/teacher)GET /classes/:id/students– List students in a class (admin/teacher)
- JWT Access Token (15 min expiry) stored in
httpOnlycookie - Refresh Token (7 days expiry) stored in
httpOnlycookie - Role-based guards restrict endpoints to
admin,teacher, orstudent - Password hashing with bcrypt (saltRounds = 10)
nest g res <module_name> --no-specExample:
nest g res auth --no-spec- Download and import the Postman Collection to try out all endpoints quickly.
- Make sure to set the
baseUrlenvironment variable in Postman tohttp://localhost:3000/api(or your deployed URL). - Auth endpoints require no token, but most others require a valid JWT (see Auth section above).
- Interactive Swagger UI available at: http://localhost:3000/api/docs
- Explore all endpoints, schemas, and try requests directly from the browser.
This project is MIT licensed.
