mirror of
https://github.com/handsomezhuzhu/QQuiz.git
synced 2026-04-18 22:42:53 +00:00
2.3 KiB
2.3 KiB
Backend Findings
Critical Findings
Schema lifecycle is unsafe
- App startup still calls
create_all() - Alembic metadata exists but the migration chain is effectively empty
- This prevents controlled upgrades and rollbacks
Files:
backend/main.pybackend/database.pybackend/alembic/versions/.gitkeep
Parsing tasks are not durable
- Document ingestion runs inside FastAPI
BackgroundTasks - Progress state lives in-process only
- Process restarts or horizontal scaling can strand exams in
pendingorprocessing
Files:
backend/routers/exam.pybackend/services/progress_service.py
Transaction boundaries are inconsistent
get_db()performs commit/rollback automatically- Routers and background tasks also call
commit()directly - SSE endpoints keep a database dependency open for long-lived streams
Files:
backend/database.pybackend/routers/exam.py
High-Priority Bugs
Admin config can destroy secrets
GET /api/admin/configmasks API keysPUT /api/admin/configpersists whatever the frontend sends back- A round-trip save can replace the real secret with the masked placeholder
Files:
backend/routers/admin.py
LLM service has import-time side effects
LLMService()is instantiated at module import time- Missing environment variables can break startup before DB-backed config is loaded
Files:
backend/services/llm_service.py
Ingestion deduplication is race-prone
- No unique DB constraint on
(exam_id, content_hash) - Multiple append operations can race and insert duplicates
Files:
backend/models.pybackend/routers/exam.py
Answer checking degrades incorrectly on infra failure
- Short-answer grading failures are converted into zero scores
- User mistake data can be polluted by provider outages or config errors
Files:
backend/services/llm_service.pybackend/routers/question.py
Refactor Order
- Replace runtime schema creation with Alembic-first migrations.
- Move ingestion, config, and answer checking into service classes.
- Introduce explicit transaction boundaries and idempotent ingestion rules.
- Add durable task execution and real status/error semantics.
- Add integration tests for config round-trips, ingestion races, and answer normalization.