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 modemake test- Run tests in containersmake migrate- Run database migrationsmake logs-backend- View backend logsmake shell-backend- Open shell in backend container
Inside container (via make shell-backend):
npm run dev- Start development server with hot reloadnpm run build- Build for productionnpm start- Run production buildnpm test- Run all testsnpm run test:feature -- --feature=vehicles- Test specific featurenpm run schema:generate- Generate combined schema
Core Modules
Configuration (src/core/config/)
environment.ts- Environment variable validationdatabase.ts- PostgreSQL connection poolredis.ts- Redis client and cache service
Security (Fastify Plugin)
src/core/plugins/auth.plugin.ts- Auth plugin (mock user in dev; plan for Auth0 JWT)
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
See .env.example for required variables. Key variables:
- Database connection (DB_*)
- Redis connection (REDIS_*)
- Auth0 configuration (AUTH0_*) — backend currently uses mock auth; JWT enforcement planned
- External API keys