# jamborjan/dorfinfobot architecture

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

- Interactive diagram: https://gitdiagram.com/jamborjan/dorfinfobot
- Repository: https://github.com/jamborjan/dorfinfobot

## Overview

##### Main Components Identification

a. News Scrapers (Node-RED based)
- Multiple scraper flows for different sources (Dierikon news, publications, Luzerner Zeitung, etc.)
- Implemented as Node-RED flows for flexibility

b. Central API (.NET Core)
- Core backend service
- Handles data persistence
- Provides REST endpoints
- Uses Entity Framework with SQLite

c. Channel Connectors (Node-RED based)
- Telegram connector
- Twitter connector
- Other potential channels

d. Web Interface (Blazor)
- Administrative interface
- News management
- Channel configuration

**[News Sources]**
- ↓
**[Node-RED Scrapers] → [Central API (.NET Core)] → [Node-RED Connectors]**
- ↓                     ↑    ↓                        ↓
**[SQLite Database] ←––––––┘    [Web Interface]    [Distribution Channels]**

##### Detailed Component Representation

For the API layer, show:
- Controllers (News, Channel, Broadcast, Attachment)
- Entity Framework context
- Repository layer
- DTOs for data transfer

For Node-RED components, represent:
- Individual scraper flows
- Channel connectors
- Flow direction
- API integration points

##### Infrastructure Layer

Infrastructure components:
- Kubernetes cluster
- Traefik ingress
- Basic Auth middleware
- Exposed endpoints:
- file-dib.domain.com
- db-dib.domain.com
- api-dib.domain.com
- nr-dib.domain.com

##### Data Flow Representation

- News collection flow from sources through scrapers
- Data persistence flow to SQLite
- Broadcasting flow through channel connectors
- Administrative control flow through web interface

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef external fill:#b3d1ff,stroke:#333
    classDef nodered fill:#99ff99,stroke:#333
    classDef core fill:#ff9999,stroke:#333
    classDef web fill:#ffcc99,stroke:#333
    classDef db fill:#e6e6e6,stroke:#333
    classDef infra fill:#d9d9d9,stroke:#333

    %% Infrastructure Layer
    subgraph Kubernetes["Kubernetes Cluster"]
        Ingress["Traefik Ingress"]
        BasicAuth["Basic Auth Middleware"]

        %% News Sources
        subgraph Sources["News Sources"]
            Dierikon["Dierikon Portal"]:::external
            LuzernerZeitung["Luzerner Zeitung"]:::external
            Rontaler["Rontaler"]:::external
        end

        %% Scrapers Layer
        subgraph Scrapers["Node-RED Scrapers"]
            DierikonNews["Dierikon News Scraper"]:::nodered
            DierikonBau["Dierikon Baugesuche Scraper"]:::nodered
            DierikonPub["Dierikon Publikationen Scraper"]:::nodered
            LuzernerScraper["Luzerner Zeitung Scraper"]:::nodered
            RontalerScraper["Rontaler Scraper"]:::nodered
        end

        %% Core API Layer
        subgraph API["Central API (.NET Core)"]
            Controllers["API Controllers"]:::core
            EFContext["Entity Framework Context"]:::core
            Repository["Repository Layer"]:::core
            DTOs["Data Transfer Objects"]:::core
            SwaggerUI["Swagger UI"]:::core
        end

        %% Database
        Database[(SQLite Database)]:::db

        %% Web Interface
        subgraph WebUI["Web Interface (Blazor)"]
            AdminPages["Admin Pages"]:::web
            NewsManagement["News Management"]:::web
            ChannelConfig["Channel Configuration"]:::web
        end

        %% Channel Connectors
        subgraph Connectors["Node-RED Connectors"]
            TelegramConnector["Telegram Connector"]:::nodered
            TwitterConnector["Twitter Connector"]:::nodered
        end

        %% Distribution Channels
        subgraph Channels["Distribution Channels"]
            Telegram["Telegram"]:::external
            Twitter["Twitter"]:::external
        end
    end

    %% Relationships
    Dierikon --> DierikonNews & DierikonBau & DierikonPub
    LuzernerZeitung --> LuzernerScraper
    Rontaler --> RontalerScraper

    DierikonNews & DierikonBau & DierikonPub & LuzernerScraper & RontalerScraper --> Controllers
    Controllers <--> Repository
    Repository <--> EFContext
    EFContext <--> Database
    Controllers <--> DTOs
    
    WebUI --> Controllers
    Controllers --> TelegramConnector & TwitterConnector
    TelegramConnector --> Telegram
    TwitterConnector --> Twitter

    %% Click Events
    click DierikonNews "https://github.com/JamborJan/DorfInfoBot/blob/main/attachments/node-red-flows/scraper-dierikon-news.json"
    click DierikonBau "https://github.com/JamborJan/DorfInfoBot/blob/main/attachments/node-red-flows/scraper-dierikon-baugesuche.json"
    click DierikonPub "https://github.com/JamborJan/DorfInfoBot/blob/main/attachments/node-red-flows/scraper-dierikon-publikationen.json"
    click LuzernerScraper "https://github.com/JamborJan/DorfInfoBot/blob/main/attachments/node-red-flows/scraper-luzerner-zeitung.json"
    click RontalerScraper "https://github.com/JamborJan/DorfInfoBot/blob/main/attachments/node-red-flows/scraper-rontaler.json"
    click Controllers "https://github.com/JamborJan/DorfInfoBot/tree/main/src/DorfInfoBot.API/Controllers/"
    click EFContext "https://github.com/JamborJan/DorfInfoBot/blob/main/src/DorfInfoBot.API/Contexts/NewsContext.cs"
    click DTOs "https://github.com/JamborJan/DorfInfoBot/tree/main/src/DorfInfoBot.API/Models/"
    click SwaggerUI "https://github.com/JamborJan/DorfInfoBot/tree/main/src/DorfInfoBot.API/wwwroot/swagger-ui/"
    click TelegramConnector "https://github.com/JamborJan/DorfInfoBot/blob/main/attachments/node-red-flows/connector-telegram.json"
    click TwitterConnector "https://github.com/JamborJan/DorfInfoBot/blob/main/attachments/node-red-flows/connector-twitter.json"
    click AdminPages "https://github.com/JamborJan/DorfInfoBot/tree/main/src/DorfInfoBot.Web/Pages/"
    click Database "https://github.com/JamborJan/DorfInfoBot/blob/main/src/DorfInfoBot.API/Contexts/NewsContext.cs"
```
