How sushant-kae/invoice-generator works
Shah Enterprises is an import/export invoice generator. Its principal workflow uploads a manufacturer invoice, extracts and normalizes line items (with OCR/manual fallback), applies internal margins, lets staff review and preview the customer-safe invoice, then saves and generates DOCX/PDF output. Separate product areas cover invoice history/dashboard, buyers, templates, and internal profit reporting. The README documents the frontend workflow; source evidence is strongest for backend routing and extraction, while unsampled frontend API wiring is not asserted.
Main entry points: invoices.py Invoice operations · pipeline.py Extraction orchestrator · extract.py Extract and margin API · models.py Invoice and buyer models
Components 26
Invoice Workspace
- Invoice workflow
frontend/src/app/new-invoice/page.tsx - Upload step
frontend/src/components/invoice/UploadStep.tsx - Review step
frontend/src/components/invoice/ReviewStep.tsx - Customer preview
frontend/src/components/invoice/PreviewStep.tsx - Export completion
frontend/src/components/invoice/DoneStep.tsx - Dashboard and profit
frontend/src/app/page.tsx - Invoice history
frontend/src/app/history/page.tsx - Buyer directory
frontend/src/app/buyers/page.tsx - Template management
frontend/src/app/templates/page.tsx - Profit overview
frontend/src/app/profit/page.tsx
API and Business Operations
- Upload endpoint
backend/app/api/routes/upload.py - Extract and margin API
backend/app/api/routes/extract.py - Invoice operations
backend/app/api/routes/invoices.py - Buyer operations
backend/app/api/routes/buyers.py - Template listing
backend/app/api/routes/templates.py
Invoice Extraction
- Extraction orchestrator
backend/app/services/extraction/pipeline.py - PDF extraction
backend/app/services/extraction/pdf_extractor.py - OCR fallback
backend/app/services/extraction/ocr_extractor.py - Column normalizer
backend/app/services/extraction/normalizer.py
Invoice Domain and Storage
- Margin and tax engine
backend/app/services/margin_calculator.py - API data schemas
backend/app/schemas/schemas.py - Invoice and buyer models
backend/app/models/models.py - SQL database
backend/app/db/database.py
Invoice Export
- DOCX generator
backend/app/services/docx/generator.py - PDF converter
backend/app/services/pdf/converter.py
Other components
- Staff user
Connections 32
- Staff user → Invoice workflow: creates invoice
README.md - Invoice workflow → Upload step: starts with
README.md - Upload step → Upload endpoint: uploads file
README.md - Upload endpoint → Extract and margin API: continues extraction
README.md - Extract and margin API → Extraction orchestrator: runs extraction
backend/app/api/routes/extract.py - Extraction orchestrator → PDF extraction: tries PDF parsing
backend/app/services/extraction/pipeline.py - Extraction orchestrator → OCR fallback: falls back to OCR
backend/app/services/extraction/pipeline.py - PDF extraction → Column normalizer: normalizes columns
backend/app/services/extraction/pdf_extractor.py - OCR fallback → Column normalizer: normalizes output
backend/app/services/extraction/ocr_extractor.py - Extraction orchestrator → Review step: returns editable items
README.md - Review step → Extract and margin API: applies margin
README.md - Extract and margin API → Margin and tax engine: calculates margins
backend/app/api/routes/extract.py - Margin and tax engine → API data schemas: uses item schemas
backend/app/services/margin_calculator.py - Review step → Customer preview: previews invoice
README.md - Customer preview → Invoice operations: saves invoice
README.md - Invoice operations → Invoice and buyer models: queries and persists
backend/app/api/routes/invoices.py - Invoice and buyer models → SQL database: uses ORM base
backend/app/models/models.py - Invoice operations → API data schemas: validates responses
backend/app/api/routes/invoices.py - Invoice operations → Margin and tax engine: calculates invoice totals
backend/app/api/routes/invoices.py - Invoice operations → DOCX generator: generates DOCX
backend/app/api/routes/invoices.py - Invoice operations → PDF converter: converts to PDF
backend/app/api/routes/invoices.py - DOCX generator → API data schemas: reads invoice data
backend/app/services/docx/generator.py - Export completion → Invoice operations: requests export
README.md - Staff user → Dashboard and profit: views metrics
README.md - Staff user → Invoice history: reviews invoices
README.md - Staff user → Buyer directory: manages buyers
README.md - Buyer directory → Buyer operations: uses buyer records
- Buyer operations → Invoice and buyer models: queries buyers
backend/app/api/routes/buyers.py - Staff user → Template management: manages templates
README.md - Template management → Template listing: lists templates
- Template listing → Invoice and buyer models: queries templates
backend/app/api/routes/templates.py - Staff user → Profit overview: views internal profit
README.md