Modular, scalable backend powering the ViBe platform — built with TypeScript, Express, MongoDB, and InversifyJS.
- Overview
- Tech Stack
- Architecture
- Directory Structure
- Key Modules
- Shared Layer
- Getting Started
- Environment Variables
- Scripts
- API Reference
- Testing
- Deployment
- Contributing
ViBe Backend is a domain-driven, modular REST API that supports:
- Authentication — Firebase-based auth with JWT support
- Course Management — Full CRUD for courses, versions, modules, sections, and items (video, quiz, blog)
- Quizzes — Question banks, attempts, grading, and multiple question types
- User Progress — Enrollment tracking, watch time, and progress analytics
- Notifications — Invite management and email notifications
- Anomaly Detection — Monitoring suspicious user/course behavior
- Settings — Proctoring and custom configuration per user/course
- GenAI — Generative AI feature integration
| Layer | Technology |
|---|---|
| Language | TypeScript |
| Web Server | Express + routing-controllers |
| Database | MongoDB (Repository pattern) |
| Dependency Injection | InversifyJS |
| Auth | Firebase Admin + JWT |
| Error Monitoring | Sentry |
| API Docs | OpenAPI via Scalar |
| Testing | Vitest |
| Containerization | Docker |
Client → Express Router → Controller → Service → Repository → MongoDB
↑
InversifyJS DI Container
- Express handles HTTP routing via
routing-controllers - InversifyJS wires controllers, services, and repositories through a central DI container
- Repository pattern abstracts all database access
- Modular structure — each domain (auth, courses, quizzes, etc.) is self-contained under
src/modules/
backend/
├── plop-templates/ # Code generation templates
│ ├── controller.hbs
│ ├── repository.hbs
│ ├── service.hbs
│ └── module-base/
├── src/
│ ├── bootstrap/ # Module loader and startup logic
│ ├── config/ # App, DB, AI, SMTP, storage configs
│ ├── container.ts # Inversify DI container setup
│ ├── index.ts # Entry point
│ ├── modules/ # Domain-driven business logic
│ │ ├── anomalies/
│ │ ├── auth/
│ │ ├── courses/
│ │ ├── genAI/
│ │ ├── notifications/
│ │ ├── quizzes/
│ │ ├── settings/
│ │ └── users/
│ ├── shared/ # Common utilities, interfaces, middleware
│ │ ├── classes/
│ │ ├── constants/
│ │ ├── database/
│ │ ├── functions/
│ │ ├── interfaces/
│ │ └── middleware/
│ └── utils/ # env, logging, type helpers
├── .example.env
├── Dockerfile
├── plopfile.cjs
├── tsconfig.json
└── README.md
Note: Compiled output goes to
build/— do not edit directly.
Firebase-based authentication — signup, login, password management, and token verification via FirebaseAuthService.
Full lifecycle management for courses, versions, modules, sections, and content items (video, quiz, blog) via CourseRepository.
Question banks, quiz attempts, grading engine, and settings. Supports question types:
| Type | Description |
|---|---|
| SOL | Single Option (MCQ) |
| SML | Select Multiple |
| MTL | Match the Following |
| OTL | Ordering |
| NAT | Numerical Answer |
| DES | Descriptive |
Enrollment, progress tracking, and watch time via EnrollmentService and ProgressService.
Invite management and email delivery via InviteRepository and MailService.
Proctoring configuration and custom settings per user/course via SettingsRepository.
Detects and logs suspicious behavior patterns for monitoring and security review.
Generative AI feature integration (model-agnostic, configurable via config/ai.ts).
| Folder | Purpose |
|---|---|
classes/ |
Base service and utility classes |
constants/ |
App-wide constants |
database/ |
MongoDB connection, base repositories, CRUD interfaces |
functions/ |
OpenAPI spec generation, auth helpers, current user checker |
interfaces/ |
TypeScript interfaces for models and DTOs |
middleware/ |
Logging, error handling, request lifecycle |
- Node.js ≥ 18
- MongoDB instance
- Firebase project
- pnpm
git clone https://github.com/vicharanashala/ajrasakha.git
cd ajrasakha
pnpm installcp .example.env .env
# Fill in required values in .env
pnpm devpnpm plopFollow the prompts to generate a controller, service, and repository for a new domain module.
See .example.env for all required variables. Key categories:
- Database — MongoDB connection URI
- Firebase — Service account credentials
- Sentry — DSN for error monitoring
- SMTP — Email service credentials
- Storage — File storage config
- AI — GenAI provider keys
Never commit
.envto version control.
| Script | Description |
|---|---|
pnpm dev |
Start dev server with hot reload |
pnpm build |
Compile TypeScript to build/ |
pnpm start |
Run compiled server |
pnpm test |
Run Vitest test suite |
pnpm plop |
Scaffold new module via Plop |
generate-openapi.cjs |
Generate OpenAPI spec from codebase |
start.sh |
Production startup script |
Live OpenAPI docs are auto-generated and available at:
http://localhost:<PORT>/reference
Powered by Scalar — interactive, always in sync with the codebase.
pnpm testTests are written with Vitest. Unit and integration tests are colocated with their respective modules.
docker build -f Dockerfile -t vibe-backend .
docker run --env-file .env -p 3000:3000 vibe-backendUse Dockerfile-all for an all-in-one deployment.
Sentry is integrated for real-time error tracking and performance profiling in production and staging environments.
- Use Plop templates (
pnpm plop) to scaffold new controllers, services, and repositories — keep the module structure consistent. - Register new controllers, services, and repositories in the module's
index.tsand the global DI container. - Follow the Repository pattern — no direct DB calls outside of
*Repositoryclasses. - All new code in TypeScript with proper type annotations.
- Write tests in Vitest for any new services or utilities.
Built with ❤️ by the ViBe team