sprout_backend
NestJS-based microservice providing REST API and background job processing for the Sprout platform.
Overview
The sprout_backend is the core API service that provides:
- REST API endpoints for the frontend
- Background job processing with BullMQ
- Event matching and pricing logic
- Inventory management
- User authentication
Technology Stack
- Framework: NestJS 10.x
- Language: TypeScript 5.x
- Database: PostgreSQL with Prisma ORM
- Queue: BullMQ with Redis
- Search: MeiliSearch
- Monitoring: Prometheus, Sentry, OpenTelemetry
- Logging: Pino
Getting Started
Prerequisites
- Node.js 18+
- Bun (preferred) or npm
- Docker (for PostgreSQL and Redis)
- Doppler CLI (for environment variables)
Setup
-
Install dependencies:
bun install -
Start Docker services:
docker-compose up -d -
Run database migrations:
doppler run -- npx prisma migrate dev -
Start development server:
doppler run -- bun run start:dev -
Start background worker (separate terminal):
doppler run -- bun run worker:dev
Key Commands
See Detailed Commands Reference for complete command reference.
Development
bun run start:dev- Start API serverbun run worker:dev- Start background workerbun run build- Build for production
Code Quality
bun run type:check- Type checkingbun run lint- Lint with auto-fixbun run format- Format code
Testing
bun test- Run testsbun run test:cov- Coverage reportbun run test:e2e- E2E tests
Architecture
The service has three main entry points:
- Main API Server (
src/main.ts) - Port 3000 - Background Worker (
src/worker.ts) - Port 4001 - CLI Interface (
src/cli.ts) - Command-line tools
Core Modules
modules/data/- Data processing (event-matcher, skybox, ticketmaster, tickops)modules/db/- Database servicemodules/worker/- Background job processingmodules/cache/- Redis cachingscrapers/- Web scraping services
Database
Uses Prisma ORM with PostgreSQL. Schema includes:
- Event data (TicketmasterEvent, SkyboxResult, CombinedResult)
- Inventory (SkyboxInventory, SkyboxSoldInventory)
- Purchases (AssignedSoldInventory)
- Monitoring (MonitoredListing, MonitoredListingPriceHistory)
- Pipeline tracking (EventRun, EventRunItem)
Queue System
Uses BullMQ with Redis:
- ETL_QUEUE (concurrency: 5) - Data processing
- EVENT_MATCHER_QUEUE (concurrency: 1) - Event matching
View queue dashboard at: http://localhost:3000/queues
API Endpoints
GET /health- Health checkGET /metrics- Prometheus metricsGET /queues- Bull Board UI- REST API endpoints for event and inventory management
Environment Variables
All environment variables are in Doppler. See Environment Variables for complete list.
Key variables:
DATABASE_URL- PostgreSQL connectionREDIS_URL- Redis connectionMEILISEARCH_HOST- MeiliSearch URLSKYBOX_*- Skybox API credentialsTICKETMASTER_API_KEY- Ticketmaster API key
Monitoring
- Metrics: Prometheus at
/metrics - Logging: Structured logging with Pino
- Tracing: OpenTelemetry integration
- Error Tracking: Sentry
Documentation
- Architecture Documentation
- Commands Reference - All available commands
- Additional documentation is available in the
sprout_backendrepository
Related Repositories
- sprout_etl - ETL service
- pricing_dashboard - Frontend dashboard
- sprout_monitoring - Monitoring stack