Architecture¶
skynet-app-api is a single FastAPI application assembled in
src/skynet_api/main.py. Configuration loads at import time from
config/cfg.py (AWS secrets via fs_config).
Application structure¶
src/skynet_api/
main.py # App factory, middleware, uvicorn entry
config/cfg.py # ENVIRONMENT-driven secret loader
authentication/ # JWT login, refresh, password reset
datastore/ # MySQL + Redis connectors
middlewares/ # Per-user rate limiting
app/ # Scheduler, OpenAPI tag metadata
*/routes.py # Feature routers (see API modules page)
health/ # GET /api/status
Router mount map¶
All feature routers attach under /api on the main app:
| Router module | Domain |
|---|---|
authentication |
Login, refresh, /auth/me |
health |
/status |
campaign_actions |
Campaign duplicate, audience, job status |
creative_actions |
Creative bulk actions |
creative_set_actions |
Creative set CRUD, upload, scheduling |
target_versions_actions |
Target version CRUD |
content_catalog_actions |
Content catalog |
site_actions |
Site reports, publish, WP keys |
custom_campaigns |
Custom campaigns + Excel import |
suggestion |
Campaign suggestions |
reports |
Report metadata and execution |
automations |
Automation info and run |
cloudflare |
Zone settings (admin) |
commands |
Internal commands, SMS, homepage batch enqueue |
droplets_manager |
DO/CF workers, snapshots, SSH, cache purge |
ad_manager |
Ad manager proxy reports |
redis_management |
Admin Redis key read/delete |
status_page |
Status page worker refresh |
management |
Users, accounts, alerts, proxy toggles |
A second FastAPI sub-app mounts management at /management (same
router, separate OpenAPI surface).
Middleware stack¶
- Rate limiting —
limit_usermiddleware (middlewares/limitation.py) - CORS —
allow_origins=["*"] - GZip — responses above ~10 MB
Lifecycle¶
main.py registers startup/shutdown hooks that connect Redis and run the
settings scheduler (app/application.py), syncing DB-backed configuration on
boot.
Sync vs async¶
Routes mix sync and async handlers. MySQL access uses databases / aiomysql
patterns established per module. FastAPI runs blocking handlers in a threadpool.
Configuration¶
See Configuration & secrets. Secrets never appear in source;
cfg.py resolves them once at import based on ENVIRONMENT.