https://github.com/coder7475/school_management_apis
https://github.com/coder7475/school_management_apis
Last synced: 28 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/coder7475/school_management_apis
- Owner: coder7475
- Created: 2025-08-26T03:32:32.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-08-26T05:06:12.000Z (6 months ago)
- Last Synced: 2025-08-26T05:36:29.160Z (6 months ago)
- Language: TypeScript
- Size: 129 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
๐ School Management API
A modular Node.js REST API built with NestJS,
Drizzle ORM, and PostgreSQL.
---
## ๐ Description
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-validator` DTOs
- โ
**Secure Cookies** for access/refresh tokens
- โ
**Optional Docker setup** for database
---
## ๐ Getting Started
### 1. Clone & Install
```bash
git clone https://github.com//school-management-api.git
cd school-management-api
pnpm install
```
### 2. Run Database (Postgres with Docker)
```bash
docker compose up -d
```
### 3. Database Management (Drizzle ORM)
Generate schema & migrations:
```bash
pnpm drizzle-kit generate
pnpm drizzle-kit migrate
pnpm drizzle-kit studio
```
Seed database with dummy data:
```bash
pnpm run db:seed
```
### 4. Start Server
```bash
# development
pnpm run start:dev
# production
pnpm run start:prod
```
API will be available at:
๐ `http://localhost:3000/api`
---
## ๐๏ธ Database
### ER Diagram

- `users` โ Authentication + roles (admin, teacher, student)
- `students` โ Student records
- `classes` โ Class records
---
## โก API Endpoints (Highlights)
### Auth Module
- `POST /auth/signup` โ Register user (admin/teacher/student)
- `POST /auth/login` โ Login and receive JWT tokens
- `POST /auth/refresh` โ Refresh access token
- `POST /auth/logout` โ Logout and clear cookies
- `GET /auth/me` โ Get logged-in user
### Student Module
- `POST /students` โ Create student (admin only)
- `GET /students` โ List students (admin/teacher)
- `GET /students/:id` โ Get student details
### Class Module
- `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)
---
## ๐ Authentication & Security
- **JWT Access Token** (15 min expiry) stored in `httpOnly` cookie
- **Refresh Token** (7 days expiry) stored in `httpOnly` cookie
- **Role-based guards** restrict endpoints to `admin`, `teacher`, or `student`
- **Password hashing** with bcrypt (saltRounds = 10)
---
## ๐ ๏ธ Development Tools
### Generate Module/Resource (no tests)
```bash
nest g res --no-spec
```
Example:
```bash
nest g res auth --no-spec
```
### ๐งช API Testing
- Download and import the [Postman Collection](./Mini%20School%20Management%20API.postman_collection.json) to try out all endpoints quickly.
- Make sure to set the `baseUrl` environment variable in Postman to `http://localhost:3000/api` (or your deployed [URL](https://school-management-apis.vercel.app/)).
- Auth endpoints require no token, but most others require a valid JWT (see Auth section above).
### ๐ API Documentation
- Interactive Swagger UI available at: [http://localhost:3000/api/docs](http://localhost:3000/api/docs)
- Explore all endpoints, schemas, and try requests directly from the browser.
---
## ๐ Resources
- [NestJS Docs](https://docs.nestjs.com)
- [Drizzle ORM Docs](https://orm.drizzle.team/)
- [PostgreSQL Docs](https://www.postgresql.org/docs/)
---
## ๐ License
This project is [MIT licensed](./LICENSE).