# saip05501-coder/navy-agent architecture

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

- Interactive diagram: https://gitdiagram.com/saip05501-coder/navy-agent
- Repository: https://github.com/saip05501-coder/navy-agent

## Overview

1. **What this repo is:**  
   This is a small, single-purpose Python agent, not a web app. Its job is to periodically check the Indian Navy recruitment site, detect new relevant updates, and send email alerts.

2. **Main execution entrypoint:**  
   `main.py` is the orchestrator. It ties together scraping, change detection/storage, and notification sending into one run cycle.

3. **Data collection boundary:**  
   `scraper.py` is the source-ingestion layer. It pulls content from the Indian Navy website using HTTP requests and HTML parsing, then extracts only the relevant news/recruitment section.

4. **State and deduplication boundary:**  
   `storage.py` handles persistence of notification history in `data/notifications.json`. This is the key stateful part of the system and is likely used to avoid re-sending the same alert on every run.

5. **Notification boundary:**  
   `notifier.py` is the delivery layer. It sends email alerts through SMTP, separating outbound communication from scraping and storage logic.

6. **Configuration boundary:**  
   `config.py` centralizes runtime settings such as target URLs, email/SMTP parameters, and file locations. This keeps environment-specific values out of the core logic.

7. **Persistent data layout:**  
   The `data/` directory is the only explicit application data store in the repo. The JSON file there is the durable memory of what has already been notified.

8. **Operational scheduling:**  
   `.github/workflows/navy-agent.yml` indicates the agent is intended to run on a schedule or CI runner. That makes the system an automated job runner rather than a continuously serving process.

9. **External dependencies and services:**  
   The architecture depends on three outside systems: the Indian Navy site as the data source, an SMTP service as the notification sink, and GitHub Actions/hosting infrastructure for execution.

10. **End-to-end flow:**  
   The run sequence is: fetch website content → extract relevant updates → compare/store against prior notifications → send email if something new is found.  
   The main architectural boundary is between external scraping, local state tracking, and outbound email delivery.

11. **Overall shape:**  
   This is a lightweight, pull-based monitoring agent with a small amount of local persistence. Its correctness depends mostly on the website structure, the JSON state file, and the SMTP delivery configuration.

