This is what users see and interact with — like a website or mobile app interface.
Built using HTML, CSS, JavaScript, or frameworks like React, Vue, or Angular.
It sends requests (e.g., “Get user data”, “Log in”, “Upload file”) to the backend.
This is your FastAPI application (or Django, Flask, Node.js, etc.).
It sits between the frontend and the database.
The backend:
Receives API requests from frontend
Processes data or applies logic
Interacts with the database or external APIs
Sends the result back to the frontend
💬 Example:
React App (Frontend) ➜ sends request ➜ FastAPI (Backend)
FastAPI ➜ processes ➜ sends JSON response ➜ React App displays it
Stores all your data: users, orders, medicines, files, etc.
Backend communicates with it directly (frontend never touches it).
💬 Example:
Frontend ➜ Backend ➜ Database
When your frontend (say, http://localhost:3000
) tries to call your backend API (http://127.0.0.1:8000
),
the browser blocks it due to different “origins.”
So your FastAPI server adds this:
app.add_middleware(CORSMiddleware, allow_origins=["*"], ...)
✅ This tells the browser:
“Hey, it’s okay! Let this frontend access me.”
Component | Role | Example |
---|---|---|
Frontend | User Interface | React App, HTML Page |
Backend / Server | Logic & API Handling | FastAPI App |
Database | Data Storage | PostgreSQL, MongoDB |
CORS Middleware | Security Bridge | Allows Frontend ↔ Backend |