Deals24Togo — Backend API
Production-grade FastAPI backend for the Deals24Togo marketplace. Supports listings for real estate, vehicles, electronics, furniture, jobs, and services.
Architecture
Tech Stack
| Layer |
Technology |
| Framework |
FastAPI 0.115+ |
| Database |
Supabase (PostgreSQL) |
| Auth |
JWT (python-jose) + bcrypt |
| File Storage |
Supabase Storage |
| Validation |
Pydantic v2 |
| Rate Limiting |
SlowAPI |
| Logging |
structlog (JSON in prod) |
| Monitoring |
Sentry (optional) |
| Container |
Docker |
API Endpoints
Authentication (/api/v1/auth)
| Method |
Path |
Auth |
Description |
| POST |
/register |
Public |
Register user |
| POST |
/login |
Public |
Login, get tokens |
| POST |
/refresh |
Public |
Refresh access token |
| GET |
/me |
Required |
Get current user |
| POST |
/change-password |
Required |
Change password |
| POST |
/password-reset/request |
Public |
Request reset email |
| POST |
/password-reset/confirm |
Public |
Confirm reset with token |
Users (/api/v1/users)
| Method |
Path |
Auth |
Description |
| GET |
/me |
Required |
Get my profile |
| PATCH |
/me |
Required |
Update my profile |
| GET |
/ |
Admin |
List all users |
| GET |
/{user_id} |
Admin |
Get user by ID |
| POST |
/{user_id}/verify |
Admin |
Verify user |
| DELETE |
/{user_id} |
Owner/Admin |
Delete user |
Agencies (/api/v1/agencies)
| Method |
Path |
Auth |
Description |
| GET |
/ |
Public |
List agencies |
| GET |
/me |
Required |
Get my agency |
| GET |
/{agency_id} |
Public |
Get agency by ID |
| POST |
/ |
Required |
Create agency |
| PATCH |
/{agency_id} |
Owner/Admin |
Update agency |
| POST |
/{agency_id}/verify |
Admin |
Verify agency |
| POST |
/{agency_id}/revoke |
Admin |
Revoke verification |
| DELETE |
/{agency_id} |
Admin |
Delete agency |
Categories (/api/v1/categories)
| Method |
Path |
Auth |
Description |
| GET |
/ |
Public |
List all categories |
| GET |
/{category_id} |
Public |
Get category |
| GET |
/slug/{slug} |
Public |
Get category by slug |
| POST |
/ |
Admin |
Create category |
| PATCH |
/{category_id} |
Admin |
Update category |
| DELETE |
/{category_id} |
Admin |
Delete category |
Listings (/api/v1/listings)
| Method |
Path |
Auth |
Description |
| GET |
/ |
Public |
Search/list listings |
| GET |
/featured |
Public |
Top 8 popular listings |
| GET |
/{listing_id} |
Public |
Get listing (increments views) |
| GET |
/agency/mine |
Agency |
My agency's listings |
| POST |
/ |
Agency |
Create listing |
| PATCH |
/{listing_id} |
Owner/Admin |
Update listing |
| DELETE |
/{listing_id} |
Owner/Admin |
Delete listing |
| GET |
/admin/all |
Admin |
List all (any status) |
| PATCH |
/{listing_id}/status |
Admin |
Approve/reject |
| GET |
/stats/overview |
Required |
Listing statistics |
Messages (/api/v1/messages)
| Method |
Path |
Auth |
Description |
| POST |
/ |
Public |
Send contact message |
| GET |
/ |
Agency |
List my messages |
| GET |
/unread-count |
Agency |
Unread count |
| PATCH |
/{message_id}/read |
Agency |
Mark read/unread |
| DELETE |
/{message_id} |
Agency |
Delete message |
Favorites (/api/v1/favorites)
| Method |
Path |
Auth |
Description |
| POST |
/ |
Required |
Add to favorites |
| GET |
/ |
Required |
List my favorites |
| GET |
/check/{listing_id} |
Required |
Check if favorited |
| DELETE |
/{listing_id} |
Required |
Remove from favorites |
Uploads (/api/v1/uploads)
| Method |
Path |
Auth |
Description |
| POST |
/image |
Required |
Upload single image |
| POST |
/images |
Required |
Upload multiple images |
| DELETE |
/ |
Required |
Delete image by URL |
Health (/health)
| Method |
Path |
Auth |
Description |
| GET |
/health |
Public |
Health check |
Setup
1. Supabase Project
- Create a project at supabase.com
- Go to SQL Editor and run
migrations/001_initial_schema.sql
- Go to Storage and create a bucket called
listings with public access
- Copy your project URL, anon key, and service role key
2. Environment
3. Run Locally
With Docker:
Without Docker:
4. Seed Data
5. API Docs
Visit http://localhost:8000/docs (Swagger UI) in development mode.
Deployment
Railway / Render / Fly.io
- Push to a Git repository
- Connect the repo to your platform
- Set environment variables from
.env.example
- Deploy — the
Dockerfile handles everything
Production Checklist
Frontend Integration
The frontend should:
- Store tokens from
/auth/login response
- Send
Authorization: Bearer <access_token> on every authenticated request
- Use
/auth/refresh when the access token expires
- Replace all mock data imports with API calls to the endpoints above
Base URL pattern: ${API_BASE_URL}/api/v1/...