How insistence/dash-fastapi-admin works
Project Type and Purpose
• This is a full‑stack, front‑end/back‑end‑separated Python rapid‑development admin platform (“Dash‑FastAPI‑Admin”).
• Frontend uses Dash + feffery‑antd‑components; backend uses FastAPI + SQLAlchemy + MySQL/PostgreSQL + Redis + OAuth2/JWT.
High‑Level Architecture Components
a. Client (Browser)
b. Frontend Server (Dash Application)
c. Backend Server (FastAPI Application)
d. Data Store (MySQL or PostgreSQL)
e. Cache / Message Broker (Redis)
f. Scheduler (APScheduler or similar)
g. External Proxy / Load Balancer (e.g., Nginx)
Component Relationships & Data Flow
• Browser sends HTTP/WebSocket requests to the Dash frontend over port (e.g., 8088).
• Dash handles routing, renders React‑style UI components, and triggers Python callbacks.
• Dash callbacks that need data invoke REST API calls (via fetch or internal router) to FastAPI on port (e.g., 9099).
• FastAPI exposes endpoints in “module_admin” and “module_task” controllers.
• Controllers → call Services → call DAOs → interact with database.
• FastAPI uses OAuth2/JWT for authentication; tokens stored/checked against Redis.
• Services may cache or rate‑limit using Redis (get_redis).
• Scheduled tasks in module_task/scheduler_test use the same database + Redis via the scheduler component.
• All long‑running or background jobs are managed by the scheduler service.
• Database holds persistent entities (DO: data objects, VO: view objects).
• Redis holds session tokens, rate‑limit data, scheduler metadata.
• Nginx or similar proxies incoming traffic, routes “/prod-api” to FastAPI and “/” to Dash.
Architectural Patterns & Design Principles
• Layered (Controller → Service → DAO → Database)
• Modular (“module_admin”, “module_task”, “sub_applications”)
• Dependency injection for DB, Redis, Scheduler via get_db, get_redis, get_scheduler
• Aspect‑oriented hooks (data_scope, interface_auth)
• Middleware pipeline (CORS, GZip, error handling)
• Clear separation of concerns: config, exceptions, utils.
Technologies & Frameworks to Call Out
• Dash, feffery‑antd‑components, feffery‑utils‑components
• FastAPI, SQLAlchemy ORM
• MySQL / PostgreSQL (config/database.py)
• Redis (config/get_redis.py)
• OAuth2 & JWT (module_admin/aspect/interface_auth.py)
• APScheduler or built‑in scheduler (config/get_scheduler.py)
• Nginx proxy (README nginx snippet)