# codewithnavy/liaplusai_assignment architecture

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

- Interactive diagram: https://gitdiagram.com/codewithnavy/liaplusai_assignment
- Repository: https://github.com/codewithnavy/liaplusai_assignment

## Overview

This is a Flask chatbot with per-message and conversation-level sentiment reporting. The main workflow is browser message submission, sentiment scoring and reply generation, session-backed conversation history, then an end-of-conversation report with aggregate sentiment and a mood trend. The graph also shows the documented settings and diagnostics pages and optional OpenAI integration. Source excerpts establish the route and module calls; template relationships are supported by the render calls in app.py. Other UI details are represented at the template level.

Main entry points: [`app.py`](https://github.com/codewithnavy/liaplusai_assignment/blob/main/app.py) (Chat routes), [`static/style.css`](https://github.com/codewithnavy/liaplusai_assignment/blob/main/static/style.css) (Page styling), [`sentiment.py`](https://github.com/codewithnavy/liaplusai_assignment/blob/main/sentiment.py) (Message scoring), [`templates/index.html`](https://github.com/codewithnavy/liaplusai_assignment/blob/main/templates/index.html) (Chat page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_chat_ui["Chat page<br/>[index.html]"]
  node_report_ui["Sentiment report<br/>[result.html]"]
  node_settings_routes["Settings and validation<br/>[app.py]"]
  node_settings_ui["Settings page<br/>[settings.html]"]
  node_status_routes["Status and troubleshooting<br/>[app.py]"]
  node_status_ui["Status page<br/>[status.html]"]
  node_troubleshoot_ui["Troubleshoot page<br/>[troubleshoot.html]"]
  node_styles["Page styling<br/>[style.css]"]
end

subgraph group_conversation["Chat workflow"]
  node_chat_routes["Chat routes<br/>[app.py]"]
  node_history["Session history<br/>[app.py]"]
  node_fallback_reply["Fallback replies<br/>[app.py]"]
end

subgraph group_analysis["Sentiment analysis"]
  node_message_sentiment["Message scoring<br/>[sentiment.py]"]
  node_conversation_report["Conversation analysis<br/>[sentiment.py]"]
end

subgraph group_integrations["Reply integrations"]
  node_reply_adapter["LLM reply adapter<br/>[llm.py]"]
end

node_browser(("Browser user"))
node_openai{{"OpenAI API"}}
node_vader{{"NLTK VADER"}}

node_browser -->|"submits messages"| node_chat_routes
node_chat_routes -->|"renders chat"| node_chat_ui
node_chat_routes -->|"reads and updates"| node_history
node_chat_routes -->|"scores message"| node_message_sentiment
node_chat_routes -->|"requests reply"| node_reply_adapter
node_chat_routes -->|"uses on failure"| node_fallback_reply
node_reply_adapter -->|"requests completion"| node_openai
node_message_sentiment -->|"scores with"| node_vader
node_browser -->|"ends conversation"| node_chat_routes
node_chat_routes -->|"aggregates history"| node_conversation_report
node_conversation_report -->|"scores user messages"| node_message_sentiment
node_chat_routes -->|"renders report"| node_report_ui
node_browser -->|"manages settings"| node_settings_routes
node_settings_routes -->|"renders settings"| node_settings_ui
node_browser -->|"checks status"| node_status_routes
node_status_routes -->|"renders status"| node_status_ui
node_browser -->|"opens troubleshooting"| node_status_routes
node_status_routes -->|"renders page"| node_troubleshoot_ui
node_chat_ui -.->|"uses styling"| node_styles
node_report_ui -.->|"uses styling"| node_styles
node_settings_ui -.->|"uses styling"| node_styles
node_status_ui -.->|"uses styling"| node_styles
node_troubleshoot_ui -.->|"uses styling"| node_styles

click node_chat_ui "https://github.com/codewithnavy/liaplusai_assignment/blob/main/templates/index.html"
click node_chat_routes "https://github.com/codewithnavy/liaplusai_assignment/blob/main/app.py"
click node_history "https://github.com/codewithnavy/liaplusai_assignment/blob/main/app.py"
click node_message_sentiment "https://github.com/codewithnavy/liaplusai_assignment/blob/main/sentiment.py"
click node_conversation_report "https://github.com/codewithnavy/liaplusai_assignment/blob/main/sentiment.py"
click node_report_ui "https://github.com/codewithnavy/liaplusai_assignment/blob/main/templates/result.html"
click node_reply_adapter "https://github.com/codewithnavy/liaplusai_assignment/blob/main/llm.py"
click node_fallback_reply "https://github.com/codewithnavy/liaplusai_assignment/blob/main/app.py"
click node_settings_routes "https://github.com/codewithnavy/liaplusai_assignment/blob/main/app.py"
click node_settings_ui "https://github.com/codewithnavy/liaplusai_assignment/blob/main/templates/settings.html"
click node_status_routes "https://github.com/codewithnavy/liaplusai_assignment/blob/main/app.py"
click node_status_ui "https://github.com/codewithnavy/liaplusai_assignment/blob/main/templates/status.html"
click node_troubleshoot_ui "https://github.com/codewithnavy/liaplusai_assignment/blob/main/templates/troubleshoot.html"
click node_styles "https://github.com/codewithnavy/liaplusai_assignment/blob/main/static/style.css"

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_report_ui,node_settings_routes,node_settings_ui,node_status_routes,node_status_ui,node_troubleshoot_ui,node_styles,node_browser toneBlue
class node_chat_routes,node_history,node_fallback_reply toneAmber
class node_message_sentiment,node_conversation_report,node_openai toneMint
class node_reply_adapter toneRose
class node_vader toneIndigo
```

## Components

### Web application

- [Chat page](https://github.com/codewithnavy/liaplusai_assignment/blob/main/templates/index.html): `templates/index.html`
- [Sentiment report](https://github.com/codewithnavy/liaplusai_assignment/blob/main/templates/result.html): `templates/result.html`
- [Settings and validation](https://github.com/codewithnavy/liaplusai_assignment/blob/main/app.py): `app.py`
- [Settings page](https://github.com/codewithnavy/liaplusai_assignment/blob/main/templates/settings.html): `templates/settings.html`
- [Status and troubleshooting](https://github.com/codewithnavy/liaplusai_assignment/blob/main/app.py): `app.py`
- [Status page](https://github.com/codewithnavy/liaplusai_assignment/blob/main/templates/status.html): `templates/status.html`
- [Troubleshoot page](https://github.com/codewithnavy/liaplusai_assignment/blob/main/templates/troubleshoot.html): `templates/troubleshoot.html`
- [Page styling](https://github.com/codewithnavy/liaplusai_assignment/blob/main/static/style.css): `static/style.css`

### Chat workflow

- [Chat routes](https://github.com/codewithnavy/liaplusai_assignment/blob/main/app.py): `app.py`
- [Session history](https://github.com/codewithnavy/liaplusai_assignment/blob/main/app.py): `app.py`
- [Fallback replies](https://github.com/codewithnavy/liaplusai_assignment/blob/main/app.py): `app.py`

### Sentiment analysis

- [Message scoring](https://github.com/codewithnavy/liaplusai_assignment/blob/main/sentiment.py): `sentiment.py`
- [Conversation analysis](https://github.com/codewithnavy/liaplusai_assignment/blob/main/sentiment.py): `sentiment.py`

### Reply integrations

- [LLM reply adapter](https://github.com/codewithnavy/liaplusai_assignment/blob/main/llm.py): `llm.py`

### Other components

- **Browser user**
- **OpenAI API**
- **NLTK VADER**

## Connections

- Browser user → Chat routes: submits messages (evidence: `app.py`)
- Chat routes → Chat page: renders chat (evidence: `app.py`)
- Chat routes → Session history: reads and updates (evidence: `app.py`)
- Chat routes → Message scoring: scores message (evidence: `app.py`)
- Chat routes → LLM reply adapter: requests reply (evidence: `app.py`)
- Chat routes → Fallback replies: uses on failure (evidence: `app.py`)
- LLM reply adapter → OpenAI API: requests completion (evidence: `llm.py`)
- Message scoring → NLTK VADER: scores with (evidence: `sentiment.py`)
- Browser user → Chat routes: ends conversation (evidence: `app.py`)
- Chat routes → Conversation analysis: aggregates history (evidence: `app.py`)
- Conversation analysis → Message scoring: scores user messages (evidence: `sentiment.py`)
- Chat routes → Sentiment report: renders report (evidence: `app.py`)
- Browser user → Settings and validation: manages settings (evidence: `app.py`)
- Settings and validation → Settings page: renders settings (evidence: `app.py`)
- Browser user → Status and troubleshooting: checks status (evidence: `app.py`)
- Status and troubleshooting → Status page: renders status (evidence: `app.py`)
- Browser user → Status and troubleshooting: opens troubleshooting (evidence: `app.py`)
- Status and troubleshooting → Troubleshoot page: renders page (evidence: `app.py`)
- Chat page → Page styling: uses styling
- Sentiment report → Page styling: uses styling
- Settings page → Page styling: uses styling
- Status page → Page styling: uses styling
- Troubleshoot page → Page styling: uses styling
