Introduction
The backend of Comdeall is built using NestJS, a progressive Node.js framework designed for scalable and maintainable server-side applications. Comdeall is a comprehensive platform for child development and therapy management, serving as the backbone for assessment management, lesson planning, appointment scheduling, and therapist coordination across mobile and web platforms.
⚙️ Core Technologies & Tools
| Category | Stack / Tool |
|---|---|
| Framework | NestJS (v11.x) |
| Language | TypeScript |
| Database | PostgreSQL with Hasura GraphQL engine |
| ORM | Prisma for schema management |
| Authentication | JWT + Firebase Admin SDK |
| Queue & Jobs | BullMQ + Redis |
| Monitoring & APM | Prometheus, Grafana, Loki + Promtail |
| Notifications | Firebase Cloud Messaging (FCM) for push notifications |
| Payment Processing | Razorpay integration + Appstore |
| Media & Storage | AWS S3 + Cloudinary for file management |
| Realtime & Events | WebSockets (socket.io) + @nestjs/event-emitter |
| PDF Generation | Puppeteer for report generation |
�� Authentication & Authorization
- JWT-based authentication with access/refresh token pattern
- Firebase Admin SDK for user management and push notifications
- Role-based access control (Parent, Therapist, Admin)
- Social Login integration ready (Google, Facebook, Apple)
- Sessionless API secured using token-based authentication
🧰 Development Scripts
From the apps/backend directory, you can use the following scripts:
# Run dev server with watch mode
npm run start:dev
# Run e2e tests
npm run test:e2e
# Build the project
npm run build
# Spin up local Docker services (PostgreSQL, Redis, Hasura, etc.)
npm run local:up
# Database and Hasura setup
npm run hasura:setup
npm run prisma:setup
# Open development tools
npm run hasura:console # Hasura GraphQL console
npm run prisma:studio # Prisma Studio for database management
💡 The
local:upscript includes Prometheus configuration and starts all required services.
🗃️ Database & ORM
- PostgreSQL as the primary database
- Hasura GraphQL engine for real-time GraphQL API
- Prisma for:
- Schema migrations and management
- Type-safe database queries
- Database introspection and studio access
Key database scripts:
npm run prisma:dbpull # Pull schema changes from database
npm run prisma:generate # Generate Prisma client
npm run prisma:studio # Launch Prisma Studio
npm run hasura:console # Open Hasura console
npm run hasura:migrate # Apply Hasura migrations
📊 Monitoring & Observability
- Prometheus metrics collection via
@willsoto/nestjs-prometheus - Grafana dashboards for metrics visualization
- Loki + Promtail for centralized logging
- Jaeger for distributed tracing
- Winston for structured logging with daily rotation
- OpenTelemetry integration for observability
🧩 Key Modules and Services
Core Business Logic
- Assessment Management - Child development assessments and scoring
- Lesson Plan System - Structured learning plans with progress tracking
- Appointment Scheduling - Therapist-child appointment management
- User Management - Parent, therapist, and admin user roles
- Subscription Management - Plan-based access control
- Payment Processing - Razorpay integration for subscriptions and appointments
Supporting Services
- Media Management - File uploads, storage, and retrieval
- Notification System - Firebase push notifications
- Background Jobs - Queue-based processing with BullMQ
- Caching - Redis-based response caching
- WebSocket Gateway - Real-time communication
- Support System - Ticket management and resolution
📦 Testing & Code Quality
- Unit and E2E tests powered by
jest - Code linting with ESLint + Prettier
- TypeScript strict mode enabled
- Comprehensive test coverage for business logic
npm run test
npm run test:watch
npm run test:coverage
npm run test:e2e
🚀 API & Documentation
The backend exposes comprehensive APIs for:
- RESTful endpoints with Swagger documentation
- GraphQL API via Hasura for real-time queries
- WebSocket connections for live updates
- File upload/download endpoints
- Authentication and authorization flows
Access Swagger documentation at: http://localhost:${PORT}/api
📄 Environment Setup
Create .env file with required variables:
# Database
DATABASE_URL=postgresql://...
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=comdeall
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
# Authentication
JWT_SECRET=...
FIREBASE_PROJECT_ID=...
FIREBASE_PRIVATE_KEY=...
FIREBASE_CLIENT_EMAIL=...
# External Services
RAZORPAY_KEY_ID=...
RAZORPAY_KEY_SECRET=...
SENDGRID_API_KEY=...
# Hasura
HASURA_GRAPHQL_ADMIN_SECRET=...
HASURA_GRAPHQL_ENDPOINT=http://localhost:8080/v1/graphql
# Monitoring
PROMETHEUS_PORT=9090
GRAFANA_PORT=3000
GRAFANA_ADMIN_PASSWORD=...
Refer to .env.example for the complete list of required environment variables.
🏗️ Architecture Highlights
- Modular Design - Clean separation of concerns with dedicated modules
- GraphQL + REST - Hybrid API approach for optimal performance
- Real-time Updates - WebSocket integration for live data
- Background Processing - Queue-based job processing
- Comprehensive Logging - Structured logging with multiple outputs
- Health Checks - Built-in health monitoring endpoints
- Rate Limiting - API protection with throttling
- Caching Strategy - Multi-layer caching for performance
✅ Final Notes
This backend is specifically designed for child development and therapy management, providing a robust foundation for:
- Assessment tracking and progress monitoring
- Lesson plan management with adaptive learning paths
- Appointment coordination between therapists and families
- Subscription-based access to premium features
- Real-time communication and notifications
- Comprehensive reporting and analytics
🚀 Built for scale. Ready for real-world child development applications. Let's explore the specific modules and their functionality.