How suryansh935/account-anomaly-detection works
This is a FastAPI backend for uploading and processing CSV files containing account records, then exposing imported accounts, anomalies, file status, and dashboard data. The main workflow is upload to disk, detect/register the CSV and enqueue a job, process rows into valid accounts and anomalies, and persist the results. Startup also recovers pending jobs and launches workers and the file watcher. The excerpts establish the main orchestration and persistence calls; some route and processing details are represented by the source index, so uncertain links are omitted.
Main entry points: main.py App Lifecycle · worker.py Job Workers · dashboard.py Dashboard API · file_watcher.py CSV Watcher
Components 19
HTTP API
- App Lifecycle
backend/app/main.py - File API
backend/app/routes/files.py - Accounts API
backend/app/routes/accounts.py - Anomalies API
backend/app/routes/anomalies.py - Dashboard API
backend/app/routes/dashboard.py
File Intake
- Upload Storage
backend/app/services/file_service.py - CSV Watcher
backend/app/services/file_watcher.py
CSV Processing
- Task Queue
backend/app/workers/queue.py - Job Workers
backend/app/workers/worker.py - CSV Processor
backend/app/services/csv_processor.py - Header Mapper
backend/app/services/header_mapper.py
Persistence
- DB Sessions
backend/app/database/session.py - DB Connection
backend/app/database/connection.py - MySQL Database
- Account Records
backend/app/models/account.py - Anomaly Records
backend/app/models/anomaly.py - Uploaded File Records
backend/app/models/uploaded_file.py - Processing Job Records
backend/app/models/processing_job.py
Other components
- API Client
Connections 26
- API Client → App Lifecycle: sends requests
- App Lifecycle → File API: registers routes
backend/app/main.py - App Lifecycle → Accounts API: registers routes
backend/app/main.py - App Lifecycle → Anomalies API: registers routes
backend/app/main.py - App Lifecycle → Dashboard API: registers routes
backend/app/main.py - App Lifecycle → CSV Watcher: starts watcher
backend/app/main.py - App Lifecycle → Job Workers: starts workers
backend/app/main.py - File API → Upload Storage: saves upload
backend/app/routes/files.py - File API → Uploaded File Records: queries files
backend/app/routes/files.py - CSV Watcher → Uploaded File Records: registers files
backend/app/services/file_watcher.py - CSV Watcher → Processing Job Records: creates jobs
backend/app/services/file_watcher.py - CSV Watcher → Task Queue: enqueues jobs
backend/app/services/file_watcher.py - Job Workers → Task Queue: takes jobs
backend/app/workers/worker.py - Job Workers → CSV Processor: processes CSV
backend/app/workers/worker.py - CSV Processor → Header Mapper: maps headers
backend/app/services/csv_processor.py - Job Workers → Account Records: writes accounts
backend/app/workers/worker.py - Job Workers → Anomaly Records: writes anomalies
backend/app/workers/worker.py - Job Workers → Uploaded File Records: updates file status
backend/app/workers/worker.py - Job Workers → Processing Job Records: updates job status
backend/app/workers/worker.py - DB Sessions → DB Connection: creates sessions
backend/app/database/session.py - DB Connection → MySQL Database: connects to
- Accounts API → Account Records: queries accounts
backend/app/routes/accounts.py - Anomalies API → Anomaly Records: queries anomalies
backend/app/routes/anomalies.py - Dashboard API → Account Records: reads accounts
backend/app/routes/dashboard.py - Dashboard API → Uploaded File Records: reads files
backend/app/routes/dashboard.py - Dashboard API → Anomaly Records: reads anomalies
backend/app/routes/dashboard.py