How khanh02-vin/ai-invoice-billing works
Invoice & Billing System provides a browser workflow for signing in, uploading or managing invoices, and viewing reports. The central backend path accepts an upload, extracts bilingual invoice fields (with OCR and optional LLM fallback), and persists user-scoped records in SQLite; users can then list or update invoices and obtain monthly reports. Separate capabilities include authentication hardening, organizations/RBAC, billing, vector search, PDF export, metrics, and file storage. Edges reflect README statements and shown imports/calls; several documented subsystem details were not sampled, so their internal links are omitted.
Main entry points: app.py FastAPI application · search.py Invoice search API · App.jsx React application · api.js API client
Components 24
Web client
- React application
frontend/src/App.jsx - Invoice dashboard
frontend/src/Invoices.jsx - API client
frontend/src/api.js
Invoice workflow
- FastAPI application
src/app.py - Upload validation
src/upload.py - Invoice extraction
src/extract/extractor.py - LLM fallback
src/llm/base.py - Invoice domain
src/domain/models.py - Invoice repository
src/store/repository.py - SQLite database
src/store/db.py - Original file storage
src/store/storage.py - PDF reports
src/reports/pdf_exporter.py
Identity and tenancy
- JWT security
src/auth/security.py - User repository
src/store/users.py - Auth hardening
src/routers/auth_ext.py - Organizations and RBAC
src/routers/orgs.py - Organization storage
src/store/orgs.py
Billing and platform
- Invoice search API
src/routers/search.py - Vector search
src/search/vector_store.py - Billing API
src/routers/billing.py - Payment provider
src/billing/provider.py - Billing repository
src/billing/repository.py - Prometheus metrics
src/observability/metrics.py
Other components
- Invoice user
Connections 24
- Invoice user → React application: uses
README.md - React application → Invoice dashboard: renders
frontend/src/App.jsx - Invoice dashboard → API client: calls
frontend/src/Invoices.jsx - React application → API client: checks session
frontend/src/App.jsx - API client → FastAPI application: HTTP requests
README.md - FastAPI application → JWT security: verifies tokens
src/app.py - FastAPI application → User repository: resolves user
src/app.py - FastAPI application → Upload validation: validates upload
src/app.py - FastAPI application → Invoice extraction: extracts fields
README.md - Invoice extraction → LLM fallback: fallback extraction
src/extract/extractor.py - FastAPI application → Invoice domain: validates records
src/app.py - FastAPI application → Invoice repository: stores and queries
src/app.py - Invoice repository → SQLite database: persists invoices
src/store/repository.py - FastAPI application → Original file storage: stores uploads
src/app.py - FastAPI application → PDF reports: exports reports
src/app.py - Auth hardening → JWT security: uses token helpers
src/routers/auth_ext.py - Auth hardening → User repository: updates credentials
src/routers/auth_ext.py - Organizations and RBAC → Organization storage: reads and writes
src/routers/orgs.py - Invoice search API → JWT security: verifies tokens
src/routers/search.py - Invoice search API → Invoice repository: loads invoices
src/routers/search.py - Invoice search API → Vector search: queries index
src/routers/search.py - Billing API → Payment provider: dispatches payments
src/routers/billing.py - Billing API → Billing repository: persists billing
src/routers/billing.py - FastAPI application → Prometheus metrics: serves metrics
src/app.py