# sharvani-shriya/ad-spend-optimizer architecture

> Architecture diagram of the GitHub repository sharvani-shriya/ad-spend-optimizer, 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/sharvani-shriya/ad-spend-optimizer
- Repository: https://github.com/sharvani-shriya/ad-spend-optimizer

## Overview

Ad Channel Spend Optimizer is a small Vue-and-FastAPI dashboard for reviewing campaign performance and receiving a ROAS-based budget recommendation. The main workflow is: a user opens the dashboard, which requests campaign metrics and an optimization suggestion; the API reads campaigns from SQLite, computes per-campaign CPA/ROAS or invokes the optimizer, and returns results for display. The README documents dashboard capabilities not visible in the sampled frontend source; relationships below reflect the documented fetch workflow and inspected backend calls.

Main entry points: [`backend/main.py`](https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/main.py) (FastAPI routes), [`backend/optimizer.py`](https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/optimizer.py) (Budget suggestion), [`frontend/index.html`](https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/frontend/index.html) (Vue dashboard), [`backend/database.py`](https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/database.py) (Campaigns SQLite)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_dashboard["Dashboard"]
  node_dashboard_page["Vue dashboard<br/>[index.html]"]
end

subgraph group_api["API"]
  node_api_app["FastAPI routes<br/>[main.py]"]
  node_campaign_metrics["Campaign metrics<br/>[main.py]"]
end

subgraph group_analytics["Optimization"]
  node_channel_roas["Channel ROAS<br/>[optimizer.py]"]
  node_reallocation["Budget suggestion<br/>[optimizer.py]"]
end

subgraph group_storage["Campaign data"]
  node_campaign_db[("Campaigns SQLite<br/>[database.py]")]
end

node_user(("Advertiser"))

node_user -->|"opens"| node_dashboard_page
node_dashboard_page -->|"fetches data"| node_api_app
node_api_app -->|"reads campaigns"| node_campaign_db
node_api_app -->|"computes CPA/ROAS"| node_campaign_metrics
node_campaign_metrics -->|"returns metrics"| node_api_app
node_api_app -->|"requests suggestion"| node_reallocation
node_reallocation -->|"aggregates ROAS"| node_channel_roas
node_reallocation -->|"returns suggestion"| node_api_app
node_api_app -->|"returns results"| node_dashboard_page

click node_dashboard_page "https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/frontend/index.html"
click node_api_app "https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/main.py"
click node_campaign_metrics "https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/main.py"
click node_channel_roas "https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/optimizer.py"
click node_reallocation "https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/optimizer.py"
click node_campaign_db "https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/database.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_dashboard_page toneBlue
class node_api_app,node_campaign_metrics toneAmber
class node_channel_roas,node_reallocation toneMint
class node_campaign_db toneRose
class node_user toneIndigo
```

## Components

### Dashboard

- [Vue dashboard](https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/frontend/index.html): `frontend/index.html`

### API

- [FastAPI routes](https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/main.py): `backend/main.py`
- [Campaign metrics](https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/main.py): `backend/main.py`

### Optimization

- [Channel ROAS](https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/optimizer.py): `backend/optimizer.py`
- [Budget suggestion](https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/optimizer.py): `backend/optimizer.py`

### Campaign data

- [Campaigns SQLite](https://github.com/sharvani-shriya/ad-spend-optimizer/blob/main/backend/database.py): `backend/database.py`

### Other components

- **Advertiser**

## Connections

- Advertiser → Vue dashboard: opens
- Vue dashboard → FastAPI routes: fetches data
- FastAPI routes → Campaigns SQLite: reads campaigns
- FastAPI routes → Campaign metrics: computes CPA/ROAS
- Campaign metrics → FastAPI routes: returns metrics
- FastAPI routes → Budget suggestion: requests suggestion
- Budget suggestion → Channel ROAS: aggregates ROAS
- Budget suggestion → FastAPI routes: returns suggestion
- FastAPI routes → Vue dashboard: returns results
