docs and tools
This commit is contained in:
parent
d3638e2e69
commit
917ab0a584
5 changed files with 54 additions and 5 deletions
19
.cursor/rules/backend_frontend_sync.mdc
Normal file
19
.cursor/rules/backend_frontend_sync.mdc
Normal 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`).
|
||||
Loading…
Add table
Add a link
Reference in a new issue