Skip to content

Dodul01/PH-University-Backend

Repository files navigation

PH University - Backend API

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.

🔧 Tech Stack

  • 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)

🔐 Features

  • ✅ 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

🚀 Getting Started

Prerequisites

  • Node.js (v18+)
  • MongoDB URI

Installation

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

🧪 API Endpoints (Sample)

Auth

  • POST /api/v1/auth/login
    Authenticate user and return JWT token.

Users

  • POST /api/v1/users
    Register a new user (Admin or Student).

Courses

  • GET /api/v1/courses
    Public endpoint to retrieve all courses.

  • POST /api/v1/courses
    Create a new course (accessible by Admins only).


🛡️ Security Practices

  • 🔐 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.

About

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.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors