================================================================================ INDELIS API — Project Setup Guide Cemetery & Gravesite Management SaaS Platform ================================================================================ REQUIREMENTS ------------ - Docker Desktop 4.x+ - Python 3.12+ - PostgreSQL 15+ with PostGIS (via Docker) - Redis 7+ (via Docker) ================================================================================ BACKEND STARTUP ================================================================================ 1. CLONE & CONFIGURE ENVIRONMENT --------------------------------- cd indelis-api cp .env.example .env Edit .env and set at minimum: JWT_SECRET= JWT_REFRESH_SECRET= 2. START DOCKER SERVICES ------------------------ docker-compose up -d This starts: - api → http://localhost:8000 - postgres → localhost:5432 (PostGIS enabled) - redis → localhost:6379 - pgadmin → http://localhost:5050 (admin@indelis.com / admin) - worker → ARQ background job processor Wait for healthy status: docker-compose ps 3. RUN DATABASE MIGRATIONS -------------------------- docker-compose exec api alembic upgrade head Or locally (with DATABASE_URL set in .env): alembic upgrade head This runs 3 migrations: 0001 → Platform tables (accounts, subscriptions, leads, site_settings) 0002 → Auth tables (users, refresh_tokens) 0003 → Domain tables (sections, plots, records, memorials, etc.) + RLS 4. LOCAL DEVELOPMENT (without Docker) -------------------------------------- python -m venv venv source venv/bin/activate # Windows: venv\Scripts\activate pip install -r requirements.txt # Start API uvicorn src.main:app --reload --host 0.0.0.0 --port 8000 # Start ARQ worker (separate terminal) arq src.worker.arq_app.WorkerSettings 5. API DOCUMENTATION --------------------- Swagger UI: http://localhost:8000/api/docs ReDoc: http://localhost:8000/api/redoc 6. HEALTH CHECKS ----------------- GET /health → Basic health GET /health/live → Liveness probe GET /health/ready → Readiness probe (checks DB + Redis) ================================================================================ FRONTEND STARTUP ================================================================================ (Inspect the indelis-web or indelis-frontend directory for the exact setup) If using Vite + React (typical): cd indelis-web cp .env.example .env.local npm install npm run dev App runs at: http://localhost:5173 If using yarn: yarn install yarn dev ================================================================================ KEY ENVIRONMENT VARIABLES ================================================================================ Variable | Required | Description --------------------------------|----------|------------------------------------------ DATABASE_URL | YES | PostgreSQL connection string JWT_SECRET | YES | HS256 signing secret (min 32 chars) JWT_REFRESH_SECRET | YES | Separate secret for refresh tokens REDIS_URL | YES | Redis connection string ANTHROPIC_API_KEY | Optional | Claude AI (biography writer, NL search) OPENAI_API_KEY | Optional | GPT-4o Vision (record extraction) STRIPE_SECRET_KEY | Optional | Stripe payments AWS_ACCESS_KEY_ID | Optional | S3 document/photo storage AWS_SECRET_ACCESS_KEY | Optional | S3 document/photo storage S3_BUCKET | Optional | S3 bucket name (default: indelis-dev) APP_DOMAIN | Optional | Root domain (default: indelis.com) ================================================================================ TENANT ACCESS ================================================================================ Tenant is resolved from (in priority order): 1. Header: X-Tenant-ID (UUID of account) 2. Header: X-Tenant-Slug (subdomain string) 3. Subdomain: riverside.indelis.com → slug "riverside" For local development, use the X-Tenant-Slug header: curl -H "X-Tenant-Slug: testcemetery" http://localhost:8000/api/v1/records ================================================================================ RUNNING TESTS ================================================================================ # Create test database createdb indelis_test # Run all tests pytest tests/ -v # Run with coverage pytest tests/ --cov=src --cov-report=html ================================================================================ PRODUCTION DEPLOYMENT ================================================================================ # Build production image docker build --target production -t indelis-api:latest . # Run migrations before deploy docker run --env-file .env indelis-api:latest alembic upgrade head # Start production API (4 workers) docker run --env-file .env -p 8000:8000 indelis-api:latest \ uvicorn src.main:app --host 0.0.0.0 --port 8000 --workers 4 # Start ARQ worker docker run --env-file .env indelis-api:latest \ arq src.worker.arq_app.WorkerSettings ================================================================================ ARCHITECTURE OVERVIEW ================================================================================ Request → CloudFront → ALB → FastAPI │ TenantMiddleware (subdomain → tenant_id via Redis) │ JWT Auth + RBAC │ Service Layer │ ┌─────────────┴─────────────┐ │ │ PostgreSQL 15 Redis + PostGIS (cache, ARQ) + Row Level Security (tenant_id isolation) Background Jobs (ARQ): - Invoice overdue reminders - QR code generation - Email notifications (AWS SES) - PDF briefing sheets ================================================================================