NestJsTypeOrmPostgreSQLDocker

Department Management System

Department Management System (DMS) - a modular NestJS API for managing users, courses, schedules, attendance, notices, activities, and reports. The project integrates with Auth0 for authentication and role management, exposes a Swagger/OpenAPI UI, and is designed for containerized deployment.

This major release introduces several months of development, bringing powerful new features including AI-driven scheduling, real-time communication, and comprehensive payment gateways. Under the hood, we've completely overhauled our observability stack and optimized performance with advanced caching mechanisms.

✨ New Features

Core Management & Academic Tools

  • AI Course Scheduler: Introduced an AI Agent for dynamic, conflict-free course schedule generation. Processing is handled via background jobs to ensure a smooth user experience.
  • Teacher Management: Added comprehensive tracking for Teacher Attendance and specific Unavailability periods.
  • Room Management: New module to manage and allocate physical spaces across Classrooms, Labs, and Offices.
  • Fee Management: Added a dedicated module to track, manage, and process student fees effectively.

Payments & Integrations

  • Multi-Gateway Payment System: Built a robust payment gateway supporting multiple providers.
  • Provider Integrations: Successfully integrated Stripe and SSLCommerz for secure and seamless transactions.

Real-Time Communication

  • WebSocket Messenger: Launched a fully functional real-time chat application.
  • Chat Features: Supports one-to-one messaging, group chats, and an exclusive admin-only broadcast/chat feature.

Performance Optimizations

  • Redis Caching Engine: Introduced Redis for application-wide caching.
  • Global Interceptors: Implemented global interceptors to seamlessly handle caching and automated cache invalidation, significantly reducing database load.

🏗️ Advanced Infrastructure & Distributed Systems

DMS has evolved into a robust Distributed Microservices Architecture, ensuring high availability and scalability.

🔌 Inter-Service Communication (gRPC)

We use **gRPC** with **Protobuf** definitions (`libs/grpc`) for lightning-fast, type-safe communication between internal services. This drastically reduces latency compared to traditional REST APIs for internal workflows.

🛡️ API Gateway (Kong)

All external requests flow through **Kong Gateway**. It handles:
  • Centralized Routing: Directs client requests to the appropriate microservice.
  • Authentication & Security: Integrated with Auth0 for JWT validation at the edge.
  • Rate Limiting & Plugins: Dynamically managed via declarative configuration (docker/kong/kong.yaml).

📊 Full-Stack Observability

Our monitoring stack provides deep insights into system health and performance:
  • Metrics: Collected via Prometheus and visualized in Grafana.
  • Logging: Log aggregation using Loki and Promtail for centralized querying.
  • Error Tracing: Real-time error capture and alerting using Sentry.

⚙️ Monorepo Orchestration

The project is managed as a monorepo using **pnpm workspaces** and **NestJS monorepo mode**. Shared logic is encapsulated in libraries:
  • libs/ai: AI Agent utilities.
  • libs/grpc: Shared proto definitions and generated gRPC clients.
  • libs/common: Core utilities, decorators, and shared filters.

🛠 Chores, DX, & Technical Debt

Architecture & Developer Experience (DX)

  • Module Restructuring: Completely reorganized the codebase, grouping modules logically by functionality and domain for better scalability.
  • Commitlint: Enforced standard commit conventions across the repository.
  • Husky Pre-commit Hooks: Integrated Husky to automatically run and pass test cases strictly on staged files before allowing commits, ensuring code stability.

Observability, Logging, & Tracing

  • Default Logger: Replaced the standard logger with Winston, supporting advanced file and console logging out of the box.
  • Full Monitoring Stack: Added a complete infrastructure monitoring solution using Loki, Promtail, Prometheus, and Grafana.
  • Error Tracking: Integrated Sentry for real-time error tracing, alerting, and debugging.

New Tools & Technologies Introduced

This document outlines the new tools, frameworks, services, and integrations added to the Department Management System (DMS) during the latest development cycle.

🤖 Artificial Intelligence

  • Google Generative AI: Integrated to power the new AI Agent responsible for dynamic, conflict-free course schedule generation.

💳 Finance & Payments

  • Stripe: Integrated as a primary payment gateway for secure, reliable fee processing.
  • SSLCommerz: Added to support localized, multi-channel payment processing for student fees.

⚡ Performance, Caching & Background Jobs

  • Redis: Implemented as the core caching engine (utilizing global interceptors) to significantly reduce database load and improve response times.
  • BullMQ: Utilized alongside Redis to handle robust background job processing, specifically to manage heavy tasks like AI schedule generation without blocking the main event loop.