Main entry points: [`main.py`](https://github.com/saip05501-coder/navy-agent/blob/main/main.py) (Main), [`config.py`](https://github.com/saip05501-coder/navy-agent/blob/main/config.py) (Config), [`scraper.py`](https://github.com/saip05501-coder/navy-agent/blob/main/scraper.py) (Scraper), [`storage.py`](https://github.com/saip05501-coder/navy-agent/blob/main/storage.py) (Storage)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_main_py["Main<br/>orchestrator<br/>[main.py]"]
  node_config_py["Config<br/>settings<br/>[config.py]"]
  node_scraper_py["Scraper<br/>ingestion<br/>[scraper.py]"]
  node_storage_py[("Storage<br/>dedupe store<br/>[storage.py]")]
  node_notifier_py["Notifier<br/>email delivery<br/>[notifier.py]"]
end

subgraph group_state["State"]
  node_notifications_json[("Notifications<br/>json state<br/>[notifications.json]")]
end

subgraph group_ops["Automation"]
  node_workflow_yml["Workflow<br/>scheduled job<br/>[navy-agent.yml]"]
end

subgraph group_ext["External"]
  node_navy_site(("Navy site<br/>web source"))
  node_smtp_service(("SMTP<br/>mail service"))
  node_github_actions(("GitHub Actions<br/>runner"))
end

node_workflow_yml -->|"runs on"| node_github_actions
node_github_actions -->|"invokes"| node_main_py
node_main_py -->|"loads"| node_config_py
node_main_py -->|"fetches via"| node_scraper_py
node_main_py -->|"checks state"| node_storage_py
node_main_py -->|"sends alerts"| node_notifier_py
node_scraper_py -->|"requests"| node_navy_site
node_storage_py -->|"reads/writes"| node_notifications_json
node_notifier_py -->|"delivers via"| node_smtp_service
node_storage_py -->|"uses paths"| node_config_py
node_scraper_py -->|"uses settings"| node_config_py
node_notifier_py -->|"uses settings"| node_config_py
node_main_py -.->|"deployed by"| node_workflow_yml

click node_main_py "https://github.com/saip05501-coder/navy-agent/blob/main/main.py"
click node_config_py "https://github.com/saip05501-coder/navy-agent/blob/main/config.py"
click node_scraper_py "https://github.com/saip05501-coder/navy-agent/blob/main/scraper.py"
click node_storage_py "https://github.com/saip05501-coder/navy-agent/blob/main/storage.py"
click node_notifier_py "https://github.com/saip05501-coder/navy-agent/blob/main/notifier.py"
click node_notifications_json "https://github.com/saip05501-coder/navy-agent/blob/main/data/notifications.json"
click node_workflow_yml "https://github.com/saip05501-coder/navy-agent/blob/main/.github/workflows/navy-agent.yml"

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_py,node_config_py,node_scraper_py,node_storage_py,node_notifier_py toneBlue
class node_notifications_json toneAmber
class node_workflow_yml toneMint
class node_navy_site,node_smtp_service,node_github_actions toneRose
```

## Components

### Application

Core Python agent that orchestrates scraping, state tracking, and email delivery.

- [Main](https://github.com/saip05501-coder/navy-agent/blob/main/main.py): orchestrator · Runs one monitoring cycle and coordinates the other modules. · `main.py`
- [Config](https://github.com/saip05501-coder/navy-agent/blob/main/config.py): settings · Central runtime settings for URLs, email, SMTP, and file paths. · `config.py`
- [Scraper](https://github.com/saip05501-coder/navy-agent/blob/main/scraper.py): ingestion · Fetches the Indian Navy site and extracts relevant recruitment/news content. · `scraper.py`
- [Storage](https://github.com/saip05501-coder/navy-agent/blob/main/storage.py): dedupe store · Reads and updates notification history to prevent duplicate alerts. · `storage.py`
- [Notifier](https://github.com/saip05501-coder/navy-agent/blob/main/notifier.py): email delivery · Sends alert emails through SMTP. · `notifier.py`

### State

Persistent notification memory used for deduplication.

- [Notifications](https://github.com/saip05501-coder/navy-agent/blob/main/data/notifications.json): json state · Durable record of previously sent alerts. · `data/notifications.json`

### Automation

Scheduled execution setup for the agent.

- [Workflow](https://github.com/saip05501-coder/navy-agent/blob/main/.github/workflows/navy-agent.yml): scheduled job · GitHub Actions workflow that triggers the agent on a schedule or runner. · `.github/workflows/navy-agent.yml`

### External

Outside systems the repo depends on.

- **Navy site**: web source · External Indian Navy recruitment/news website being monitored.
- **SMTP**: mail service · External email transport used to deliver alerts.
- **GitHub Actions**: runner · Execution environment for the scheduled automation.

## Connections

- Workflow → GitHub Actions: runs on · Workflow is executed by GitHub Actions.
- GitHub Actions → Main: invokes · Runner starts the monitoring job.
- Main → Config: loads · Main reads runtime settings.
- Main → Scraper: fetches via · Main asks the scraper for current site content.
- Main → Storage: checks state · Main consults stored notification history.
- Main → Notifier: sends alerts · Main triggers email delivery when new updates are found.
- Scraper → Navy site: requests · Scraper pulls content from the Indian Navy website.
- Storage → Notifications: reads/writes · Storage persists deduplication state in the JSON file.
- Notifier → SMTP: delivers via · Notifier sends outbound mail through SMTP.
- Storage → Config: uses paths · Storage relies on configured file locations.
- Scraper → Config: uses settings · Scraper uses configured target URLs and parsing parameters.
- Notifier → Config: uses settings · Notifier uses configured SMTP and recipient values.
- Main → Workflow: deployed by · The scheduled job wraps the main entrypoint.
