A deployable FastAPI service that turns collision-repair intake notes into a structured operational assessment. It demonstrates API design, typed AI outputs, environment-based configuration, JSON logging, graceful fallback behavior, tests, and Docker packaging.
This service supports intake workflow only. It does not provide a repair estimate or guarantee that a vehicle is safe to drive.
- API health: https://collision-intake-api-production.up.railway.app/health
- Swagger docs: https://collision-intake-api-production.up.railway.app/docs
Collision shops lose time when intake details arrive as incomplete calls, emails, photos, and claim notes. This API turns the first customer intake into a structured operational handoff: urgency, conservative drivability guidance, likely damage areas, next steps, customer-ready language, and escalation reasons.
The service intentionally avoids repair estimates, coverage decisions, and safety guarantees. It is designed as a production-style workflow layer that helps a shop triage work faster while keeping human review in the loop.
- urgency level
- conservative drivability guidance
- likely damage areas
- required next steps
- customer-ready follow-up language
- escalation reasons
- confidence score
- persisted audit record retrievable by request ID
flowchart LR
Client["Client or shop intake form"] --> API["FastAPI service"]
API --> Validation["Pydantic validation"]
Validation --> Model["OpenAI Responses API"]
Model --> Assessment["Typed IntakeAssessment"]
Assessment --> Store["SQLite database on Railway volume"]
Store --> Response["JSON response and audit record"]
When OPENAI_API_KEY is absent, the service uses a deterministic fallback so local development, health checks, and tests still work.
Assessments are stored in SQLite so each intake can be retrieved later for auditing or workflow handoff.
POST /v1/intakescreates and assesses an intake.POST /v1/intakes/assesskeeps backward compatibility with the original assessment endpoint.GET /v1/intakeslists recent intake summaries.GET /v1/intakes/{request_id}retrieves the full stored intake and assessment.GET /healthsupports deployment health checks.
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
uvicorn app.main:app --reloadOpen Swagger UI at http://localhost:8000/docs.
docker build -t collision-intake-api .
docker run --rm -p 8000:8000 --env-file .env collision-intake-api- Push this repository to GitHub.
- Create a Railway project from the GitHub repository.
- Railway will detect the
Dockerfileand userailway.tomlfor the/healthdeployment check. - Add service variables:
APP_ENV=production
LOG_LEVEL=INFO
OPENAI_API_KEY=<your key>
OPENAI_MODEL=gpt-5-mini
REQUEST_TIMEOUT_SECONDS=30
DATABASE_PATH=/data/intakes.db
- Add a volume mounted at
/dataso saved intake records survive redeploys. - Generate a public domain from the service Networking settings.
curl -X POST http://localhost:8000/v1/intakes \
-H 'Content-Type: application/json' \
-d '{
"customer_name": "Jordan",
"vehicle": "2021 Toyota RAV4",
"incident_description": "Rear-ended. Liftgate will not open and the rear bumper is pushed inward.",
"drivable": true,
"airbags_deployed": false,
"warning_lights": [],
"insurer": "Example Insurance"
}'pytest -qruff check .
ruff format --check .The GitHub Actions workflow runs linting, formatting checks, tests, and a Docker image build on every push and pull request.
curl http://localhost:8000/v1/intakes/<request_id>The tests/fixtures/evaluation_cases.json file captures representative collision scenarios and expected triage behavior. Current fixtures cover airbag deployment, fluid leaks, minor bumper scrape, dashboard warning lights, and non-drivable vehicles.
- Put the container behind HTTPS and an authenticated gateway.
- Do not log claim numbers, phone numbers, images, or other sensitive customer data.
- Add rate limiting and database migrations before multi-environment deployment.
- Run evaluation fixtures before changing prompts or models.
- Human review remains required before communicating safety or repair decisions.
- Designed a typed AI API around a real collision-shop workflow.
- Used structured outputs rather than parsing untrusted free-form JSON.
- Implemented deterministic fallback behavior for resilience and local testing.
- Added request IDs, structured logs, health checks, validation, tests, and Docker packaging.

