Faculytics is an analytics platform designed to integrate seamlessly with Moodle. This repository contains the backend API built with NestJS.
- Framework: NestJS
- ORM: MikroORM with PostgreSQL
- Validation: Zod & class-validator
- Documentation: Swagger/OpenAPI
- Node.js: v22.x or later
- PostgreSQL: A running instance of PostgreSQL
- Moodle: A Moodle instance with Mobile Web Services enabled.
npm installCopy the sample environment file and update the variables:
cp .env.sample .envRequired Variables:
| Variable | Description |
|---|---|
DATABASE_URL |
PostgreSQL connection string (supports Neon.tech SSL) |
MOODLE_BASE_URL |
Base URL of your Moodle instance (e.g., https://moodle.example.com) |
MOODLE_MASTER_KEY |
Moodle web services master key |
JWT_SECRET |
Secret for signing access tokens |
REFRESH_SECRET |
Secret for signing refresh tokens |
CORS_ORIGINS |
JSON array of allowed origins (e.g., ["http://localhost:4100"]) |
OPENAI_API_KEY |
OpenAI API key (for ChatKit module) |
Optional Variables:
| Variable | Default | Description |
|---|---|---|
PORT |
5200 |
Server port |
NODE_ENV |
development |
development | production | test |
OPENAPI_MODE |
false |
Set to "true" to enable Swagger docs |
SUPER_ADMIN_USERNAME |
superadmin |
Default super admin username |
SUPER_ADMIN_PASSWORD |
password123 |
Default super admin password |
This project uses MikroORM migrations. By default, migrations are automatically applied when the application starts.
To manage migrations manually:
# Create a new migration
npx mikro-orm migration:create
# Apply pending migrations
npx mikro-orm migration:up
# Check migration status
npx mikro-orm migration:list# Development (with watch mode)
npm run start:dev
# Production mode
npm run build
npm run start:prodOnce the application is running, you can access the interactive Swagger documentation at:
http://localhost:5200/swagger
- Linting:
npm run lint - Formatting:
npm run format - Husky: Pre-commit hooks are enabled to ensure code quality (Linting + Formatting).
# Unit tests
npm run test
# E2E tests
npm run test:e2e
# Test coverage
npm run test:covThis project is UNLICENSED.