# irilith/vbt architecture

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

- Interactive diagram: https://gitdiagram.com/irilith/vbt
- Repository: https://github.com/irilith/vbt

## Overview

##### Main Components
- Backend (Rust):
– Two Rust crates are present: one called “rss” and another called “vbt”. The “vbt” crate is the primary application that contains modules for configuration, file operations, HTTP requests, services (such as the watchlist update), and Discord webhook integration. There is also a dedicated “rss” crate to handle RSS generation or parsing.
– Key modules include:
o Requests: Responsible for fetching or retrieving necessary data.
o File Operations & JSON Processing: Handling reading and writing of JSON/RSS files, caches, and configuration.
o Services: Including a watchlist service to track the books.
o Discord Integration: For sending updates or notifications via webhooks.
- Frontend (Next.js):
– Located in the “pages” directory, this part of the project uses Next.js and React.
– It presents the RSS feeds – for example, offering a website where users can select and copy an RSS feed URL.
– It uses UI components (buttons, dialog, etc.) and configuration files like tailwind.config and next.config.
- GitHub Actions / CI Integration:
– The .github folder contains several workflows (ci.yml, daily.yml, nextjs.yml) that handle continuous integration, daily updates, and perhaps deployment of the Next.js site.
– These workflow files indicate that the project is built and updated automatically via these pipelines.
- Data Feed Storage:
– Local file storage is used as a “database” of sorts, with directories like “feed/json” and “feed/rss” that store actual feed files.
– There are also configuration files like rss.json, watchlist.json, and date_cache.json that control the application’s runtime behavior and caching.

##### Relationships and Data Flow
- GitHub Actions initiates the periodic runs (daily or on event triggers).
- The backend Rust application (VBT) is built and executed as part of these actions:
– It retrieves the latest data (using its requests and services modules).
– It processes the data (using file_ops, json, and types modules), generates or updates the RSS feeds, and writes these to the “feed” directory.
– It optionally sends notifications or webhook messages via the Discord integration.
- The frontend Next.js application then serves a website that:
– Displays the available book feeds.
– Allows users to copy RSS feed URLs, and possibly provides further interaction.
- There is a clear separation of concerns, with the backend handling all the data processing and feed generation, and the frontend delivering user interaction.

##### Architectural Patterns and Key Technologies
- Modular Architecture: The backend is organized into distinct Rust crates and clearly separated modules (for file operations, requests, Discord communications, etc.). This encourages clean separation of concerns.
- Full-Stack Design: The system is split into a Rust-based backend and a Next.js frontend.
- CI/CD Integration: GitHub Actions workflows are crucial to automate testing, building, and deployment.
- File-Based Persistence: Instead of a database, the system uses local JSON and RSS files to manage state and feed data.
- External Integration: The Discord webhook integration module shows that the system can push notifications to an external messaging system.

##### Final Touches
- Avoid overcomplicating; focus on identifying as many separate functional components as possible, as this aids in clarity during discussions with your team.

## Diagram (Mermaid)

```mermaid
graph TB
    %% CI/CD System
    subgraph "CI/CD System"
        GA["GitHub Actions Workflows"]:::cicd
    end

    %% Backend Service (Rust)
    subgraph "Backend Service (Rust)"
        vbt["VBT Application"]:::backend
        rss["RSS Generation (Crate)"]:::backend
        config["Configuration"]:::backend
        requests["Requests/Data Fetching"]:::backend
        fileOps["File Operations"]:::backend
        jsonProc["JSON Processing"]:::backend
        services["Watchlist Service"]:::backend
        discord["Discord Integration"]:::backend
    end

    %% Data Store
    subgraph "Data Store"
        datastore["Feed Files & Configurations"]:::datastore
    end

    %% Frontend Application
    subgraph "Frontend Application"
        nextjs["Next.js Application"]:::frontend
    end

    %% External Integration
    discord_ext["Discord"]:::external

    %% Connections
    GA -->|"triggers"| vbt
    vbt -->|"loads"| config
    vbt -->|"initiates"| requests
    requests -->|"sends data to"| fileOps
    fileOps -->|"processes"| jsonProc
    jsonProc -->|"writes feeds to"| datastore
    vbt -->|"invokes"| services
    services -->|"notifies"| discord
    discord -->|"sends webhook"| discord_ext
    vbt -->|"generates feeds using"| rss
    rss -->|"updates"| datastore
    datastore -->|"serves feed to"| nextjs

    %% Styles
    classDef backend fill:#ffdddd,stroke:#990000,stroke-width:2px;
    classDef frontend fill:#ddffdd,stroke:#009900,stroke-width:2px;
    classDef cicd fill:#ddeeff,stroke:#003399,stroke-width:2px;
    classDef datastore fill:#ffffdd,stroke:#999900,stroke-width:2px;
    classDef external fill:#e5e5ff,stroke:#333399,stroke-width:2px;

    %% Click Events
    click rss "https://github.com/irilith/vbt/tree/main/crates/rss"
    click vbt "https://github.com/irilith/vbt/tree/main/crates/vbt"
    click config "https://github.com/irilith/vbt/tree/main/crates/vbt/src/config"
    click requests "https://github.com/irilith/vbt/tree/main/crates/vbt/src/requests"
    click fileOps "https://github.com/irilith/vbt/tree/main/crates/vbt/src/file_ops"
    click jsonProc "https://github.com/irilith/vbt/tree/main/crates/vbt/src/json"
    click services "https://github.com/irilith/vbt/tree/main/crates/vbt/src/services"
    click discord "https://github.com/irilith/vbt/tree/main/crates/vbt/src/discord"
    click nextjs "https://github.com/irilith/vbt/tree/main/pages"
    click GA "https://github.com/irilith/vbt/tree/main/.github/workflows"
    click datastore "https://github.com/irilith/vbt/tree/main/feed"
```
