Skip to content

About

A Stellar-based healthcare platform delivering verified medical knowledge and rewarding professionals with XLM πŸŒβš•οΈ

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

1,383 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Stellar Uzima Backend

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.

πŸ“‹ Table of Contents

🎯 Overview

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

πŸ›  Tech Stack

  • 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

🎨 Code Quality & Formatting

This project uses ESLint for code linting and Prettier for automatic code formatting to ensure consistent code style across all contributions.

Available Scripts

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

Configuration Files

  • .eslintrc.js: ESLint configuration with TypeScript support
  • .prettierrc: Prettier formatting rules
  • .prettierignore: Files to exclude from formatting
  • eslint.config.mjs: Modern ESLint flat configuration

Pre-commit Checks

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.

πŸ“ Project Structure

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

πŸš€ Getting Started

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

Available Scripts

# 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

Code Style

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

Environment Variables

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

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.

🚨 Operational Runbooks

Procedures for responding to incidents and monitoring alerts live in docs/runbooks/:

Runbooks are versioned and reviewed as part of the release process β€” see the versioning & review policy.

πŸ§ͺ Testing

The project uses Jest for unit and integration testing.

Running Tests

# Run all tests
npm run test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:cov

Writing Tests

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();
  });
});

πŸ”„ API Versioning

This API uses URI-based versioning. All endpoints are available under /api/v1/.

Current Version

Version Status Base URL
v1 Active /api/v1/

Examples

GET /api/v1/auth/login GET /api/v1/users/profile

Versioning Strategy

When breaking changes are introduced, a new version (e.g., /api/v2/) will be added. Existing versions remain available to allow gradual client migration.

🐳 Docker

Local development with Docker Compose

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.

πŸ“– Module Guides

Detailed documentation for each module is available in their respective README files:

πŸ“¦ Dependency updates

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.

🀝 Contributing

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

πŸ“ Commit Convention

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

πŸ”’ Security

  • Never commit .env files with sensitive data
  • Always use environment variables for secrets
  • Validate all user inputs
  • Follow OWASP security guidelines
  • Report security issues to the maintainers

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ†˜ Support

For issues, questions, or suggestions:

  1. Check existing GitHub Issues
  2. Create a new issue with a clear description
  3. Contact the maintainers

πŸš€ Deployment

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! πŸŽ‰

About

A Stellar-based healthcare platform delivering verified medical knowledge and rewarding professionals with XLM πŸŒβš•οΈ

Resources

Contributing

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages