# shalloe99/taxai architecture

> Architecture diagram of the GitHub repository shalloe99/taxai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shalloe99/taxai
- Repository: https://github.com/shalloe99/taxai

## Overview

1. **Overall shape**
   - This repo is a Python backend for a tax-document processing workflow. The core path appears to be: uploaded/customer PDFs and form templates are ingested, text is extracted, document intent/type is classified, and data is stored or retrieved from local/vector and cloud-backed stores.
   - The backend is the main executable subsystem; the frontend is mentioned in the README but not present in this tree.

2. **HTTP/API boundary**
   - `backend/app.py` is the Flask entrypoint exposed on `localhost:5001`.
   - `backend/routes/routes.py` is the request-routing layer, likely defining the service endpoints used by the UI or API clients.
   - This boundary is where external callers enter the system before work is delegated into extraction, retrieval, or persistence modules.

3. **Domain orchestration**
   - `backend/modules.py` likely acts as a coordination layer tying together extraction, classification, storage, and service clients.
   - The repo structure suggests this is where document-processing use cases are assembled into end-to-end flows rather than isolated utilities.

4. **Document extraction pipeline**
   - `backend/retriever/data_extractor.py` is the main data-ingestion component for PDF content.
   - The README’s `poppler` dependency indicates PDF text/image extraction depends on native PDF tooling.
   - This subsystem bridges raw tax forms, instructions, and customer documents into machine-usable text or chunks.

5. **AI / retrieval subsystem**
   - `backend/crews/` contains notebooks, knowledge assets, and two local Chroma databases (`chroma_db`, `db`), which strongly indicates vector search and/or LLM-driven classification workflows.
   - The `intent_classification.ipynb` and `crew_playground.ipynb` notebooks suggest experimentation around document intent routing, probably feeding the production backend logic.
   - `backend/crews/knowledge/i8949.pdf` is a seed knowledge artifact used for retrieval or prompting.

6. **Local persistence for vectors/blobs**
   - `backend/database/blobs_db.py`, `files_db.py`, and `id_generator.py` define a storage abstraction for document identifiers, file/blob handling, and ID generation.
   - The embedded Chroma SQLite files under `backend/crews/` show that vector data is persisted locally for fast retrieval during development or single-node deployment.
   - This local store is a distinct boundary from cloud persistence and likely used for search/index state.

7. **Cloud integrations**
   - `backend/service_clients/aws_client.py` centralizes AWS connectivity.
   - `backend/database/s3/s3_bucket_store.py` suggests S3 is used for document/object storage.
   - `backend/database/dynamodb/dynamodb_store.py` suggests DynamoDB is used for structured metadata, status, or record indexing.
   - `backend/service_clients/mongo_db_client.py` indicates an optional or parallel MongoDB integration, likely for document metadata or application state.

8. **Data model and supported artifacts**
   - The `resource/` tree is the main corpus: IRS forms, instructions, schemas, tests, and a sample customer package.
   - Form families such as `1040`, `1099-*`, `ScheduleA/B/C/D/E`, and `w-2` indicate the app is designed around tax document intake and classification.
   - The `resource/data/schema/*.json` files imply schema-driven parsing or validation for at least some document types.

9. **Processing inputs and test fixtures**
   - `resource/first-customer/` contains realistic source documents grouped by life event/domain: wage, investment, property, school, and health.
   - `resource/data/tests/` and `resource/data/forms/` provide canonical inputs for validating extraction/classification behavior.
   - These assets are important for understanding the intended data flow: from mixed customer PDF bundles to normalized tax-document outputs.

10. **Deployment and runtime**
   - The backend is packaged for local Python execution, Docker image build, and docker-compose orchestration.
   - The README documents environment-based AWS credentials in `.env`, which means cloud connectivity is runtime-configured rather than hardcoded.
   - The architecture therefore supports both local development with embedded Chroma storage and containerized deployment with external AWS dependencies.

11. **Operational boundaries**
   - There is a clear split between:
     - API layer (`app.py`, `routes/`)
     - processing/orchestration (`modules.py`, `retriever/`)
     - storage adapters (`database/`, `service_clients/`)
     - knowledge/index assets (`crews/`)
     - raw/form data (`resource/`)
   - For an architecture diagram, these should be drawn as separate concerns with data flowing from request/API into extraction/classification, then into storage/search backends.

12. **Likely end-to-end flow**
   - A client submits or selects a tax PDF set.
   - The backend extracts document text and metadata.
   - The system classifies the document/intent and may retrieve supporting knowledge from Chroma-backed indexes.
   - Results and file references are persisted via S3/DynamoDB/Mongo abstractions, with local SQLite/Chroma used for vector state or development data.

Main entry points: [`backend/modules.py`](https://github.com/shalloe99/taxai/blob/main/backend/modules.py) (Modules), [`backend/retriever/data_extractor.py`](https://github.com/shalloe99/taxai/blob/main/backend/retriever/data_extractor.py) (Extractor), [`backend/crews/intent_classification.ipynb`](https://github.com/shalloe99/taxai/blob/main/backend/crews/intent_classification.ipynb) (Intent notebook), [`backend/service_clients/aws_client.py`](https://github.com/shalloe99/taxai/blob/main/backend/service_clients/aws_client.py) (AWS client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API layer"]
  node_app["App<br/>Flask entrypoint<br/>[app.py]"]
  node_routes["Routes<br/>[routes.py]"]
end

subgraph group_processing["Processing"]
  node_modules["Modules<br/>orchestrator<br/>[modules.py]"]
  node_extractor["Extractor<br/>PDF ingestion<br/>[data_extractor.py]"]
  node_intent_nb["Intent notebook<br/>classification notebook"]
  node_playground_nb["Playground<br/>exploration notebook"]
  node_chroma_dev[("Chroma index<br/>vector store<br/>[chroma.sqlite3]")]
  node_chroma_db[("Vector DB<br/>vector store<br/>[chroma.sqlite3]")]
  node_knowledge["Knowledge PDF<br/>seed document<br/>[i8949.pdf]"]
end

subgraph group_storage["Storage"]
  node_blobs_db["Blobs DB<br/>local storage<br/>[blobs_db.py]"]
  node_files_db["Files DB<br/>local storage<br/>[files_db.py]"]
  node_id_gen["ID generator<br/>identifier service<br/>[id_generator.py]"]
  node_aws_client["AWS client<br/>cloud client<br/>[aws_client.py]"]
  node_s3_store[("S3 store<br/>object store<br/>[s3_bucket_store.py]")]
  node_dynamo_store[("Dynamo store<br/>metadata store<br/>[dynamodb_store.py]")]
  node_mongo_client[("Mongo client<br/>document client<br/>[mongo_db_client.py]")]
end

subgraph group_assets["Assets"]
  node_forms["Form corpus<br/>tax forms"]
  node_schema["Schemas"]
  node_tests["Test fixtures<br/>sample inputs"]
  node_customer["Customer docs<br/>sample package"]
end

node_app -->|"dispatches"| node_routes
node_routes -->|"invokes"| node_modules
node_modules -->|"extracts"| node_extractor
node_modules -.->|"classifies"| node_intent_nb
node_modules -.->|"experiments"| node_playground_nb
node_modules -->|"stores"| node_blobs_db
node_modules -->|"indexes"| node_files_db
node_modules -->|"assigns ids"| node_id_gen
node_modules -->|"uses"| node_aws_client
node_aws_client -->|"connects"| node_s3_store
node_aws_client -->|"connects"| node_dynamo_store
node_modules -->|"uploads"| node_s3_store
node_modules -->|"persists"| node_dynamo_store
node_modules -.->|"optionally uses"| node_mongo_client
node_extractor -->|"reads"| node_forms
node_extractor -->|"validates"| node_schema
node_extractor -.->|"benchmarks"| node_tests
node_extractor -->|"processes"| node_customer
node_intent_nb -->|"queries"| node_chroma_dev
node_intent_nb -.->|"queries"| node_chroma_db
node_intent_nb -->|"retrieves"| node_knowledge
node_playground_nb -.->|"explores"| node_chroma_dev
node_modules -->|"searches"| node_chroma_dev

click node_app "https://github.com/shalloe99/taxai/blob/main/backend/app.py"
click node_routes "https://github.com/shalloe99/taxai/blob/main/backend/routes/routes.py"
click node_modules "https://github.com/shalloe99/taxai/blob/main/backend/modules.py"
click node_extractor "https://github.com/shalloe99/taxai/blob/main/backend/retriever/data_extractor.py"
click node_intent_nb "https://github.com/shalloe99/taxai/blob/main/backend/crews/intent_classification.ipynb"
click node_playground_nb "https://github.com/shalloe99/taxai/blob/main/backend/crews/crew_playground.ipynb"
click node_chroma_dev "https://github.com/shalloe99/taxai/blob/main/backend/crews/chroma_db/chroma.sqlite3"
click node_chroma_db "https://github.com/shalloe99/taxai/blob/main/backend/crews/db/chroma.sqlite3"
click node_knowledge "https://github.com/shalloe99/taxai/blob/main/backend/crews/knowledge/i8949.pdf"
click node_blobs_db "https://github.com/shalloe99/taxai/blob/main/backend/database/blobs_db.py"
click node_files_db "https://github.com/shalloe99/taxai/blob/main/backend/database/files_db.py"
click node_id_gen "https://github.com/shalloe99/taxai/blob/main/backend/database/id_generator.py"
click node_aws_client "https://github.com/shalloe99/taxai/blob/main/backend/service_clients/aws_client.py"
click node_s3_store "https://github.com/shalloe99/taxai/blob/main/backend/database/s3/s3_bucket_store.py"
click node_dynamo_store "https://github.com/shalloe99/taxai/blob/main/backend/database/dynamodb/dynamodb_store.py"
click node_mongo_client "https://github.com/shalloe99/taxai/blob/main/backend/service_clients/mongo_db_client.py"
click node_forms "https://github.com/shalloe99/taxai/tree/main/resource/data/forms"
click node_schema "https://github.com/shalloe99/taxai/tree/main/resource/data/schema"
click node_tests "https://github.com/shalloe99/taxai/tree/main/resource/data/tests"
click node_customer "https://github.com/shalloe99/taxai/tree/main/resource/first-customer"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_routes toneBlue
class node_modules,node_extractor,node_intent_nb,node_playground_nb,node_chroma_dev,node_chroma_db,node_knowledge toneAmber
class node_blobs_db,node_files_db,node_id_gen,node_aws_client,node_s3_store,node_dynamo_store,node_mongo_client toneMint
class node_forms,node_schema,node_tests,node_customer toneRose
```

## Components

### API layer

HTTP entrypoints and request routing

- [App](https://github.com/shalloe99/taxai/blob/main/backend/app.py): Flask entrypoint · Starts the backend server and exposes the HTTP surface · `backend/app.py`
- [Routes](https://github.com/shalloe99/taxai/blob/main/backend/routes/routes.py): API routes · Defines request handlers and endpoint wiring · `backend/routes/routes.py`

### Processing

Extraction, orchestration, and retrieval/classification

- [Modules](https://github.com/shalloe99/taxai/blob/main/backend/modules.py): orchestrator · Coordinates end-to-end document processing flows · `backend/modules.py`
- [Extractor](https://github.com/shalloe99/taxai/blob/main/backend/retriever/data_extractor.py): PDF ingestion · Extracts text and metadata from incoming documents · `backend/retriever/data_extractor.py`
- [Intent notebook](https://github.com/shalloe99/taxai/blob/main/backend/crews/intent_classification.ipynb): classification notebook · Experimental intent classification and routing logic · `backend/crews/intent_classification.ipynb`
- [Playground](https://github.com/shalloe99/taxai/blob/main/backend/crews/crew_playground.ipynb): exploration notebook · Interactive crew and retrieval experimentation · `backend/crews/crew_playground.ipynb`
- [Chroma index](https://github.com/shalloe99/taxai/blob/main/backend/crews/chroma_db/chroma.sqlite3): vector store · Local Chroma database used for retrieval and classification state · `backend/crews/chroma_db/chroma.sqlite3`
- [Vector DB](https://github.com/shalloe99/taxai/blob/main/backend/crews/db/chroma.sqlite3): vector store · Secondary local Chroma database backing notebook workflows · `backend/crews/db/chroma.sqlite3`
- [Knowledge PDF](https://github.com/shalloe99/taxai/blob/main/backend/crews/knowledge/i8949.pdf): seed document · Reference form used as retrieval knowledge · `backend/crews/knowledge/i8949.pdf`

### Storage

Local and cloud persistence adapters

- [Blobs DB](https://github.com/shalloe99/taxai/blob/main/backend/database/blobs_db.py): local storage · Stores blob or document payload references · `backend/database/blobs_db.py`
- [Files DB](https://github.com/shalloe99/taxai/blob/main/backend/database/files_db.py): local storage · Tracks file records and document metadata · `backend/database/files_db.py`
- [ID generator](https://github.com/shalloe99/taxai/blob/main/backend/database/id_generator.py): identifier service · Generates stable document or record identifiers · `backend/database/id_generator.py`
- [AWS client](https://github.com/shalloe99/taxai/blob/main/backend/service_clients/aws_client.py): cloud client · Central AWS connectivity and credential setup · `backend/service_clients/aws_client.py`
- [S3 store](https://github.com/shalloe99/taxai/blob/main/backend/database/s3/s3_bucket_store.py): object store · Persists documents and files in S3 · `backend/database/s3/s3_bucket_store.py`
- [Dynamo store](https://github.com/shalloe99/taxai/blob/main/backend/database/dynamodb/dynamodb_store.py): metadata store · Stores structured records and application state in DynamoDB · `backend/database/dynamodb/dynamodb_store.py`
- [Mongo client](https://github.com/shalloe99/taxai/blob/main/backend/service_clients/mongo_db_client.py): document client · Optional MongoDB integration for metadata or state · `backend/service_clients/mongo_db_client.py`

### Assets

Tax form corpora, schemas, and sample customer documents

- [Form corpus](https://github.com/shalloe99/taxai/tree/main/resource/data/forms): tax forms · Canonical IRS forms and instructions used for parsing and classification · `resource/data/forms`
- [Schemas](https://github.com/shalloe99/taxai/tree/main/resource/data/schema): validation schemas · JSON schemas for selected document types · `resource/data/schema`
- [Test fixtures](https://github.com/shalloe99/taxai/tree/main/resource/data/tests): sample inputs · Representative document sets for extraction and classification evaluation · `resource/data/tests`
- [Customer docs](https://github.com/shalloe99/taxai/tree/main/resource/first-customer): sample package · Realistic mixed customer tax-document bundle · `resource/first-customer`

## Connections

- App → Routes: dispatches · Flask app hands requests to routing layer
- Routes → Modules: invokes · Endpoints delegate work to orchestration layer
- Modules → Extractor: extracts · Processing flow starts by reading PDFs and document text
- Modules → Intent notebook: classifies · Orchestration likely uses intent routing logic developed in notebooks
- Modules → Playground: experiments · Notebook workflows inform or validate processing behavior
- Modules → Blobs DB: stores · Document payloads and references are persisted locally
- Modules → Files DB: indexes · File-level metadata is tracked for retrieval and state
- Modules → ID generator: assigns ids · Identifiers are generated before persistence
- Modules → AWS client: uses · Cloud adapters rely on shared AWS client setup
- AWS client → S3 store: connects · AWS connectivity supports object storage operations
- AWS client → Dynamo store: connects · AWS connectivity supports metadata persistence
- Modules → S3 store: uploads · Processed documents can be stored in S3
- Modules → Dynamo store: persists · Structured processing state is written to DynamoDB
- Modules → Mongo client: optionally uses · MongoDB is an alternate or parallel backend
- Extractor → Form corpus: reads · Extraction and classification operate on IRS form corpus
- Extractor → Schemas: validates · Structured output can be matched against schemas
- Extractor → Test fixtures: benchmarks · Test fixtures exercise extraction behavior
- Extractor → Customer docs: processes · Real customer document bundles are the main input shape
- Intent notebook → Chroma index: queries · Intent experiments use the local vector index
- Intent notebook → Vector DB: queries · Notebook workflows also reference a second local vector store
- Intent notebook → Knowledge PDF: retrieves · Reference documents provide retrieval context
- Playground → Chroma index: explores · Interactive retrieval and classification experiments
- Modules → Chroma index: searches · Production flow likely consults local retrieval state
