This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
bun install- Install dependenciesbun dev- Start development server with file watchingbun start- Start production serverbun test- Run all testsbun test --watch- Run tests in watch modebun test tests/e2e/- Run only end-to-end tests
docker compose up -d- Start services (includes Redis for job queue)docker compose down- Stop services
- Runtime: Bun (TypeScript)
- Framework: Express.js
- Database: PostgreSQL (via Knex.js)
- Authentication: Supabase JWT
- Job Queue: BullMQ with Redis
- Geolocation: MaxMind GeoIP2
controllers/ # Express route handlers (REST API endpoints)
services/ # Business logic layer
repos/ # Data access layer (database operations)
middleware/ # Express middleware (auth, error handling)
types/ # TypeScript type definitions
config/ # Database, Redis, Supabase configuration
utils/ # Shared utilities (caching)
tests/ # Unit tests and E2E tests
The application follows a layered architecture:
- Controllers handle HTTP requests/responses and route to services
- Services contain business logic and orchestrate data operations
- Repos handle database queries and data persistence
- Middleware handles cross-cutting concerns (auth, errors)
Services should follow these patterns:
- Export individual functions as
constdeclarations - Export a single service object at the end:
export const ServiceName = { func1, func2 } - Import dependencies at the top (repos, config, middleware)
- Use proper error handling with
ApiErrorfor business logic errors - Functions should be focused on single responsibilities
- Use descriptive function names that clearly indicate their purpose
- JobQueueService: Manages background jobs with BullMQ (user monitoring, notifications)
- GeoLocationService: IP-based location detection using MaxMind database
- UserProfileService: User data management and location tracking
- FriendsService: Social features and friend connections
- NotificationService: User notification system
- WebhookService: Handles Stripe webhook event processing
- StripeService: Stripe API interactions and checkout session creation
- LicenseService: User license management and validation
- Uses Supabase JWT tokens for API authentication
- Test mode available with
valid_test_tokenfor automated testing - Auth middleware protects all
/apiroutes except/api/marketing
- Background job processing with Redis/BullMQ
- Scheduled jobs: new user checks (10min), paid user checks (10min), inactive user checks (daily 9AM)
- Manual job triggers available via
/api/jobsendpoints - Graceful shutdown handling with job queue cleanup
- PostgreSQL with Knex.js query builder
- Connection pooling configured (min: 2, max: 10)
- Environment-based configuration
- Copy
.env.exampleto.env - Required: Supabase credentials, PostgreSQL connection, Redis connection
- Optional: GEOIP_DATABASE_PATH for location features
- Global error handling with ApiError class
- Development vs production error details
- Graceful service degradation (GeoIP, job queue failures don't crash server)
- Unit tests with Bun test runner
- E2E tests using Supertest
- Test authentication with mock tokens
- Fixtures and helpers in
tests/directory
- Avoid
return awaitin async functions - prefer direct return of promises