How heykvr/dental-client-management-backend works
This is a FastAPI backend for dental-clinic patient and case-sheet management. Clinic staff use its REST API to create, find, and update patients; record clinical case sheets; view dashboard metrics; request grounded, stateless AI chat; and receive AI summaries that refresh after changes. The documented architecture is routes → services → repositories. The graph includes validation, persistence, Gemini, and the background-summary capability. Some route and service implementations were not excerpted, so their edges rely on the SOURCE INDEX or README where available.
Main entry points: deps.py Dependency wiring · chat_service.py Patient-grounded chat · v1 REST routes · case_sheet_repo.py Case-sheet repository
Components 22
API and validation
- REST routes
app/api/v1 - Dependency wiring
app/api/deps.py - Patient validation
app/schemas/patient.py - Case-sheet validation
app/schemas/case_sheet.py
Clinic workflows
- Patient workflow
app/services/patient_service.py - Case-sheet workflow
app/services/case_sheet_service.py - Dashboard metrics
app/services/dashboard_service.py
Persistence
- Patient repository
app/repositories/patient_repo.py - Case-sheet repository
app/repositories/case_sheet_repo.py - ID counter
app/repositories/counter_repo.py
AI features
- Summary generation
app/services/summary_service.py - Patient-grounded chat
app/services/chat_service.py - AI client
app/services/ai_service.py - Summary instructions
app/prompts/summary.txt - Chat instructions
app/prompts/chat_system.txt
Runtime foundations
- Application startup
app/main.py - Database connection
app/core/database.py - Request rate limits
app/core/rate_limit.py - Error responses
app/core/exceptions.py
Other components
- Clinic staff
- MongoDB
- Google Gemini
Connections 30
- Clinic staff → REST routes: sends requests
README.md - REST routes → Dependency wiring: resolves services
app/api/v1/patients.py - Dependency wiring → Patient workflow: constructs
app/api/deps.py - Dependency wiring → Case-sheet workflow: constructs
app/api/deps.py - Dependency wiring → Dashboard metrics: constructs
app/api/deps.py - Dependency wiring → Summary generation: constructs
app/api/deps.py - Dependency wiring → Patient-grounded chat: constructs
app/api/deps.py - REST routes → Patient validation: validates patient data
app/api/v1/patients.py - REST routes → Case-sheet validation: validates case data
app/api/v1/case_sheets.py - Patient workflow → Patient repository: reads and writes
app/services/patient_service.py - Patient workflow → ID counter: allocates IDs
app/services/patient_service.py - Case-sheet workflow → Case-sheet repository: reads and saves
app/services/case_sheet_service.py - Dashboard metrics → Patient repository: aggregates patients
app/services/dashboard_service.py - Dashboard metrics → Case-sheet repository: counts statuses
app/services/dashboard_service.py - Summary generation → Case-sheet repository: loads and saves summary
app/services/summary_service.py - Summary generation → AI client: generates summary
app/services/summary_service.py - Summary generation → Summary instructions: loads instructions
app/services/summary_service.py - Patient-grounded chat → AI client: requests response
app/services/chat_service.py - Patient-grounded chat → Case-sheet workflow: uses case workflow
app/services/chat_service.py - Patient-grounded chat → Patient workflow: uses patient workflow
app/services/chat_service.py - Patient-grounded chat → Case-sheet repository: loads clinical record
app/services/chat_service.py - Patient-grounded chat → Chat instructions: uses instructions
- AI client → Google Gemini: calls provider
app/services/ai_service.py - Patient repository → MongoDB: queries patients
app/repositories/patient_repo.py - Case-sheet repository → MongoDB: queries embedded sheets
app/repositories/case_sheet_repo.py - ID counter → MongoDB: allocates sequence
README.md - Application startup → REST routes: mounts router
app/main.py - Application startup → Database connection: initializes database
app/main.py - REST routes → Request rate limits: applies limits
app/api/v1/chat.py - Application startup → Error responses: registers handlers
app/main.py