Files
motovaultpro/backend/README.md
Eric Gullickson a052040e3a Initial Commit
2025-09-17 16:09:15 -05:00

2.4 KiB

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
# Ensure a valid .env exists at project root (production values provided by your team)

# 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 start - Build and start all services (production)
  • 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 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 (Fastify Plugin)

  • src/core/plugins/auth.plugin.ts - Auth plugin (Auth0 JWT via JWKS; tokens required in all environments)

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 test -- features/vehicles

# Watch mode
npm run test:watch

Environment Variables

Ensure .env includes these key variables:

  • Database connection (DB_*)
  • Redis connection (REDIS_*)
  • Auth0 configuration (AUTH0_*) — backend validates JWTs via Auth0 JWKS (@fastify/jwt + get-jwks)
  • External API keys