# damilaresanni/consumerduty architecture

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

- Interactive diagram: https://gitdiagram.com/damilaresanni/consumerduty
- Repository: https://github.com/damilaresanni/consumerduty

## Overview

#### Purpose and Runtime

This is a Django-based Consumer Duty governance and document-monitoring system. It manages products, uploaded regulatory/business documents, compliance review findings, and user-facing dashboards. Django provides HTTP, admin, ORM, templates, and WSGI/ASGI deployment; Celery is configured for background processing.

Entry points: `manage.py`, `consumerduty/urls.py`, `consumerduty/asgi.py`, `consumerduty/wsgi.py`, and `consumerduty/celery.py`.

#### Django Project Composition

`consumerduty` is the project boundary: settings, URL composition, synchronous/asynchronous server interfaces, and Celery integration are centralized in `consumerduty/settings.py`, `consumerduty/urls.py`, and `consumerduty/celery.py`.

Feature ownership is split into Django apps:
- Product management: `product/models.py`, `product/views.py`, `product/urls.py`
- Governance records: `governance/models.py`, `governance/views.py`
- Monitoring, ingestion, analysis, and APIs: `monitoring/models.py`, `monitoring/views.py`, `monitoring/urls.py`
- User/account behavior: `user/models.py`, `user/views.py`, `user/forms.py`

#### Product and Governance Domain

The `product` app owns product entities and their lifecycle/UI endpoints. Its migrations show an evolving domain model including product descriptions and type/sophistication-related fields: `product/models.py`, `product/migrations/0002_product_description_and_more.py`, `product/migrations/0004_alter_product_product_type.py`.

The `governance` app provides the separate governance domain and Django-admin integration, likely for formal Consumer Duty oversight records rather than raw document processing: `governance/models.py`, `governance/admin.py`, `governance/views.py`.

#### Document Ingestion and Persistent Review State

Monitoring is the core workflow. Its migrations establish persistent document, document-chunk, Consumer Duty review, and rule-based finding concepts: `monitoring/models.py`, `monitoring/migrations/0001_initial.py`, `monitoring/migrations/0004_documentchunk_rulebasedfinding.py`.

Uploaded source files are stored beneath `uploads/`, with examples of PDFs organized by date. The expected control flow is: browser upload → monitoring view/form → document persistence → background or direct extraction/chunking → findings and review records. Relevant boundaries are `monitoring/forms.py`, `monitoring/views.py`, `monitoring/tasks.py`, and `uploads/`.

#### Analysis, Retrieval, and AI Boundary

The monitoring app contains distinct modules for NLP, retrieval-augmented generation, vector indexing, and question/query handling: `monitoring/nlp.py`, `monitoring/rag.py`, `monitoring/vector_store.py`, `monitoring/qd.py`.

These modules form the intelligence boundary: document chunks and metadata from Django persistence are transformed/indexed, retrieved for a query, and used to produce analysis or compliance-oriented answers/findings. `monitoring/ee.py` and `monitoring/utils.py` appear to support this analysis layer. Evaluation artifacts and code indicate that output quality is assessed separately from the serving workflow: `monitoring/eval/eval.py`, `monitoring/eval/summary_stats.py`, `evals/`.

#### HTTP, UI, and API Surfaces

Server-rendered pages are implemented through Django views and templates, including dashboards, documents, product management, and upload flows: `templates/dashboard.html`, `templates/documents.html`, `templates/uploadDocument.html`.

Monitoring additionally exposes a programmatic API and serialization boundary via `monitoring/api.py` and `monitoring/serializers.py`. Client-side document-status polling/updates and RAG querying are represented by `static/js/document_status.js` and `static/js/rag_query.js`.

#### Infrastructure and External Dependencies

Material runtime infrastructure is Django plus Celery; a `dump.rdb` file strongly suggests Redis is or was used, likely as Celery broker/result storage or application caching. File-based upload storage is present locally under `uploads/`. The vector-store and RAG modules imply an embedding/vector-search dependency, but the exact provider is not available from the supplied tree. Django migrations define the relational database schema across `monitoring`, `product`, `governance`, and `user`.

