# lgf2111/inf1103-project1-p9-g04 architecture

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

- Interactive diagram: https://gitdiagram.com/lgf2111/inf1103-project1-p9-g04
- Repository: https://github.com/lgf2111/inf1103-project1-p9-g04

## Overview

PhishReport is an interactive CLI that collects a suspicious message and reported actions, obtains and validates Groq findings, applies local assessment rules, displays guidance, and saves a report. Users can also browse saved history. The graph distinguishes prompt construction, provider transport, response parsing and validation, rule-based assessment, and local/PostgreSQL persistence. Some storage and logic implementation details were not sampled; their links are limited to the README and the shown orchestration.

Main entry points: [`app/main.py`](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/main.py) (Workflow controller), [`app/io_manager/__init__.py`](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/io_manager/__init__.py) (Terminal input and display), [`app/data_manager/__init__.py`](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/data_manager/__init__.py) (Report persistence and queries), [`app/ai_manager/prompt.py`](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/prompt.py) (Prompt builder)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI workflow"]
  node_main["Workflow controller<br/>[main.py]"]
  node_terminal_io["Terminal input and display<br/>[__init__.py]"]
end

subgraph group_ai["AI assessment"]
  node_prompt["Prompt builder<br/>[prompt.py]"]
  node_prompt_text["Prompt instructions<br/>[prompts.py]"]
  node_groq_client["Groq transport<br/>[client.py]"]
  node_response_parser["JSON response parser<br/>[parsing.py]"]
  node_finding_validator["Finding validator<br/>[validation.py]"]
  node_ai_errors["AI failure handling<br/>[errors.py]"]
end

subgraph group_rules["Assessment rules"]
  node_assessment_rules["Scoring and guidance<br/>[__init__.py]"]
end

subgraph group_reports["Reports and diagnostics"]
  node_report_manager["Report persistence and queries<br/>[__init__.py]"]
  node_json_history[("Local JSON history<br/>[__init__.py]")]
  node_logging["Diagnostic logging<br/>[logging_setup.py]"]
end

node_user(("CLI user"))
node_groq{{"Groq API"}}
node_postgres[("PostgreSQL reports")]

node_user -->|"provides input"| node_terminal_io
node_main -->|"collects and displays"| node_terminal_io
node_terminal_io -->|"returns record"| node_main
node_main -->|"builds prompt"| node_prompt
node_prompt -->|"uses instructions"| node_prompt_text
node_main -->|"requests findings"| node_groq_client
node_groq_client -->|"sends request"| node_groq
node_main -->|"parses reply"| node_response_parser
node_main -->|"validates findings"| node_finding_validator
node_main -->|"evaluates record"| node_assessment_rules
node_main -->|"saves and queries"| node_report_manager
node_report_manager -->|"reads and writes"| node_json_history
node_report_manager -->|"reads and writes"| node_postgres
node_main -->|"displays assessment"| node_terminal_io
node_main -->|"configures diagnostics"| node_logging
node_ai_errors -->|"logs failures"| node_logging

click node_main "https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/main.py"
click node_terminal_io "https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/io_manager/__init__.py"
click node_prompt "https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/prompt.py"
click node_prompt_text "https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/prompts.py"
click node_groq_client "https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/client.py"
click node_response_parser "https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/parsing.py"
click node_finding_validator "https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/validation.py"
click node_ai_errors "https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/errors.py"
click node_assessment_rules "https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/logic_manager/__init__.py"
click node_report_manager "https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/data_manager/__init__.py"
click node_json_history "https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/data_manager/__init__.py"
click node_logging "https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/misc/logging_setup.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_main,node_terminal_io,node_user toneBlue
class node_prompt,node_prompt_text,node_groq_client,node_response_parser,node_finding_validator,node_ai_errors,node_postgres toneAmber
class node_assessment_rules,node_groq toneMint
class node_report_manager,node_json_history,node_logging toneRose
```

## Components

### CLI workflow

- [Workflow controller](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/main.py): `app/main.py`
- [Terminal input and display](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/io_manager/__init__.py): `app/io_manager/__init__.py`

### AI assessment

- [Prompt builder](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/prompt.py): `app/ai_manager/prompt.py`
- [Prompt instructions](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/prompts.py): `app/ai_manager/prompts.py`
- [Groq transport](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/client.py): `app/ai_manager/client.py`
- [JSON response parser](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/parsing.py): `app/ai_manager/parsing.py`
- [Finding validator](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/validation.py): `app/ai_manager/validation.py`
- [AI failure handling](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/ai_manager/errors.py): `app/ai_manager/errors.py`

### Assessment rules

- [Scoring and guidance](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/logic_manager/__init__.py): `app/logic_manager/__init__.py`

### Reports and diagnostics

- [Report persistence and queries](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/data_manager/__init__.py): `app/data_manager/__init__.py`
- [Local JSON history](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/data_manager/__init__.py): `app/data_manager/__init__.py`
- [Diagnostic logging](https://github.com/lgf2111/inf1103-project1-p9-g04/blob/main/app/misc/logging_setup.py): `app/misc/logging_setup.py`

### Other components

- **CLI user**
- **Groq API**
- **PostgreSQL reports**

## Connections

- CLI user → Terminal input and display: provides input (evidence: `README.md`)
- Workflow controller → Terminal input and display: collects and displays (evidence: `app/main.py`)
- Terminal input and display → Workflow controller: returns record (evidence: `app/main.py`)
- Workflow controller → Prompt builder: builds prompt (evidence: `app/main.py`)
- Prompt builder → Prompt instructions: uses instructions (evidence: `app/ai_manager/prompt.py`)
- Workflow controller → Groq transport: requests findings (evidence: `app/main.py`)
- Groq transport → Groq API: sends request (evidence: `app/ai_manager/client.py`)
- Workflow controller → JSON response parser: parses reply (evidence: `app/main.py`)
- Workflow controller → Finding validator: validates findings (evidence: `app/main.py`)
- Workflow controller → Scoring and guidance: evaluates record (evidence: `app/main.py`)
- Workflow controller → Report persistence and queries: saves and queries (evidence: `app/main.py`)
- Report persistence and queries → Local JSON history: reads and writes (evidence: `README.md`)
- Report persistence and queries → PostgreSQL reports: reads and writes (evidence: `app/data_manager/__init__.py`)
- Workflow controller → Terminal input and display: displays assessment (evidence: `app/main.py`)
- Workflow controller → Diagnostic logging: configures diagnostics (evidence: `app/main.py`)
- AI failure handling → Diagnostic logging: logs failures (evidence: `app/ai_manager/errors.py`)
