# edictor96/tarangini-alerts architecture

> Architecture diagram of the GitHub repository edictor96/tarangini-alerts, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/edictor96/tarangini-alerts
- Repository: https://github.com/edictor96/tarangini-alerts

## Overview

##### Project type and purpose
- This is a small full-stack monolithic web application (“Taranगini — Disaster Alert Demo”).
- It ingests disaster-alert data by scraping an external source (INCOIS), stores it in a local JSON file (alerts.json), and serves a simple UI over HTTP using FastAPI with Jinja2 templates and static assets.

##### File structure
- Top-level
– main.py → entrypoint for FastAPI application (run via uvicorn)
– incois_scraper (1).py → standalone scraper script that fetches data from INCOIS and writes to alerts.json
– alerts.json → local data store for scraped alert records
– README.md → instructions to set up and run
– .gitignore → version-control ignores
- Folders
– templates/ → Jinja2 HTML views (index.html, db_view.html) and CSS file (styles.css)
– static/ → any other static assets (images, JS, extra CSS)

##### README for additional insights
- Confirms use of uvicorn and FastAPI (“python -m uvicorn main:app --reload”)
- No external database; uses a JSON file as data store
- Simplified demo, no cloud deployment files or containerization shown

a. Main components
- External Data Source (INCOIS API or website)
- Scraper Module (incois_scraper.py)
- Local Data Store (alerts.json)
- Backend Service (FastAPI app in main.py)
- Templating Engine (Jinja2)
- Static File Server (CSS under templates/ or static/)
- Web Client (Browser)
b. Relationships and data flows
1. Scheduler or manual trigger invokes the Scraper Module → fetches from INCOIS → writes to alerts.json
2. Web Client (Browser) → HTTP GET to Backend Service
3. Backend Service reads alerts.json → processes via Jinja2 → serves HTML + CSS
4. Web Client renders UI, user interacts → may trigger more API calls or page reloads
c. Architectural patterns / principles
– Separation of concerns: scraping logic is decoupled from request handling
– Single-process monolith; could evolve into microservices if scaled
– Template-based rendering for simplicity (no SPA framework)
d. Key technologies/frameworks
– Python 3, FastAPI, Uvicorn
– Jinja2 templating
– Simple file-based “database” (alerts.json)
– Optional scheduler (cron, APScheduler) for the scraper

##### Detailed yet simple breakdown
- Don’t over-fragment: two main subsystems (Data Ingestion vs Presentation) plus external source and client.
- Every Python script as a component only if it has an ongoing runtime role (main.py, scraper if scheduled).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Ingestion Layer
    subgraph "Data Ingestion Layer"
        INCOIS["External INCOIS Source"]:::external
        Scheduler["Scheduler (cron/APScheduler)"]:::scheduler
        Scraper["Scraper Module"]:::service
        DB["alerts.json"]:::db
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Web Client (Browser)"]:::client
        API["FastAPI App"]:::service
        subgraph "Templates & Static Assets"
            Index["index.html"]:::template
            DBView["db_view.html"]:::template
            Styles["styles.css"]:::static
            StaticDir["static/"]:::static
        end
    end

    %% Data Flows
    INCOIS -->|"fetch data"| Scraper
    Scheduler -->|"trigger scrape"| Scraper
    Scraper -->|"write JSON"| DB

    Browser -->|"HTTP GET"| API
    API -->|"read JSON"| DB
    API -->|"render"| Index
    API -->|"render"| DBView
    API -->|"serve assets"| Styles
    API -->|"serve assets"| StaticDir
    Index -->|"HTML/CSS"| Browser
    DBView -->|"HTML/CSS"| Browser
    Styles -->|"CSS"| Browser
    StaticDir -->|"assets"| Browser

    %% Click Events
    click Scraper "https://github.com/edictor96/tarangini-alerts/blob/main/incois_scraper (1).py"
    click DB "https://github.com/edictor96/tarangini-alerts/blob/main/alerts.json"
    click API "https://github.com/edictor96/tarangini-alerts/blob/main/main.py"
    click Index "https://github.com/edictor96/tarangini-alerts/blob/main/templates/index.html"
    click DBView "https://github.com/edictor96/tarangini-alerts/blob/main/templates/db_view.html"
    click Styles "https://github.com/edictor96/tarangini-alerts/blob/main/templates/styles.css"
    click StaticDir "https://github.com/edictor96/tarangini-alerts/tree/main/static/"
    click README "https://github.com/edictor96/tarangini-alerts/blob/main/README.md"
    click GitIgnore "https://github.com/edictor96/tarangini-alerts/blob/main/.gitignore"

    %% Styles
    classDef external fill:#B3E5FC,stroke:#0288D1,color:#01579B;
    classDef service fill:#C8E6C9,stroke:#388E3C,color:#1B5E20;
    classDef db fill:#FFECB3,stroke:#FFB300,color:#E65100;
    classDef template fill:#E1BEE7,stroke:#8E24AA,color:#4A148C;
    classDef static fill:#E0E0E0,stroke:#9E9E9E,color:#424242;
    classDef client fill:#FFF9C4,stroke:#FBC02D,color:#F57F17;
    classDef scheduler fill:#FFCCBC,stroke:#E64A19,color:#BF360C;
```