Main entry points: [`monitoring/views.py`](https://github.com/damilaresanni/consumerduty/blob/main/monitoring/views.py) (Monitoring HTTP flow), [`monitoring/models.py`](https://github.com/damilaresanni/consumerduty/blob/main/monitoring/models.py) (Documents and reviews), [`consumerduty/urls.py`](https://github.com/damilaresanni/consumerduty/blob/main/consumerduty/urls.py) (Project composition), [`monitoring/tasks.py`](https://github.com/damilaresanni/consumerduty/blob/main/monitoring/tasks.py) (Document processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Django Runtime"]
  node_entrypoints{{"Server entry points<br/>Django entry<br/>[manage.py]"}}
  node_project["Project composition<br/>Django project<br/>[urls.py]"]
  node_celery["Background workers<br/>Celery<br/>[celery.py]"]
end

subgraph group_domains["Domain Apps"]
  node_product["Product management<br/>Django app<br/>[models.py]"]
  node_governance["Governance records<br/>Django app<br/>[models.py]"]
  node_accounts["User accounts<br/>Django app<br/>[models.py]"]
end

subgraph group_monitoring["Monitoring Workflow"]
  node_monitoring_views["Monitoring HTTP flow<br/>Django views<br/>[views.py]"]
  node_monitoring_api["Monitoring API<br/>API and serializers<br/>[api.py]"]
  node_upload_storage["Uploaded files<br/>file storage"]
  node_review_data[("Documents and reviews<br/>Django models<br/>[models.py]")]
  node_processing_tasks["Document processing<br/>Celery tasks<br/>[tasks.py]"]
end

subgraph group_intelligence["Analysis &amp; Retrieval"]
  node_nlp["NLP extraction<br/>analysis module<br/>[nlp.py]"]
  node_vector_store[("Vector index<br/>vector search<br/>[vector_store.py]")]
  node_rag["RAG analysis<br/>retrieval workflow<br/>[rag.py]"]
  node_query_handler["Query handling<br/>query module<br/>[qd.py]"]
end

node_ui_templates["Dashboards and upload UI<br/>Django templates<br/>[dashboard.html]"]
node_browser_js["Document and RAG clients<br/>browser JavaScript<br/>[rag_query.js]"]
node_relational_db[("Relational database<br/>Django ORM database<br/>[0001_initial.py]")]
node_redis[("Redis broker/cache<br/>[dump.rdb]")]

node_entrypoints -->|"boots"| node_project
node_project -->|"routes requests"| node_monitoring_views
node_project -->|"routes product UI"| node_product
node_project -->|"routes account UI"| node_accounts
node_monitoring_views -->|"renders"| node_ui_templates
node_browser_js -->|"calls"| node_monitoring_api
node_monitoring_views -->|"stores uploads"| node_upload_storage
node_monitoring_views -->|"creates documents"| node_review_data
node_monitoring_views -->|"queues processing"| node_processing_tasks
node_celery -->|"runs"| node_processing_tasks
node_celery -.->|"uses"| node_redis
node_processing_tasks -->|"reads source files"| node_upload_storage
node_processing_tasks -->|"extracts and chunks"| node_nlp
node_nlp -->|"persists chunks/findings"| node_review_data
node_review_data -->|"supplies chunks"| node_vector_store
node_nlp -->|"indexes embeddings"| node_vector_store
node_monitoring_api -->|"submits queries"| node_query_handler
node_query_handler -->|"requests analysis"| node_rag
node_rag -->|"retrieves context"| node_vector_store
node_rag -->|"stores review output"| node_review_data
node_product -->|"persists products"| node_relational_db
node_governance -->|"persists records"| node_relational_db
node_accounts -->|"persists users"| node_relational_db
node_review_data -->|"persists monitoring state"| node_relational_db

click node_entrypoints "https://github.com/damilaresanni/consumerduty/blob/main/manage.py"
click node_project "https://github.com/damilaresanni/consumerduty/blob/main/consumerduty/urls.py"
click node_celery "https://github.com/damilaresanni/consumerduty/blob/main/consumerduty/celery.py"
click node_product "https://github.com/damilaresanni/consumerduty/blob/main/product/models.py"
click node_governance "https://github.com/damilaresanni/consumerduty/blob/main/governance/models.py"
click node_accounts "https://github.com/damilaresanni/consumerduty/blob/main/user/models.py"
click node_monitoring_views "https://github.com/damilaresanni/consumerduty/blob/main/monitoring/views.py"
click node_monitoring_api "https://github.com/damilaresanni/consumerduty/blob/main/monitoring/api.py"
click node_review_data "https://github.com/damilaresanni/consumerduty/blob/main/monitoring/models.py"
click node_processing_tasks "https://github.com/damilaresanni/consumerduty/blob/main/monitoring/tasks.py"
click node_nlp "https://github.com/damilaresanni/consumerduty/blob/main/monitoring/nlp.py"
click node_vector_store "https://github.com/damilaresanni/consumerduty/blob/main/monitoring/vector_store.py"
click node_rag "https://github.com/damilaresanni/consumerduty/blob/main/monitoring/rag.py"
click node_query_handler "https://github.com/damilaresanni/consumerduty/blob/main/monitoring/qd.py"
click node_ui_templates "https://github.com/damilaresanni/consumerduty/blob/main/templates/dashboard.html"
click node_browser_js "https://github.com/damilaresanni/consumerduty/blob/main/static/js/rag_query.js"
click node_relational_db "https://github.com/damilaresanni/consumerduty/blob/main/monitoring/migrations/0001_initial.py"
click node_redis "https://github.com/damilaresanni/consumerduty/blob/main/dump.rdb"

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_entrypoints,node_project,node_celery toneBlue
class node_product,node_governance,node_accounts toneAmber
class node_monitoring_views,node_monitoring_api,node_upload_storage,node_review_data,node_processing_tasks toneMint
class node_nlp,node_vector_store,node_rag,node_query_handler toneRose
class node_ui_templates,node_browser_js,node_relational_db,node_redis toneNeutral
```

## Components

### Django Runtime

- [Server entry points](https://github.com/damilaresanni/consumerduty/blob/main/manage.py): Django entry · CLI plus WSGI and ASGI deployment entry points. · `manage.py`
- [Project composition](https://github.com/damilaresanni/consumerduty/blob/main/consumerduty/urls.py): Django project · Central settings, URL composition, and Celery integration. · `consumerduty/urls.py`
- [Background workers](https://github.com/damilaresanni/consumerduty/blob/main/consumerduty/celery.py): Celery · `consumerduty/celery.py`

### Domain Apps

- [Product management](https://github.com/damilaresanni/consumerduty/blob/main/product/models.py): Django app · Owns product lifecycle and product UI. · `product/models.py`
- [Governance records](https://github.com/damilaresanni/consumerduty/blob/main/governance/models.py): Django app · Owns formal Consumer Duty oversight records. · `governance/models.py`
- [User accounts](https://github.com/damilaresanni/consumerduty/blob/main/user/models.py): Django app · `user/models.py`

### Monitoring Workflow

- [Monitoring HTTP flow](https://github.com/damilaresanni/consumerduty/blob/main/monitoring/views.py): Django views · Handles document and monitoring requests. · `monitoring/views.py`
- [Monitoring API](https://github.com/damilaresanni/consumerduty/blob/main/monitoring/api.py): API and serializers · Programmatic monitoring and query boundary. · `monitoring/api.py`
- **Uploaded files**: file storage
- [Documents and reviews](https://github.com/damilaresanni/consumerduty/blob/main/monitoring/models.py): Django models · Persists documents, chunks, reviews, and rule-based findings. · `monitoring/models.py`
- [Document processing](https://github.com/damilaresanni/consumerduty/blob/main/monitoring/tasks.py): Celery tasks · Extracts and chunks uploaded documents. · `monitoring/tasks.py`

### Analysis & Retrieval

- [NLP extraction](https://github.com/damilaresanni/consumerduty/blob/main/monitoring/nlp.py): analysis module · `monitoring/nlp.py`
- [Vector index](https://github.com/damilaresanni/consumerduty/blob/main/monitoring/vector_store.py): vector search · Indexes document chunks for semantic retrieval. · `monitoring/vector_store.py`
- [RAG analysis](https://github.com/damilaresanni/consumerduty/blob/main/monitoring/rag.py): retrieval workflow · Retrieves indexed context for compliance answers and findings. · `monitoring/rag.py`
- [Query handling](https://github.com/damilaresanni/consumerduty/blob/main/monitoring/qd.py): query module · `monitoring/qd.py`

### Other components

- [Dashboards and upload UI](https://github.com/damilaresanni/consumerduty/blob/main/templates/dashboard.html): Django templates · `templates/dashboard.html`
- [Document and RAG clients](https://github.com/damilaresanni/consumerduty/blob/main/static/js/rag_query.js): browser JavaScript · Polls document status and submits RAG queries. · `static/js/rag_query.js`
- [Relational database](https://github.com/damilaresanni/consumerduty/blob/main/monitoring/migrations/0001_initial.py): Django ORM database · Schema is defined by migrations across all apps. · `monitoring/migrations/0001_initial.py`
- [Redis broker/cache](https://github.com/damilaresanni/consumerduty/blob/main/dump.rdb): Redis · Likely Celery broker, results, or cache. · `dump.rdb`

## Connections

- Server entry points → Project composition: boots
- Project composition → Monitoring HTTP flow: routes requests
- Project composition → Product management: routes product UI
- Project composition → User accounts: routes account UI
- Monitoring HTTP flow → Dashboards and upload UI: renders
- Document and RAG clients → Monitoring API: calls
- Monitoring HTTP flow → Uploaded files: stores uploads
- Monitoring HTTP flow → Documents and reviews: creates documents
- Monitoring HTTP flow → Document processing: queues processing
- Background workers → Document processing: runs
- Background workers → Redis broker/cache: uses
- Document processing → Uploaded files: reads source files
- Document processing → NLP extraction: extracts and chunks
- NLP extraction → Documents and reviews: persists chunks/findings
- Documents and reviews → Vector index: supplies chunks
- NLP extraction → Vector index: indexes embeddings
- Monitoring API → Query handling: submits queries
- Query handling → RAG analysis: requests analysis
- RAG analysis → Vector index: retrieves context
- RAG analysis → Documents and reviews: stores review output
- Product management → Relational database: persists products
- Governance records → Relational database: persists records
- User accounts → Relational database: persists users
- Documents and reviews → Relational database: persists monitoring state
