# slash217/ipo-alert architecture

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

- Interactive diagram: https://gitdiagram.com/slash217/ipo-alert
- Repository: https://github.com/slash217/ipo-alert

## Overview

IPO Alert monitors Sharesansar for open Nepalese IPOs, suppresses repeat notifications, and emails configured recipients. The main runtime is initiated by either the Python entry point or CLI, then coordinated by IPOAlert: fetch and parse the source, check notification history, send alerts, and persist successful notifications. CLI health, statistics, and cleanup operations are additional product branches. The README documents automated scheduling and monitoring; workflow internals beyond the sampled runtime are not expanded here.

Main entry points: [`src/main_app.py`](https://github.com/slash217/ipo-alert/blob/main/src/main_app.py) (Alert coordinator), [`src/email_service.py`](https://github.com/slash217/ipo-alert/blob/main/src/email_service.py) (Email service), [`src/database.py`](https://github.com/slash217/ipo-alert/blob/main/src/database.py) (Notification history), [`cli.py`](https://github.com/slash217/ipo-alert/blob/main/cli.py) (CLI commands)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry points"]
  node_main["Python entry<br/>[main.py]"]
  node_cli["CLI commands<br/>[cli.py]"]
end

subgraph group_workflow["Alert workflow"]
  node_app["Alert coordinator<br/>[main_app.py]"]
  node_config["Configuration<br/>[config.py]"]
  node_scraper["IPO scraper<br/>[scraper.py]"]
  node_html["Fetched HTML<br/>[scraper.py]"]
  node_ipo["IPO model<br/>[models.py]"]
end

subgraph group_state["Notification state"]
  node_database[("Notification history<br/>[database.py]")]
  node_historyfile[("IPO history JSON<br/>[ipo_history.json]")]
  node_record["Notification record<br/>[models.py]"]
end

subgraph group_delivery["Email delivery"]
  node_email["Email service<br/>[email_service.py]"]
  node_gmail{{"Gmail SMTP"}}
  node_resend{{"Resend API"}}
end

subgraph group_operations["Operations"]
  node_logger["Logging<br/>[logger.py]"]
end

node_user(("Operator"))
node_sharesansar{{"Sharesansar"}}
node_recipient(("Email recipients"))

node_user -->|"runs"| node_main
node_user -->|"runs commands"| node_cli
node_main -->|"runs"| node_app
node_cli -->|"dispatches"| node_app
node_app -->|"loads"| node_config
node_app -->|"fetches and parses"| node_scraper
node_scraper -->|"requests data"| node_sharesansar
node_scraper -->|"saves and reads"| node_html
node_scraper -->|"creates"| node_ipo
node_app -->|"checks history"| node_database
node_app -->|"sends alert"| node_email
node_app -->|"saves success"| node_database
node_database -->|"reads and writes"| node_historyfile
node_database -->|"serializes"| node_record
node_database -->|"records IPO"| node_ipo
node_email -->|"formats alert"| node_ipo
node_email -->|"uses settings"| node_config
node_email -->|"sends via"| node_gmail
node_email -.->|"optionally sends via"| node_resend
node_email -->|"delivers to"| node_recipient
node_cli -->|"checks health"| node_app
node_app -->|"tests connection"| node_email
node_app -->|"checks source"| node_scraper
node_cli -->|"requests statistics"| node_app
node_app -->|"gets statistics"| node_database
node_cli -->|"requests cleanup"| node_app
node_app -->|"cleans records"| node_database
node_main -->|"configures"| node_logger
node_cli -->|"configures"| node_logger
node_app -->|"configures"| node_logger

click node_main "https://github.com/slash217/ipo-alert/blob/main/main.py"
click node_cli "https://github.com/slash217/ipo-alert/blob/main/cli.py"
click node_app "https://github.com/slash217/ipo-alert/blob/main/src/main_app.py"
click node_config "https://github.com/slash217/ipo-alert/blob/main/src/config.py"
click node_scraper "https://github.com/slash217/ipo-alert/blob/main/src/scraper.py"
click node_html "https://github.com/slash217/ipo-alert/blob/main/src/scraper.py"
click node_ipo "https://github.com/slash217/ipo-alert/blob/main/src/models.py"
click node_database "https://github.com/slash217/ipo-alert/blob/main/src/database.py"
click node_historyfile "https://github.com/slash217/ipo-alert/blob/main/data/ipo_history.json"
click node_record "https://github.com/slash217/ipo-alert/blob/main/src/models.py"
click node_email "https://github.com/slash217/ipo-alert/blob/main/src/email_service.py"
click node_logger "https://github.com/slash217/ipo-alert/blob/main/src/logger.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_cli toneBlue
class node_app,node_config,node_scraper,node_html,node_ipo toneAmber
class node_database,node_historyfile,node_record toneMint
class node_email,node_gmail,node_resend toneRose
class node_logger,node_user,node_sharesansar,node_recipient toneIndigo
```

## Components

### Entry points

- [Python entry](https://github.com/slash217/ipo-alert/blob/main/main.py): `main.py`
- [CLI commands](https://github.com/slash217/ipo-alert/blob/main/cli.py): `cli.py`

### Alert workflow

- [Alert coordinator](https://github.com/slash217/ipo-alert/blob/main/src/main_app.py): `src/main_app.py`
- [Configuration](https://github.com/slash217/ipo-alert/blob/main/src/config.py): `src/config.py`
- [IPO scraper](https://github.com/slash217/ipo-alert/blob/main/src/scraper.py): `src/scraper.py`
- [Fetched HTML](https://github.com/slash217/ipo-alert/blob/main/src/scraper.py): `src/scraper.py`
- [IPO model](https://github.com/slash217/ipo-alert/blob/main/src/models.py): `src/models.py`

### Notification state

- [Notification history](https://github.com/slash217/ipo-alert/blob/main/src/database.py): `src/database.py`
- [IPO history JSON](https://github.com/slash217/ipo-alert/blob/main/data/ipo_history.json): `data/ipo_history.json`
- [Notification record](https://github.com/slash217/ipo-alert/blob/main/src/models.py): `src/models.py`

### Email delivery

- [Email service](https://github.com/slash217/ipo-alert/blob/main/src/email_service.py): `src/email_service.py`
- **Gmail SMTP**
- **Resend API**

### Operations

- [Logging](https://github.com/slash217/ipo-alert/blob/main/src/logger.py): `src/logger.py`

### Other components

- **Operator**
- **Sharesansar**
- **Email recipients**

## Connections

- Operator → Python entry: runs (evidence: `README.md`)
- Operator → CLI commands: runs commands (evidence: `README.md`)
- Python entry → Alert coordinator: runs (evidence: `main.py`)
- CLI commands → Alert coordinator: dispatches (evidence: `cli.py`)
- Alert coordinator → Configuration: loads (evidence: `src/main_app.py`)
- Alert coordinator → IPO scraper: fetches and parses (evidence: `src/main_app.py`)
- IPO scraper → Sharesansar: requests data (evidence: `src/scraper.py`)
- IPO scraper → Fetched HTML: saves and reads (evidence: `src/scraper.py`)
- IPO scraper → IPO model: creates (evidence: `src/scraper.py`)
- Alert coordinator → Notification history: checks history (evidence: `src/main_app.py`)
- Alert coordinator → Email service: sends alert (evidence: `src/main_app.py`)
- Alert coordinator → Notification history: saves success (evidence: `src/main_app.py`)
- Notification history → IPO history JSON: reads and writes (evidence: `src/database.py`)
- Notification history → Notification record: serializes (evidence: `src/database.py`)
- Notification history → IPO model: records IPO (evidence: `src/database.py`)
- Email service → IPO model: formats alert (evidence: `src/email_service.py`)
- Email service → Configuration: uses settings (evidence: `src/email_service.py`)
- Email service → Gmail SMTP: sends via (evidence: `src/email_service.py`)
- Email service → Resend API: optionally sends via (evidence: `src/email_service.py`)
- Email service → Email recipients: delivers to (evidence: `src/email_service.py`)
- CLI commands → Alert coordinator: checks health (evidence: `cli.py`)
- Alert coordinator → Email service: tests connection (evidence: `src/main_app.py`)
- Alert coordinator → IPO scraper: checks source (evidence: `src/main_app.py`)
- CLI commands → Alert coordinator: requests statistics (evidence: `cli.py`)
- Alert coordinator → Notification history: gets statistics (evidence: `src/main_app.py`)
- CLI commands → Alert coordinator: requests cleanup (evidence: `cli.py`)
- Alert coordinator → Notification history: cleans records (evidence: `src/main_app.py`)
- Python entry → Logging: configures (evidence: `main.py`)
- CLI commands → Logging: configures (evidence: `cli.py`)
- Alert coordinator → Logging: configures (evidence: `src/main_app.py`)