💬 Real-Time Communication

  • WebSockets / Socket.IO: Added to facilitate real-time, bidirectional communication for the newly introduced Messenger module, supporting one-to-one, group, and admin-only broadcasts.

📊 Observability, Logging & Tracing

  • Winston: Replaced the default NestJS logger to provide advanced, customizable file and console logging capabilities.
  • Prometheus & Grafana: Integrated to collect, monitor, and visualize application metrics and infrastructure health.
  • Loki & Promtail: Added to securely aggregate and query logs effectively across the containerized application environment.
  • Sentry: Implemented for real-time application error tracking, alerting, and debugging.

🛠 Developer Experience (DX) & Code Quality

  • Husky: Introduced as a Git hook tool to automatically enforce pre-commit checks, ensuring test cases run successfully on staged files before allowing a commit.
  • Commitlint: Added to strictly enforce standardized commit message formatting across the repository.


DMS (NestJS) — Project Overview

Department Management System (DMS) — a modular NestJS API for managing users, academic operations, attendance, finance, messaging, and reporting. The project integrates with Auth0 for authentication and role management, exposes a Swagger/OpenAPI UI, and is designed for containerized deployment.

Project Structure

├── 📁 apps
│   ├── 📁 academic-service
│   ├── 📁 auth-service
│   ├── 📁 messenger-service
│   ├── 📁 user-service
│   ├── 📁 register-service
│   └── 📁 docs-service
├── 📁 libs
│   ├── 📁 ai
│   ├── 📁 common
│   └── 📁 grpc
├── 📁 docker
├── 🐳 Dockerfile
├── 📄 Dockerfile.prod
├── ⚙️ nest-cli.json
├── ⚙️ package.json
└── ⚙️ tsconfig.json
├── ⚙️ .dockerignore
├── ⚙️ .env.example
├── ⚙️ .gitignore
├── ⚙️ .prettierrc
├── 🐳 Dockerfile
├── 📄 Dockerfile.prod
├── 📝 README.md
├── 📄 commitlint.config.ts
├── ⚙️ docker-compose.prod.yaml
├── ⚙️ docker-compose.yaml
├── 📄 eslint.config.mjs
├── ⚙️ nest-cli.json
├── ⚙️ package.json
├── ⚙️ pnpm-lock.yaml
└── ⚙️ tsconfig.json

Features

  • Authentication & authorization using Auth0 (support for roles and guards)
  • Identity management (students, teachers, admin staff)
  • Academic management (courses, semesters, and course scheduling)
  • Attendance tracking and record-keeping
  • Real-time messaging using WebSockets (messenger module)
  • Finance and payment integration (Stripe, SSLCommerz)
  • Background job processing using BullMQ and Redis
  • AI Integration (Google Generative AI) for automated tasks
  • Comprehensive API documentation via Swagger

Technologies used (details)

  • NestJS — server-side framework used for modular architecture, dependency injection, middleware, pipes, and guards.
  • TypeORM — entity management, migrations, and DB access via PostgreSQL
  • Auth0 — identity provider for user authentication and M2M management interactions
  • class-validator & class-transformer — request DTO validation with custom validators in feature modules.
  • Swagger / OpenAPI — automatic API documentation
  • WebSockets / Socket.IO — real-time bidirectional event-based communication
  • BullMQ / Redis — robust message queue handling for background jobs
  • Stripe & SSLCommerz — secure payment gateway integrations
  • Docker & docker-compose — containerized development and production deployments.
  • TypeScript — language used across the codebase with strict typing.

Installation & Quick Start

Prerequisites:

  • Node.js (LTS) and pnpm recommended
  • Running database (Postgres) and Redis instances, or use the provided Docker Compose setup
  • Auth0 account and credentials if you want to enable full auth integration
  1. Clone repository
git clone <repo-url> dms-api
cd dms-api
  1. Install dependencies
pnpm install
  1. Generate gRPC Types
pnpm run proto:gen
  1. Create environment file
Copy `.env.example` (if present) to `.env` and populate required values:
cp .env.example .env
  r compose up --build

`

Or use the provided Dockerfile and docker-compose.yaml for customization.

Running tests & linting

  • Unit tests:
pnpm run test

`

  • E2E tests:
pnpm run test:e2e
  • Linting:
pnpm run lint

Contact

Example placeholder:

  • Email: mmislam027@gmail.com.com
  • GitHub: https://github.com/mislam-dev