Centralized FastAPI + Swagger/OpenAPI service for the Fleet Manager architecture, powered by PostgreSQL.
Create a .env file in the root directory (see .env.example):
DATABASE_URL=postgresql://neondb_owner:your_password@ep-your-project.us-east-2.aws.neon.tech/neondb?sslmode=requirepython -m venv .venv
.\.venv\Scripts\Activate.ps1
pip install -r requirements.txt
python import_data.py
uvicorn app.main:app --reload- Interactive Swagger Docs:
http://127.0.0.1:8000/docs - Root URL: Automatically redirects to
/docs - OpenAPI Schema:
http://127.0.0.1:8000/openapi.json
- Push your updated code to GitHub:
git add . git commit -m "Migrate database to PostgreSQL" git push origin main
- In the Render Dashboard:
- Go to your Web Service (fleet-data-api).
- Navigate to Environment.
- Add an environment variable:
- Key:
DATABASE_URL - Value:
postgresql://neondb_owner:...@ep-...neon.tech/neondb?sslmode=require
- Key:
- Click Save Changes.
- Render will redeploy your service automatically and connect to the PostgreSQL database!
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Redirects to /docs |
GET |
/api/v1/health |
System health and timestamp |
GET |
/api/v1/fleet/summary |
Aggregate statistics by status, connectivity, and warranty |
GET |
/api/v1/offices |
List of all office locations and device counts |
GET |
/api/v1/offices/{office_id}/devices |
Devices located in a specific office |
GET |
/api/v1/devices |
Paginated and filtered devices inventory |
GET |
/api/v1/devices/{device_id} |
Detailed device specification and telemetry |
GET |
/api/v1/devices/{device_id}/health |
Device operational health status |
GET |
/api/v1/devices/{device_id}/warranty |
Device warranty information and remaining days |
GET |
/api/v1/warranty |
Warranty list filtered by status |
GET |
/api/v1/alerts |
Critical alerts for devices requiring attention |