mirror of
https://github.com/handsomezhuzhu/QQuiz.git
synced 2026-04-18 14:32:54 +00:00
2.3 KiB
2.3 KiB
QQuiz Architecture Audit
Scope
This document records the current system shape and the approved target direction for the ongoing refactor.
Audit date: 2026-04-17
Current Architecture
Backend
- Runtime: FastAPI + SQLAlchemy async
- Database access: direct ORM session injection per request
- Task execution: in-process
BackgroundTasks - Progress streaming: in-memory
ProgressService - Schema management: mixed
create_all()and Alembic placeholders
Frontend
- Runtime: React 18 + Vite SPA
- Routing:
react-router-dom - Auth state: client-only
localStoragetoken + context - API transport: axios interceptor with browser redirects
- Styling: Tailwind CSS with page-local utility classes
Deployment
docker-compose.yml: development-oriented split stackdocker-compose-single.yml: monolith container with SQLiteDockerfile: FastAPI serves the built SPA as static assets
Target Architecture
Backend
- Keep FastAPI as the system API boundary
- Move heavy router logic into typed services
- Use Alembic as the only schema migration path
- Introduce durable ingestion execution semantics
- Replace implicit transaction patterns with explicit service-level boundaries
Frontend
- New app in
web/ - Stack: Next.js App Router + TypeScript + Tailwind + shadcn/ui
- Auth:
HttpOnlysession cookie mediated by Next route handlers - Data fetching:
fetchwrappers for server/client usage - Streaming: Next proxy route for exam progress SSE
Deployment
- Split deployment becomes the primary production shape
- Monolith mode remains secondary compatibility mode
- Development and production Compose files must be separated
Core Constraints
- Do not overwrite existing uncommitted user changes in the legacy frontend.
- Keep the legacy
frontend/app available until the newweb/app reaches functional parity. - Preserve backend API contracts where possible during the frontend migration.
- Fix deployment/documentation drift before treating new frontend work as production-ready.
Immediate Workstreams
- Remove abandoned ESA captcha wiring from the legacy frontend.
- Write audit documents and freeze the migration backlog.
- Scaffold the new
web/frontend without disturbing the legacy app. - Fix first-order deployment issues such as health checks and documented mount paths.