docs and tools

This commit is contained in:
counterweight 2025-12-20 23:09:46 +01:00
parent d3638e2e69
commit 917ab0a584
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
5 changed files with 54 additions and 5 deletions

View file

@ -0,0 +1,19 @@
---
description: Constants and shared elements synchronization between backend and frontend
alwaysApply: false
---
# Backend-to-Frontend Synchronization
The backend is the source of truth. Frontend types and constants are generated/validated from backend definitions.
## Two Mechanisms
1. **OpenAPI → TypeScript**: API response types are generated from FastAPI's OpenAPI schema using `openapi-typescript`. Regenerate with `make generate-types-standalone` after changing Pydantic schemas.
2. **Shared Constants**: `shared/constants.json` holds values needed by both sides (roles, statuses, validation rules). Backend validates this file matches its definitions at startup.
## Key Principle
Never manually define types or constants in the frontend that originate from the backend. Import from `generated/api.ts` or `shared/constants.json` instead.
See `Makefile` for sync commands (`generate-types-standalone`, `check-types-fresh`, `check-constants`).