JSON = Contract
All layers (FE, BE, Data, AI) communicate via JSON.
If the JSON shape is stable → teams move independently.
This is the only thing teams must agree on. Everything else can change independently.
Minimal Architecture
Frontend ⇄ REST API ⇄ Backend ⇄ Data / ML
Only shared dependency: JSON schema
Think of the API as a boundary layer — it isolates systems while exposing structured data.
Example Contract
Define this early. This is what every team builds against.
Backend: Define Endpoint (Python / FastAPI)
The backend exposes data through a predictable JSON response via REST endpoints.
Deploy → this becomes a service.
Frontend: Consume It
Frontend simply calls the endpoint and parses JSON — no knowledge of backend logic required.
Frontend only depends on JSON format.
A Quick Note on CORS
If you're testing this locally, your browser will likely block the request with an error like:
Access to fetch at 'http://localhost:8000/score/123' from origin 'http://localhost:3000' has been blocked by CORS policy.
This is CORS (Cross-Origin Resource Sharing). Browsers block requests between different origins (different domain, port, or protocol) by default. It's a security feature — your frontend at localhost:3000 and your API at localhost:8000 are considered different origins.
This isn't a bug in your code. It's the browser protecting users from malicious scripts making requests to APIs they shouldn't access.
The fix lives on the backend. Your API needs to explicitly allow requests from your frontend's origin. In FastAPI:
In production, replace localhost:3000 with your actual frontend domain. Avoid using "*" for allow_origins in production — it means "allow any website to call your API", which is rarely what you want.
Rule of thumb: If the browser blocks it, the backend needs to allow it. Frontend can't fix CORS — only the server can.
Swap Logic: Data / ML Integration
You can replace static logic with real models without breaking consumers.
No frontend changes required.
AI Services Fit the Same Pattern
AI outputs should also conform to structured JSON for consistency and reuse.
Expose via API → reusable across apps.
Rules (Non-Negotiable)
These rules ensure systems remain decoupled and scalable:
Define JSON schema first
Version breaking changes
Never couple UI to backend logic
Keep responses predictable
TL;DR
JSON is not just a format — it's your system contract.
Control the JSON → control the system.
Everything else is replaceable.


