Architecture
Overview
The service is an async FastAPI application with SQLAlchemy async sessions and PostgreSQL.
Runtime flow
- App startup runs schema migrations and seed scripts.
- Clients request token generation and validation.
- Survey responses are submitted and persisted.
- Scores are computed from stored responses.
Modules
- main.py: app bootstrap, middleware, route handlers
- database.py: engine/session setup
- models.py: ORM models
- schemas.py: request/response DTOs
- services/: business logic and persistence orchestration
- scripts/: migrations/startup helpers/smoke test
Data flow
- Verification flow:
generate-token -> companies + locations -> verification_requests -> validate-token -> submissions
- Submission flow:
submit-survey -> survey_responses
- Results flow:
submissions/{id}/score -> computed weighted output
Current constraints
- Routes and payload formats are kept backward compatible.
- Existing scoring formulas are preserved.
- category_max_score column name is preserved.
- submission_results and company_results remain persistent tables.
- Runtime linkages for verification_requests, submissions, and aggregate rows are location-based.