2026-01-09 17:32:54 -05:00
|
|
|
# FastAPI + React Example
|
2026-01-03 13:19:49 -05:00
|
|
|
|
2026-01-09 17:32:54 -05:00
|
|
|
Basic example with a FastAPI backend and a React frontend (Vite).
|
2026-01-03 13:19:49 -05:00
|
|
|
|
2026-01-04 10:36:37 -05:00
|
|
|
## Publish to CitadelHosts.com
|
|
|
|
|
|
|
|
|
|
**All `podman` commands can be replaced with `docker`**
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
podman login registry.citadelhosts.com
|
|
|
|
|
podman build -t registry.citadelhosts.com/react-frontend:latest frontend
|
2026-01-09 17:32:54 -05:00
|
|
|
podman build -t registry.citadelhosts.com/fastapi-backend:latest backend
|
2026-01-04 10:36:37 -05:00
|
|
|
podman image push registry.citadelhosts.com/react-frontend:latest
|
2026-01-09 17:32:54 -05:00
|
|
|
podman image push registry.citadelhosts.com/fastapi-backend:latest
|
2026-01-04 10:36:37 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
2026-01-03 13:19:49 -05:00
|
|
|
## Backend
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cd backend
|
|
|
|
|
python -m venv .venv
|
|
|
|
|
source .venv/bin/activate
|
|
|
|
|
pip install -r requirements.txt
|
2026-01-11 17:31:58 -05:00
|
|
|
export DATABASE_URL="postgresql+psycopg2://user:password@localhost:5432/dbname"
|
2026-01-09 17:32:54 -05:00
|
|
|
uvicorn app:app --reload --port 5000
|
2026-01-03 13:19:49 -05:00
|
|
|
```
|
|
|
|
|
|
2026-01-09 17:32:54 -05:00
|
|
|
FastAPI will run on `http://localhost:5000`.
|
2026-01-03 13:19:49 -05:00
|
|
|
|
2026-01-11 17:31:58 -05:00
|
|
|
Database health check is available at `http://localhost:5000/api/db/health`.
|
|
|
|
|
|
2026-01-03 13:19:49 -05:00
|
|
|
## Frontend
|
|
|
|
|
|
|
|
|
|
```bash
|
|
|
|
|
cd frontend
|
|
|
|
|
npm install
|
|
|
|
|
npm run dev
|
|
|
|
|
```
|
|
|
|
|
|
2026-01-09 17:32:54 -05:00
|
|
|
Vite will run on `http://localhost:5173` and proxy `/api` to the FastAPI server.
|