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
- 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
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
- Node.js >= 18.x
- npm, yarn, or pnpm
- PostgreSQL 12+
-
Clone the repository
git clone https://github.com/Stellar-Uzima/Uzima-Backend.git cd backend -
Install dependencies
npm install # or yarn install # or pnpm install
-
Setup environment variables
cp .env.example .env # Edit .env with your configuration -
Run database migrations
npm run migrate
-
Seed the database (optional)
npm run seed
-
Start the development server
npm run start:dev
The application will be available at http://localhost:3000
# 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
npm run build:watch # Build with watch mode
# 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:revert # Revert last migration
npm run seed # Seed the database
# Linting & Formatting
npm run lint # Run ESLint
npm run lint:fix # Fix linting errors
npm run format # Format with PrettierThis 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:fixSee .env.example for all available environment variables:
# App
NODE_ENV=development
PORT=3000
API_PREFIX=api
# Database
DB_HOST=localhost
DB_PORT=5432
DB_USERNAME=postgres
DB_PASSWORD=password
DB_DATABASE=uzima_dev
# JWT
JWT_SECRET=your-secret-key
JWT_EXPIRATION=7d
# CORS
CORS_ORIGIN=http://localhost:3000
# Mail (optional)
MAIL_HOST=smtp.example.com
MAIL_PORT=587
MAIL_USER=your-email@example.com
MAIL_PASSWORD=your-passwordAPI documentation is available via Swagger at:
http://localhost:3000/api/docs
To regenerate OpenAPI documentation:
npm run swaggerThe 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:covCreate 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();
});
});docker build -t uzima-backend .docker-compose up -dDetailed 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
We welcome contributions! Please read our CONTRIBUTOR_GUIDE.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
For production deployment guidelines, see DEPLOYMENT.md
Happy coding! π