A robust, scalable NestJS backend for the Stellar Uzima health and wellness platform. This repository contains the core API and services that power the Uzima ecosystem.
- Overview
- Tech Stack
- Project Structure
- Getting Started
- Development
- API Documentation
- Operational Runbooks
- Contributing
- License
Stellar Uzima is a comprehensive health and wellness platform designed to help users manage their health goals, track progress, and receive personalized recommendations. The backend provides:
- Authentication & Authorization: Secure user authentication with JWT tokens
- User Management: Complete user profile and account management
- Health Tasks: Track and manage health-related tasks and habits
- Data Persistence: Robust database operations with TypeORM
- Error Handling: Comprehensive error handling and logging
- API Documentation: Auto-generated API documentation with Swagger
- Runtime: Node.js (v18+)
- Framework: NestJS 10+
- Language: TypeScript
- Database: PostgreSQL with TypeORM
- Authentication: JWT (JSON Web Tokens)
- Validation: class-validator, class-transformer
- Testing: Jest
- API Documentation: Swagger/OpenAPI
- Linting & Formatting: ESLint, Prettier
This project uses ESLint for code linting and Prettier for automatic code formatting to ensure consistent code style across all contributions.
Run these commands to maintain code quality:
# Run linting and automatically fix issues
npm run lint
# Only check for linting issues without fixing
npm run lint:check
# Run Prettier to format all files
npm run format
# Only check if files are properly formatted
npm run format:check
# Run both linting fixes and formatting
npm run lint:format
.eslintrc.js: ESLint configuration with TypeScript support.prettierrc: Prettier formatting rules.prettierignore: Files to exclude from formattingeslint.config.mjs: Modern ESLint flat configuration
Run checks explicitly before submitting changes. The current package.json does
not declare a prepare script installing a pre-commit hook; do not rely on an
automatically installed hook.
backend/
βββ src/
β βββ main.ts # Application entry point
β βββ app.module.ts # Root module
β βββ app.controller.ts # Root controller
β βββ app.service.ts # Root service
β β
β βββ common/ # Shared utilities and components
β β βββ decorators/ # Custom decorators (auth, roles, etc.)
β β βββ filters/ # Exception filters
β β βββ guards/ # Authentication & authorization guards
β β βββ interceptors/ # Request/response interceptors
β β βββ pipes/ # Validation and transformation pipes
β β βββ dtos/ # Common DTOs (pagination, responses)
β β βββ utils/ # Utility functions and helpers
β β
β βββ config/ # Configuration management
β β βββ database.config.ts
β β βββ app.config.ts
β β βββ validation.schema.ts
β β
β βββ database/ # Database setup and migrations
β β βββ migrations/
β β βββ seeds/
β β βββ entities/ # Database entities
β β
β βββ modules/ # Feature modules
β β βββ auth/ # Authentication module
β β β βββ auth.module.ts
β β β βββ auth.controller.ts
β β β βββ auth.service.ts
β β β βββ strategies/ # Passport strategies
β β β βββ guards/
β β β βββ dtos/
β β β
β β βββ users/ # User management module
β β β βββ users.module.ts
β β β βββ users.controller.ts
β β β βββ users.service.ts
β β β βββ entities/
β β β βββ dtos/
β β β
β β βββ health-tasks/ # Health tasks module
β β βββ health-tasks.module.ts
β β βββ health-tasks.controller.ts
β β βββ health-tasks.service.ts
β β βββ entities/
β β βββ dtos/
β β
β βββ shared/ # Shared services (mail, notifications, etc.)
β βββ mail/
β βββ notifications/
β βββ logger/
β
βββ test/ # End-to-end tests
β βββ app.e2e.spec.ts
β
βββ package.json
βββ tsconfig.json
βββ nest-cli.json
βββ jest.config.js
βββ .env.example
βββ .eslintrc.js
βββ .prettierrc
βββ .gitignore
βββ Dockerfile
βββ docker-compose.yml
βββ README.md
Follow Local development for prerequisites, a fresh clone, environment setup, PostgreSQL/Redis startup, migrations and tests. It includes POSIX and PowerShell test configuration, optional integrations and current application startup blockers. Use Node 20.x to match CI.
Development uses APP_PORT (default 3001) and DB_NAME. E2E tests require
separate explicit TEST_DB_* settings and a disposable PostgreSQL server; see
Isolated E2E databases. A passing database-harness test is
not evidence that the complete backend or migration chain is healthy.
# Development
npm run start # Start the application
npm run start:dev # Start with hot reload
npm run start:debug # Start with debug mode
# Building
npm run build # Build for production
# Testing
npm run test # Run unit tests
npm run test:watch # Run tests with watch mode
npm run test:cov # Run tests with coverage
npm run test:e2e # Run e2e tests
# Database
npm run migrate # Run migrations
npm run migrate:rollback # Revert last migration
npm run seed # Seed the database
npm run seed:db # Run database seeders
# Linting & Formatting
npm run lint # Run ESLint
npm run lint:fix # Fix linting errors
npm run format # Format with Prettier
This project uses ESLint and Prettier for code consistency:
- ESLint: Enforces code quality rules
- Prettier: Handles automatic code formatting
# Format all files
npm run format
# Check and fix linting issues
npm run lint:fix
Use the local configuration guide
to reconcile .env.example with the active consumers. The HTTP server uses
APP_PORT, DatabaseModule uses DB_NAME, and the E2E harness uses only explicit
TEST_DB_* settings. Legacy factories and migration helpers use some different
aliases; do not assume every variable in an example configures the running app.
API documentation is available via Swagger at:
http://localhost:3001/api/docs
Swagger is generated at application startup by SwaggerModule.createDocument;
there is no separate swagger npm script.
Procedures for responding to incidents and monitoring alerts live in docs/runbooks/:
- Database Outage
- Authentication Issues
- Queue Failures
- Redis Incidents
- Notification Provider Incidents
- Stellar Incidents
- Reward Regressions
Runbooks are versioned and reviewed as part of the release process β see the versioning & review policy.
The project uses Jest for unit and integration testing.
# Run all tests
npm run test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:cov
Create test files next to the modules with .spec.ts suffix:
// Example: users.service.spec.ts
import { Test, TestingModule } from '@nestjs/testing';
import { UsersService } from './users.service';
describe('UsersService', () => {
let service: UsersService;
beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({
providers: [UsersService],
}).compile();
service = module.get<UsersService>(UsersService);
});
it('should be defined', () => {
expect(service).toBeDefined();
});
});
This API uses URI-based versioning. All endpoints are available under /api/v1/.
| Version | Status | Base URL |
|---|---|---|
| v1 | Active | /api/v1/ |
GET /api/v1/auth/login GET /api/v1/users/profile
When breaking changes are introduced, a new version (e.g., /api/v2/) will be added.
Existing versions remain available to allow gradual client migration.
The local guide
documents starting only PostgreSQL and Redis, host/container addresses, health
checks and non-destructive cleanup. The optional full and tools profiles
are defined in docker-compose.yml. The full profile still depends on the
application build; it is not a workaround for the documented baseline failures.
Detailed documentation for each module is available in their respective README files:
- Auth Module - Authentication and authorization
- Users Module - User management
- Health Tasks Module - Health task tracking
- Database Module - Database setup and migrations
This repository uses Dependabot (see .github/dependabot.yml):
- Weekly pull requests for routine npm dependency updates (non-breaking, reviewed before merge).
- Daily monitoring with prioritized PRs for security patches (labeled
security). - Maintainers should merge security updates promptly; routine updates can follow the normal PR review process.
We welcome contributions! Please read our CONTRIBUTING.md for detailed guidelines on:
- Setting up your development environment
- Making code changes
- Creating pull requests
- Code review process
- Commit message conventions
We follow conventional commits:
feat: Add new feature
fix: Fix a bug
docs: Update documentation
style: Code style changes
refactor: Refactor code
perf: Performance improvements
test: Add or update tests
chore: Maintenance tasks
- Never commit
.envfiles with sensitive data - Always use environment variables for secrets
- Validate all user inputs
- Follow OWASP security guidelines
- Report security issues to the maintainers
This project is licensed under the MIT License - see the LICENSE file for details.
For issues, questions, or suggestions:
- Check existing GitHub Issues
- Create a new issue with a clear description
- Contact the maintainers
Before deployment, complete Backend release readiness. It records evidence for tests, migrations, configuration, monitoring and rollback, with release ownership, approved exceptions and go/no-go authorization. It also links the existing mandatory security review and operational runbooks.
Happy coding! π