# mzubair31102/ai-portfolio architecture

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

- Interactive diagram: https://gitdiagram.com/mzubair31102/ai-portfolio
- Repository: https://github.com/mzubair31102/ai-portfolio

## Overview

This repository is a Flask-backed AI assistant template with two browser experiences: a conversational chat and a web-content generation page. Users submit messages from the frontend; the backend either maintains chat history and requests an Azure-hosted model response, or rewrites a query, obtains URLs, and scrapes page text. The backend also exposes PostgreSQL data and Redis test endpoints. The README describes Azure deployment and CI/CD, but those capabilities are not implemented in the supplied runtime tree. Relationships below follow the sampled app and JavaScript; unsampled deployment and schema details are omitted.

Main entry points: [`backend/app.py`](https://github.com/mzubair31102/ai-portfolio/blob/main/backend/app.py) (Flask API), [`frontend/index.html`](https://github.com/mzubair31102/ai-portfolio/blob/main/frontend/index.html) (Chat interface), [`frontend/jsscript.js`](https://github.com/mzubair31102/ai-portfolio/blob/main/frontend/jsscript.js) (Chat interaction), [`frontend/contentgen.html`](https://github.com/mzubair31102/ai-portfolio/blob/main/frontend/contentgen.html) (Content interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser experiences"]
  node_chat_ui["Chat interface<br/>[index.html]"]
  node_chat_js["Chat interaction<br/>[jsscript.js]"]
  node_content_ui["Content interface<br/>[contentgen.html]"]
  node_content_js["Content interaction<br/>[contentgen.js]"]
end

subgraph group_backend["Flask services"]
  node_api["Flask API<br/>[app.py]"]
  node_search_urls["URL search<br/>[search_url.py]"]
  node_scraper["Page scraper<br/>[scraper.py]"]
end

subgraph group_integrations["External services and data"]
  node_model["Azure AI model"]
  node_redis[("Redis history")]
  node_postgres[("PostgreSQL")]
end

node_user(("Assistant user"))
node_web_pages["Web pages"]

node_user -->|"uses"| node_chat_ui
node_chat_ui -->|"runs"| node_chat_js
node_chat_js -->|"posts chat"| node_api
node_user -->|"uses"| node_content_ui
node_content_ui -->|"runs"| node_content_js
node_content_js -->|"posts content"| node_api
node_api -->|"requests completion"| node_model
node_api -->|"reads and writes"| node_redis
node_api -->|"queries data"| node_postgres
node_api -->|"gets URLs"| node_search_urls
node_api -->|"fetches text"| node_scraper
node_scraper -->|"fetches pages"| node_web_pages

click node_chat_ui "https://github.com/mzubair31102/ai-portfolio/blob/main/frontend/index.html"
click node_chat_js "https://github.com/mzubair31102/ai-portfolio/blob/main/frontend/jsscript.js"
click node_content_ui "https://github.com/mzubair31102/ai-portfolio/blob/main/frontend/contentgen.html"
click node_content_js "https://github.com/mzubair31102/ai-portfolio/blob/main/frontend/contentgen.js"
click node_api "https://github.com/mzubair31102/ai-portfolio/blob/main/backend/app.py"
click node_search_urls "https://github.com/mzubair31102/ai-portfolio/blob/main/backend/services/search_url.py"
click node_scraper "https://github.com/mzubair31102/ai-portfolio/blob/main/backend/services/scraper.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_chat_ui,node_chat_js,node_content_ui,node_content_js,node_user toneBlue
class node_api,node_search_urls,node_scraper toneAmber
class node_model,node_redis,node_postgres toneMint
class node_web_pages toneIndigo
```

## Components

### Browser experiences

- [Chat interface](https://github.com/mzubair31102/ai-portfolio/blob/main/frontend/index.html): `frontend/index.html`
- [Chat interaction](https://github.com/mzubair31102/ai-portfolio/blob/main/frontend/jsscript.js): `frontend/jsscript.js`
- [Content interface](https://github.com/mzubair31102/ai-portfolio/blob/main/frontend/contentgen.html): `frontend/contentgen.html`
- [Content interaction](https://github.com/mzubair31102/ai-portfolio/blob/main/frontend/contentgen.js): `frontend/contentgen.js`

### Flask services

- [Flask API](https://github.com/mzubair31102/ai-portfolio/blob/main/backend/app.py): `backend/app.py`
- [URL search](https://github.com/mzubair31102/ai-portfolio/blob/main/backend/services/search_url.py): `backend/services/search_url.py`
- [Page scraper](https://github.com/mzubair31102/ai-portfolio/blob/main/backend/services/scraper.py): `backend/services/scraper.py`

### External services and data

- **Azure AI model**
- **Redis history**
- **PostgreSQL**

### Other components

- **Assistant user**
- **Web pages**

## Connections

- Assistant user → Chat interface: uses
- Chat interface → Chat interaction: runs (evidence: `frontend/jsscript.js`)
- Chat interaction → Flask API: posts chat (evidence: `frontend/jsscript.js`)
- Assistant user → Content interface: uses
- Content interface → Content interaction: runs (evidence: `frontend/contentgen.js`)
- Content interaction → Flask API: posts content (evidence: `frontend/contentgen.js`)
- Flask API → Azure AI model: requests completion (evidence: `backend/app.py`)
- Flask API → Redis history: reads and writes (evidence: `backend/app.py`)
- Flask API → PostgreSQL: queries data (evidence: `backend/app.py`)
- Flask API → URL search: gets URLs (evidence: `backend/app.py`)
- Flask API → Page scraper: fetches text (evidence: `backend/app.py`)
- Page scraper → Web pages: fetches pages (evidence: `backend/services/scraper.py`)
