# sriramkv1409/adgorithm architecture

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

- Interactive diagram: https://gitdiagram.com/sriramkv1409/adgorithm
- Repository: https://github.com/sriramkv1409/adgorithm

## Overview

Adgorithm personalizes advertisements using a viewer’s age and gender. The main flow captures a camera image, sends it to the Flask prediction endpoint, passes the returned profile to the ad slideshow, and loads matching ads from S3. A separate admin workflow manages targeted ads and displays analytics. The README documents local face analysis and privacy goals; backend implementation details were not excerpted, so internal backend relationships are left unverified where source evidence is unavailable.

Main entry points: [`frontend/src/App.js`](https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/App.js) (App routing), [`frontend/src/components/CameraCapture.js`](https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/CameraCapture.js) (Camera capture), [`frontend/src/components/AdSlideshow.js`](https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/AdSlideshow.js) (Ad slideshow), [`frontend/src/components/admin/AdminLayout.js`](https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/admin/AdminLayout.js) (Admin navigation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_audience["Audience experience"]
  node_app["App routing<br/>[App.js]"]
  node_camera["Camera capture<br/>[CameraCapture.js]"]
  node_face_detection["Face detection<br/>[CameraCapture.js]"]
end

subgraph group_backend["Prediction backend"]
  node_prediction_api["Prediction API<br/>[app.py]"]
  node_age_gender["Age/gender analysis<br/>[age_detection.py]"]
  node_model_files["Model artifacts"]
  node_admin_api["Admin API<br/>[app.py]"]
end

subgraph group_admin["Ad administration"]
  node_admin_layout["Admin navigation<br/>[AdminLayout.js]"]
  node_ad_manager["Ad management<br/>[AdManager.js]"]
  node_analytics["Analytics dashboard<br/>[AdminDashboard.js]"]
end

subgraph group_delivery["Ad delivery"]
  node_slideshow["Ad slideshow<br/>[AdSlideshow.js]"]
  node_s3_ads[("S3 ad library")]
  node_feedback_qr["Feedback QR"]
end

node_viewer(("Viewer"))

node_viewer -->|"opens"| node_app
node_app -->|"routes to"| node_camera
node_camera -->|"detects faces"| node_face_detection
node_camera -->|"posts image"| node_prediction_api
node_prediction_api -.->|"delegates analysis"| node_age_gender
node_age_gender -.->|"uses model"| node_model_files
node_camera -->|"routes profile"| node_slideshow
node_app -->|"routes to"| node_slideshow
node_slideshow -->|"loads matching ads"| node_s3_ads
node_slideshow -->|"displays after ads"| node_feedback_qr
node_app -->|"routes admin"| node_admin_layout
node_admin_layout -->|"renders route"| node_ad_manager
node_admin_layout -->|"renders route"| node_analytics
node_ad_manager -->|"uploads and updates"| node_admin_api
node_analytics -->|"requests statistics"| node_admin_api
node_admin_api -.->|"stores uploaded ads"| node_s3_ads

click node_app "https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/App.js"
click node_camera "https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/CameraCapture.js"
click node_face_detection "https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/CameraCapture.js"
click node_prediction_api "https://github.com/sriramkv1409/adgorithm/blob/main/backend/app.py"
click node_age_gender "https://github.com/sriramkv1409/adgorithm/blob/main/backend/age_detection.py"
click node_model_files "https://github.com/sriramkv1409/adgorithm/tree/main/backend/models"
click node_slideshow "https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/AdSlideshow.js"
click node_admin_layout "https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/admin/AdminLayout.js"
click node_ad_manager "https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/admin/AdManager.js"
click node_analytics "https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/admin/AdminDashboard.js"
click node_admin_api "https://github.com/sriramkv1409/adgorithm/blob/main/backend/app.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_app,node_camera,node_face_detection,node_viewer toneBlue
class node_prediction_api,node_age_gender,node_model_files,node_admin_api toneAmber
class node_admin_layout,node_ad_manager,node_analytics toneMint
class node_slideshow,node_s3_ads,node_feedback_qr toneRose
```

## Components

### Audience experience

- [App routing](https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/App.js): `frontend/src/App.js`
- [Camera capture](https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/CameraCapture.js): `frontend/src/components/CameraCapture.js`
- [Face detection](https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/CameraCapture.js): `frontend/src/components/CameraCapture.js`

### Prediction backend

- [Prediction API](https://github.com/sriramkv1409/adgorithm/blob/main/backend/app.py): `backend/app.py`
- [Age/gender analysis](https://github.com/sriramkv1409/adgorithm/blob/main/backend/age_detection.py): `backend/age_detection.py`
- [Model artifacts](https://github.com/sriramkv1409/adgorithm/tree/main/backend/models): `backend/models`
- [Admin API](https://github.com/sriramkv1409/adgorithm/blob/main/backend/app.py): `backend/app.py`

### Ad administration

- [Admin navigation](https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/admin/AdminLayout.js): `frontend/src/components/admin/AdminLayout.js`
- [Ad management](https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/admin/AdManager.js): `frontend/src/components/admin/AdManager.js`
- [Analytics dashboard](https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/admin/AdminDashboard.js): `frontend/src/components/admin/AdminDashboard.js`

### Ad delivery

- [Ad slideshow](https://github.com/sriramkv1409/adgorithm/blob/main/frontend/src/components/AdSlideshow.js): `frontend/src/components/AdSlideshow.js`
- **S3 ad library**
- **Feedback QR**

### Other components

- **Viewer**

## Connections

- Viewer → App routing: opens (evidence: `frontend/src/App.js`)
- App routing → Camera capture: routes to (evidence: `frontend/src/App.js`)
- Camera capture → Face detection: detects faces (evidence: `frontend/src/components/CameraCapture.js`)
- Camera capture → Prediction API: posts image (evidence: `frontend/src/components/CameraCapture.js`)
- Prediction API → Age/gender analysis: delegates analysis
- Age/gender analysis → Model artifacts: uses model
- Camera capture → Ad slideshow: routes profile (evidence: `frontend/src/components/CameraCapture.js`)
- App routing → Ad slideshow: routes to (evidence: `frontend/src/App.js`)
- Ad slideshow → S3 ad library: loads matching ads (evidence: `frontend/src/components/AdSlideshow.js`)
- Ad slideshow → Feedback QR: displays after ads (evidence: `frontend/src/components/AdSlideshow.js`)
- App routing → Admin navigation: routes admin (evidence: `frontend/src/App.js`)
- Admin navigation → Ad management: renders route (evidence: `frontend/src/App.js`)
- Admin navigation → Analytics dashboard: renders route (evidence: `frontend/src/App.js`)
- Ad management → Admin API: uploads and updates (evidence: `frontend/src/components/admin/AdManager.js`)
- Analytics dashboard → Admin API: requests statistics (evidence: `frontend/src/components/admin/AdminDashboard.js`)
- Admin API → S3 ad library: stores uploaded ads
