# humzah-kiani/fca_marketing_app architecture

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

- Interactive diagram: https://gitdiagram.com/humzah-kiani/fca_marketing_app
- Repository: https://github.com/humzah-kiani/fca_marketing_app

## Overview

This Streamlit application drafts financial-promotion copy grounded in cached FCA guidance, validates it, and records each generation for later review. Advisers can also create visual posts, inspect generation history, and run a compliance monitor that flags posts tied to outdated guidance. The main flow is visible in the app and sampled modules; monitor fetching and database behavior are also sampled. The design editor’s internal UI details and some app routes are only partially excerpted, so the graph omits uncertain wiring.

Main entry points: [`app.py`](https://github.com/humzah-kiani/fca_marketing_app/blob/main/app.py) (Streamlit app), [`db.py`](https://github.com/humzah-kiani/fca_marketing_app/blob/main/db.py) (Database access), [`generator.py`](https://github.com/humzah-kiani/fca_marketing_app/blob/main/generator.py) (Copy generation), [`compliance_validator.py`](https://github.com/humzah-kiani/fca_marketing_app/blob/main/compliance_validator.py) (Copy validation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_authoring["Drafting and Design"]
  node_streamlit["Streamlit app<br/>[app.py]"]
  node_copygen["Copy generation<br/>[generator.py]"]
  node_poststudio["Visual post editor<br/>[post_studio.py]"]
end

subgraph group_assurance["Compliance Monitoring"]
  node_validator["Copy validation"]
  node_reference["FCA reference cache<br/>[fca_monitor.py]"]
  node_monitor["Change detection<br/>[fca_monitor.py]"]
  node_scheduledcheck["Scheduled checks<br/>[monitor_cli.py]"]
end

subgraph group_storage["Persistence"]
  node_postgres[("PostgreSQL<br/>[schema.sql]")]
  node_dbaccess["Database access<br/>[db.py]"]
end

subgraph group_integrations["External Services"]
  node_fcasources["FCA pages and PDFs"]
  node_gemini["Google Gemini"]
  node_ollama["Ollama service"]
end

node_adviser(("Financial adviser"))

node_adviser -->|"provides request"| node_streamlit
node_streamlit -->|"requests drafts"| node_copygen
node_copygen -->|"reads guidance"| node_reference
node_copygen -.->|"generates with"| node_gemini
node_copygen -.->|"generates with"| node_ollama
node_copygen -->|"returns drafts"| node_streamlit
node_streamlit -->|"validates drafts"| node_validator
node_validator -->|"reads guidance"| node_reference
node_validator -.->|"reviews with"| node_gemini
node_validator -.->|"reviews with"| node_ollama
node_validator -->|"returns review"| node_streamlit
node_streamlit -->|"stores batches"| node_dbaccess
node_streamlit -->|"reads history"| node_dbaccess
node_streamlit -->|"opens editor"| node_poststudio
node_streamlit -->|"runs check"| node_monitor
node_scheduledcheck -->|"initializes tables"| node_dbaccess
node_scheduledcheck -->|"runs check"| node_monitor
node_monitor -->|"fetches guidance"| node_fcasources
node_monitor -->|"reads and updates"| node_dbaccess
node_reference -->|"reads cached text"| node_dbaccess
node_dbaccess -->|"queries and writes"| node_postgres

click node_streamlit "https://github.com/humzah-kiani/fca_marketing_app/blob/main/app.py"
click node_copygen "https://github.com/humzah-kiani/fca_marketing_app/blob/main/generator.py"
click node_validator "https://github.com/humzah-kiani/fca_marketing_app/blob/main/compliance_validator.py"
click node_poststudio "https://github.com/humzah-kiani/fca_marketing_app/blob/main/post_studio.py"
click node_reference "https://github.com/humzah-kiani/fca_marketing_app/blob/main/fca_monitor.py"
click node_monitor "https://github.com/humzah-kiani/fca_marketing_app/blob/main/fca_monitor.py"
click node_scheduledcheck "https://github.com/humzah-kiani/fca_marketing_app/blob/main/monitor_cli.py"
click node_postgres "https://github.com/humzah-kiani/fca_marketing_app/blob/main/schema.sql"
click node_dbaccess "https://github.com/humzah-kiani/fca_marketing_app/blob/main/db.py"

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_streamlit,node_copygen,node_poststudio toneBlue
class node_validator,node_reference,node_monitor,node_scheduledcheck toneAmber
class node_postgres,node_dbaccess toneMint
class node_fcasources,node_gemini,node_ollama toneRose
class node_adviser toneIndigo
```

## Components

### Drafting and Design

- [Streamlit app](https://github.com/humzah-kiani/fca_marketing_app/blob/main/app.py): `app.py`
- [Copy generation](https://github.com/humzah-kiani/fca_marketing_app/blob/main/generator.py): `generator.py`
- [Visual post editor](https://github.com/humzah-kiani/fca_marketing_app/blob/main/post_studio.py): `post_studio.py`

### Compliance Monitoring

- [Copy validation](https://github.com/humzah-kiani/fca_marketing_app/blob/main/compliance_validator.py): `compliance_validator.py`
- [FCA reference cache](https://github.com/humzah-kiani/fca_marketing_app/blob/main/fca_monitor.py): `fca_monitor.py`
- [Change detection](https://github.com/humzah-kiani/fca_marketing_app/blob/main/fca_monitor.py): `fca_monitor.py`
- [Scheduled checks](https://github.com/humzah-kiani/fca_marketing_app/blob/main/monitor_cli.py): `monitor_cli.py`

### Persistence

- [PostgreSQL](https://github.com/humzah-kiani/fca_marketing_app/blob/main/schema.sql): `schema.sql`
- [Database access](https://github.com/humzah-kiani/fca_marketing_app/blob/main/db.py): `db.py`

### External Services

- **FCA pages and PDFs**
- **Google Gemini**
- **Ollama service**

### Other components

- **Financial adviser**

## Connections

- Financial adviser → Streamlit app: provides request
- Streamlit app → Copy generation: requests drafts
- Copy generation → FCA reference cache: reads guidance
- Copy generation → Google Gemini: generates with
- Copy generation → Ollama service: generates with
- Copy generation → Streamlit app: returns drafts
- Streamlit app → Copy validation: validates drafts
- Copy validation → FCA reference cache: reads guidance
- Copy validation → Google Gemini: reviews with
- Copy validation → Ollama service: reviews with
- Copy validation → Streamlit app: returns review
- Streamlit app → Database access: stores batches
- Streamlit app → Database access: reads history
- Streamlit app → Visual post editor: opens editor
- Streamlit app → Change detection: runs check
- Scheduled checks → Database access: initializes tables
- Scheduled checks → Change detection: runs check
- Change detection → FCA pages and PDFs: fetches guidance
- Change detection → Database access: reads and updates
- FCA reference cache → Database access: reads cached text
- Database access → PostgreSQL: queries and writes
