# amolith/willow architecture

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

- Interactive diagram: https://gitdiagram.com/amolith/willow
- Repository: https://github.com/amolith/willow

## Overview

##### Main Components Identification
The system can be broken down into these major components:

a. Core Components:
- Web Server (ws/)
- Database Layer (db/)
- Git Integration Service (git/)
- RSS Feed Handler (rss/)
- User Management (users/)
- Project Management (project/)

b. External Interfaces:
- Various Git Forges (GitHub, GitLab, SourceHut, etc.)
- RSS Feeds
- Web UI

**[Git Forges] [RSS Feeds] [Web Browsers]**

**[Web Server (ws/)]**

- [User Management]
- [Project Management]
- [Release Tracking]

**[Git Service] [RSS Handler] [Database]**

##### Component Relationships

- Blue: Core components
- Green: External interfaces
- Orange: Data storage
- Purple: Service components

##### Specific Implementation Details

a. Database Layer:
- SQL migrations support
- Project and release tracking tables
- User management storage

b. Web Server:
- Static file serving (templates, CSS)
- User authentication flow
- Project management interface

c. Integration Services:
- Git repository cloning and version tracking
- RSS feed parsing and monitoring
- Release detection logic

##### Key Interactions to Highlight

- User Authentication Flow
- Project Addition Process
- Release Detection Mechanism
- Version Comparison Logic
- Update Notification System

##### Deployment Context

A small section showing:
- Reverse proxy setup
- System daemon integration
- Database persistence

Remember to emphasize:
##### Web interface and CLI dual control paths

This will provide a comprehensive view of how Willow functions as a release tracking system while maintaining clarity about its internal architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Layer
    subgraph External
        GitForges["Git Forges"]
        RSSFeeds["RSS Feeds"]
        WebBrowsers["Web Browsers"]
    end

    %% Core Application Layer
    subgraph CoreApp
        WebServer["Web Server"]:::server
        click WebServer "https://github.com/Amolith/willow/blob/main/ws/ws.go"
        
        subgraph WebComponents
            Templates["Web Templates"]:::ui
            click Templates "https://github.com/Amolith/willow/tree/main/ws/static/"
            UIStyles["UI Styles"]:::ui
            click UIStyles "https://github.com/Amolith/willow/blob/main/ws/static/styles.css"
            StaticAssets["Static Assets"]:::ui
            click StaticAssets "https://github.com/Amolith/willow/tree/main/ws/static/"
        end

        subgraph Management
            UserMgmt["User Management"]:::core
            click UserMgmt "https://github.com/Amolith/willow/blob/main/users/users.go"
            ProjMgmt["Project Management"]:::core
            click ProjMgmt "https://github.com/Amolith/willow/blob/main/project/project.go"
            ReleaseMgmt["Release Management"]:::core
        end

        CLI["CLI Interface"]:::core
        click CLI "https://github.com/Amolith/willow/blob/main/cmd/cli.go"
    end

    %% Services Layer
    subgraph Services
        GitService["Git Integration Service"]:::service
        click GitService "https://github.com/Amolith/willow/blob/main/git/git.go"
        RSSHandler["RSS Feed Handler"]:::service
        click RSSHandler "https://github.com/Amolith/willow/blob/main/rss/rss.go"
    end

    %% Database Layer
    subgraph Storage
        Database["Database"]:::storage
        click Database "https://github.com/Amolith/willow/blob/main/db/db.go"
        SQLMigrations["SQL Migrations"]:::storage
        click SQLMigrations "https://github.com/Amolith/willow/tree/main/db/sql/"
        ProjectDB["Project DB Ops"]:::storage
        click ProjectDB "https://github.com/Amolith/willow/blob/main/db/project.go"
        ReleaseDB["Release DB Ops"]:::storage
        click ReleaseDB "https://github.com/Amolith/willow/blob/main/db/release.go"
        UserDB["User DB Ops"]:::storage
        click UserDB "https://github.com/Amolith/willow/blob/main/db/users.go"
    end

    %% Relationships
    WebBrowsers -->|HTTP| WebServer
    GitForges -.->|Version Data| GitService
    RSSFeeds -.->|Feed Data| RSSHandler

    WebServer --> UserMgmt
    WebServer --> ProjMgmt
    WebServer --> ReleaseMgmt
    WebServer --> Templates
    WebServer --> UIStyles
    WebServer --> StaticAssets

    CLI --> UserMgmt
    CLI --> ProjMgmt
    CLI --> ReleaseMgmt

    UserMgmt --> UserDB
    ProjMgmt --> ProjectDB
    ReleaseMgmt --> ReleaseDB

    GitService --> Database
    RSSHandler --> Database

    Database --> SQLMigrations
    Database --> ProjectDB
    Database --> ReleaseDB
    Database --> UserDB

    %% Styles
    classDef server fill:#3498db,stroke:#2980b9,color:white
    classDef ui fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#9b59b6,stroke:#8e44ad,color:white
    classDef storage fill:#e67e22,stroke:#d35400,color:white

    %% Legend
    subgraph Legend
        L1["Web Components"]:::server
        L2["UI Elements"]:::ui
        L3["Core Functions"]:::core
        L4["Services"]:::service
        L5["Storage"]:::storage
    end
```
