PH University is a backend system built to manage an educational platform with core features like course management, user authentication, and role-based access. This project is developed using Node.js, Express, and MongoDB.
- Backend: Node.js, Express.js
- Database: MongoDB with Mongoose
- Authentication: JSON Web Token (JWT)
- Validation: Zod
- Authorization: Role-based (Admin, Student, Faculty)
- API Documentation: Swagger (if implemented)
- ✅ JWT-based authentication and secure route access
- ✅ User roles: Admin, Student, Faculty
- ✅ CRUD operations for users and courses
- ✅ Centralized error handling and API response format
- ✅ Input validation using Zod
- ✅ Environment configuration with
dotenv
- Node.js (v18+)
- MongoDB URI
git clone https://github.com/Dodul01/PH-University-Backend.git
cd PH-University-Backend
npm install
PORT=5000
DATABASE_URL=mongodb://localhost:27017/ph-university
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=7d
POST /api/v1/auth/login
Authenticate user and return JWT token.
POST /api/v1/users
Register a new user (Admin or Student).
-
GET /api/v1/courses
Public endpoint to retrieve all courses. -
POST /api/v1/courses
Create a new course (accessible by Admins only).
-
🔐 Password Hashing:
User passwords are hashed using bcrypt before saving to the database. -
🧱 Route Protection:
Sensitive endpoints are protected via JWT middleware. Only authenticated users can access them. -
⏳ Token Expiration:
JWT tokens are configured to expire after a defined period, minimizing risk. -
🔄 Token Refresh Support:
The system is designed to optionally support refresh tokens for secure session renewal.