Welcome to the CoverAI monorepo workspace. This project is structured as a premium, highly optimized full-stack monorepo integrating a high-performance Python FastAPI backend, a Next.js 16 React frontend, shared schemas, and database container stacks.
Status: working end-to-end. The core claim lifecycle is wired and verified: customer files a claim → uploads damage images → submits → AI triage runs in the background → insurer pulls from the queue, self-assigns, and adjudicates. Unit, integration (real Postgres + pgvector), and Playwright e2e suites all run green in CI — a red build fails the pipeline.
coverai/
├── apps/
│ ├── web/ → Next.js 16 frontend (App Router, strict TypeScript, Tailwind CSS)
│ └── api/ → FastAPI backend (Python 3.11, Poetry, SQLAlchemy 2.0 Async)
├── packages/
│ ├── shared-types/ → Centralized Zod schemas & types for validation (User, Vehicle, Policy, Claim)
│ └── ui/ → Workspace-shared visual components (built with shadcn/ui "new-york" preset)
├── .env.example → Core template configuration for credentials and connections
├── docker-compose.yml → Local multi-service infrastructure (postgres, redis, api, web)
├── turbo.json → Workspace pipeline configuration for Turborepo caching
├── Makefile → Orchestration entrypoints for development operations
├── .gitignore → Workspace ignore definitions for Node, Python, IDEs, and credentials
└── README.md → Developer instructions and platform guides
Make sure you have the following installed on your machine:
- Node.js (v18 or newer, v20+ recommended)
- pnpm (v9 or newer, workspace manager)
- Python 3.11+
- Poetry (Python package manager)
- Docker Desktop
Create your local environment file by cloning the template:
cp .env.example .envFill in the credentials inside .env (such as OPENAI_API_KEY, etc.).
From the root directory, run the workspace-level installer to bootstrap both internal packages (shared-types, ui) and the Next.js web app:
pnpm installTo set up autocompletion and dependencies on your host machine:
cd apps/api
poetry install --no-root(Note: If compiling the native postgres driver fails on the host due to a lack of C++ compiler libraries, don't worry! Dependencies compile seamlessly inside our Linux Docker environments.)
We orchestrate our development suite using Docker Compose. Hot reloading is enabled on both Next.js and FastAPI through workspace-level directory mappings.
Spin up the entire platform (PostgreSQL 15, Redis 7, FastAPI Backend, Next.js Frontend):
docker compose up --build- Next.js Web Portal: http://localhost:3000
- FastAPI API Swagger Docs: http://localhost:8000/docs
- FastAPI Health Checks: http://localhost:8000/health
- PostgreSQL Port:
5432 - Redis Port:
6379
We provide a Makefile at the root to automate common lifecycle tasks:
| Command | Action |
|---|---|
make dev |
Spins up the full Docker container environment with hot reload enabled |
make build |
Builds the Node monorepo apps and packages using Turborepo |
make lint |
Runs Node ESLint checks and Python lint analysis |
make test |
Executes both Next.js tests and backend pytest runner |
make migrate |
Applies pending database Alembic schema migrations |
make clean |
Tears down container stacks, purges volumes, and removes build artifacts |
cd apps/api
pytest tests/ -vThese exercise the actual routers over an ASGI transport. They need a
disposable pgvector-enabled Postgres (the compose stack or the pgvector/pgvector
Docker image) and skip cleanly when the variable is unset:
docker compose up -d postgres
# PowerShell: $env:TEST_DATABASE_URL = "postgresql+asyncpg://postgres:postgres@localhost:5432/coverai_test"
# bash: export TEST_DATABASE_URL="postgresql+asyncpg://postgres:postgres@localhost:5432/coverai_test"
cd apps/api
pytest tests/test_claims_api.py -vCreate the test database first if needed: docker exec coverai-postgres createdb -U postgres coverai_test.
pnpm test:e2e| Method | Path | Role | Purpose |
|---|---|---|---|
| POST | /api/v1/claims |
customer | File a new claim (draft) |
| GET | /api/v1/claims |
any | Role-scoped claim list |
| GET | /api/v1/claims/{id} |
any* | Full detail (images, history, policy) |
| POST | /api/v1/claims/{id}/submit |
customer | Submit for review (requires ≥1 image) |
| PATCH | /api/v1/claims/{id}/status |
insurer_officer/admin | Adjudicate (state machine enforced) |
| POST | /api/v1/claims/{id}/images |
customer | Upload damage image (JPEG/PNG/WebP, magic-byte checked) |
| GET | /api/v1/claims/{id}/images |
any* | List images with signed URLs |
| GET | /api/v1/insurer/claims/queue |
insurer_officer/admin | Shared queue (all non-draft claims) |
| POST | /api/v1/insurer/claims/{id}/assign-self |
insurer_officer/admin | Claim a claim (submitted → under_review) |
| POST | /api/v1/insurer/claims/{id}/assign-surveyor |
insurer_officer/admin | Assign field inspection |
| POST | /api/v1/insurer/claims/{id}/adjudicate |
insurer_officer/admin | Approve/reject convenience wrapper |
* claimant, assigned officer, advisor of the claimant, or internal role.
Submitting a claim fires background notify_insurer + run_ai_triage (Gemini);
uploading images fires run_image_ai_analysis (Gemini vision). All AI calls are
consent-gated, logged to ai_call_logs, and counted in Prometheus metrics.
@coverai/shared-types: Zod schemas and inferred types are defined inpackages/shared-typesand referenced in package.json:"@coverai/shared-types": "workspace:*"
@coverai/ui: Premium shared buttons, inputs, and components are defined inpackages/uiand can be imported directly in Next.js:import { Button } from "@coverai/ui";
- Frontend: Vercel (Next.js)
- Backend: Railway (FastAPI)
- Database: Supabase (PostgreSQL)
- Redis: Upstash (serverless)
- AI: Google Gemini API
- Push code to GitHub
- Create a Supabase project → get connection string
- Create a Railway project → connect GitHub repo
- Create a Vercel project → connect GitHub repo
- Get a Gemini API key
Set these in Railway dashboard → Variables:
DATABASE_URL=postgresql://postgres:[PASSWORD]@[HOST]:6543/postgres
REDIS_URL=rediss://default:[PASSWORD]@[HOST]:6379
GEMINI_API_KEY=your_key
JWT_SECRET=generate_with_openssl_rand_hex_32
ALLOWED_ORIGINS=https://your-app.vercel.app
STORAGE_BUCKET=coverai-documents-bucket
FIELD_ENCRYPTION_KEY=REQUIRED
FIELD_ENCRYPTION_KEYis REQUIRED — no default is shipped. The backend refuses to start (and document encryption raises) if it is missing or is not a valid Fernet key. Generate one with:python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
Set in Vercel dashboard → Environment Variables:
NEXT_PUBLIC_API_URL=https://your-backend.railway.app/api/v1
After Railway deploys, run migrations:
# Connect to Railway and run:
cd apps/api
alembic upgrade headOr use the seed script for demo data:
python scripts/seed_dev.py- Connect GitHub repo to Railway
- Select
apps/apias root directory - Railway auto-detects Dockerfile
- Add environment variables
- Deploy → get URL like
https://coverai-api.up.railway.app
- Import repo in Vercel
- Set Root Directory to
apps/web - Add
NEXT_PUBLIC_API_URLenvironment variable - Deploy → get URL like
https://coverai.vercel.app
Update Railway ALLOWED_ORIGINS to include your Vercel URL.
.github/workflows/ci.yml runs on pull requests and pushes to main. The workflow
requests read-only contents permission and cancels superseded runs on the same
ref. It defines two jobs, and every step fails the job on error (no fallbacks):
API job — apps/api, Python 3.12, Poetry 2.2.1, 20-minute timeout, with
pgvector Postgres + Redis service containers:
poetry check --lock— verifiespyproject.tomlandpoetry.lockare in syncpoetry install --no-root --no-interaction— installs locked dependenciespoetry run alembic upgrade head— applies migrations to the service databasepoetry run pytest -q— test suite (unit + integration)poetry run ruff check .— Python lintpoetry run python -m pip_audit— dependency vulnerability audit
Web job — pnpm 9.1.4, Node 20, 15-minute timeout:
pnpm install --frozen-lockfile— installs from the committed lockfilepnpm --filter web lintpnpm --filter web exec tsc --noEmitpnpm --filter web buildpnpm audit --audit-level=high— fails on any high or critical advisory
This repository contains no automatic deployment step; deployment is performed manually following the steps below.
- Backend:
https://your-backend.railway.app/health - Frontend:
https://your-app.vercel.app
See EXECUTION_GUIDE.md for local development.