Files
motovaultpro/backend
2025-08-23 10:47:58 -05:00
..
2025-08-23 10:47:58 -05:00
2025-08-09 12:47:15 -05:00
2025-08-23 10:34:21 -05:00
2025-08-09 12:47:15 -05:00
2025-08-09 12:47:15 -05:00
2025-08-09 12:47:15 -05:00
2025-08-09 12:47:15 -05:00
2025-08-09 12:47:15 -05:00

MotoVaultPro Backend

Modified Feature Capsule Architecture

Each feature is 100% self-contained in src/features/[name]/:

  • api/ - HTTP endpoints and routing
  • domain/ - Business logic and types
  • data/ - Database operations
  • migrations/ - Feature-specific schema
  • external/ - External API integrations
  • tests/ - All feature tests
  • docs/ - Feature documentation

Quick Start (Containerized)

# From project root directory
# Copy environment variables
cp .env.example .env
# Update .env with your credentials

# Build and start all services (including backend)
make setup

# View logs
make logs-backend

# Run migrations
make migrate

# Run tests
make test

Available Commands (Containerized)

From project root:

  • make dev - Start all services in development mode
  • make test - Run tests in containers
  • make migrate - Run database migrations
  • make logs-backend - View backend logs
  • make shell-backend - Open shell in backend container

Inside container (via make shell-backend):

  • npm run dev - Start development server with hot reload
  • npm run build - Build for production
  • npm start - Run production build
  • npm test - Run all tests
  • npm run test:feature -- --feature=vehicles - Test specific feature
  • npm run schema:generate - Generate combined schema

Core Modules

Configuration (src/core/config/)

  • environment.ts - Environment variable validation
  • database.ts - PostgreSQL connection pool
  • redis.ts - Redis client and cache service

Security (src/core/security/)

  • auth.middleware.ts - JWT authentication via Auth0

Logging (src/core/logging/)

  • logger.ts - Structured logging with Winston

Feature Development

To create a new feature capsule:

../scripts/generate-feature-capsule.sh feature-name

This creates the complete capsule structure with all necessary files.

Testing

Tests mirror the source structure:

features/vehicles/
├── domain/
│   └── vehicles.service.ts
└── tests/
    └── unit/
        └── vehicles.service.test.ts

Run tests:

# All tests
npm test

# Specific feature
npm run test:feature -- --feature=vehicles

# Watch mode
npm run test:watch

Environment Variables

See .env.example for required variables. Key variables:

  • Database connection (DB_*)
  • Redis connection (REDIS_*)
  • Auth0 configuration (AUTH0_*)
  • External API keys