# miniflux/v2 architecture

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

- Interactive diagram: https://gitdiagram.com/miniflux/v2
- Repository: https://github.com/miniflux/v2

## Overview

##### Main Components

a. Core Application Components:
- Web Server Layer (internal/http/server)
- API Layer (internal/api)
- User Interface Layer (internal/ui)
- Database Layer (PostgreSQL)
- Feed Processing System (internal/reader)
- Background Workers (internal/worker)

b. External Integrations:
- RSS/Atom Feed Sources
- Integration Services (internal/integration)
- Multiple third-party services (Pocket, Telegram, Matrix, etc.)
- Authentication Systems (OAuth2, WebAuthn)

##### Architecture Pattern Representation

**[Client Layer]**
- ↓↑
**[Web/API Layer]**
- ↓↑
**[Service Layer]**
- ↓↑
**[Storage Layer]**

##### Component Details

Frontend:
- Static assets (CSS/JS/Templates)
- Multiple UI views
- API clients

Backend Services:
- Feed fetcher and parser
- Content sanitizer
- Media proxy
- Job scheduler
- Authentication handler
- Integration handlers

Database:
- PostgreSQL with direct SQL (no ORM)
- User management
- Feed storage
- Entry storage
- Category management

##### Key Flows to Highlight

- Feed Processing Flow:
- [Feed Sources] → [Fetcher] → [Parser] → [Sanitizer] → [Storage]

- User Request Flow:
- [Browser] → [Web Server] → [Handler] → [Service] → [Database]

##### Important Elements

- Security boundaries
- Authentication flow
- Background job processing
- Content processing pipeline
- Integration points
- Data flow directions

##### Specific Implementation Notes

- Separation between the different API implementations (REST, Fever, Google Reader)
- Worker pool system
- Template engine system
- Localization system
- Static file serving mechanism

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
        MobileApp["Mobile Apps"]
    end

    subgraph WebLayer
        WebServer["Web Server"]:::server
        click WebServer "https://github.com/miniflux/v2/tree/main/internal/http/server"
        Templates["Template Engine"]:::ui
        click Templates "https://github.com/miniflux/v2/tree/main/internal/template"
        Static["Static Assets"]:::ui
        Sessions["Session Management"]:::security
        click Sessions "https://github.com/miniflux/v2/tree/main/internal/ui/session"
    end

    subgraph APILayer
        REST["REST API"]:::api
        click REST "https://github.com/miniflux/v2/tree/main/internal/api"
        Fever["Fever API"]:::api
        GReader["Google Reader API"]:::api
    end

    subgraph ServiceLayer
        Config["Configuration"]:::service
        click Config "https://github.com/miniflux/v2/tree/main/internal/config"
        Auth["Authentication"]:::security
        click Auth "https://github.com/miniflux/v2/tree/main/internal/oauth2"
        FeedProcessor["Feed Processor"]:::service
        click FeedProcessor "https://github.com/miniflux/v2/tree/main/internal/reader"
        Workers["Background Workers"]:::service
        click Workers "https://github.com/miniflux/v2/tree/main/internal/worker"
        Locale["Localization"]:::service
        click Locale "https://github.com/miniflux/v2/tree/main/internal/locale"
        Media["Media Proxy"]:::service
        click Media "https://github.com/miniflux/v2/tree/main/internal/mediaproxy"
        Metrics["Metrics System"]:::service
        click Metrics "https://github.com/miniflux/v2/tree/main/internal/metric"
    end

    subgraph ProcessingLayer
        Fetcher["Feed Fetcher"]
        Parser["Feed Parser"]
        click Parser "https://github.com/miniflux/v2/tree/main/internal/reader/rss"
        Sanitizer["Content Sanitizer"]
        click Sanitizer "https://github.com/miniflux/v2/tree/main/internal/reader/sanitizer"
    end

    subgraph IntegrationLayer
        Integrations["Integration Services"]:::integration
        click Integrations "https://github.com/miniflux/v2/tree/main/internal/integration"
        Pocket["Pocket"]:::external
        Telegram["Telegram"]:::external
        Matrix["Matrix"]:::external
    end

    subgraph StorageLayer
        DB[(PostgreSQL)]:::database
        click DB "https://github.com/miniflux/v2/tree/main/internal/storage"
    end

    Browser --> WebServer
    MobileApp --> REST
    WebServer --> Templates
    WebServer --> Static
    WebServer --> Sessions
    
    WebServer --> REST
    WebServer --> Fever
    WebServer --> GReader
    
    REST --> Auth
    REST --> FeedProcessor
    REST --> Workers
    
    FeedProcessor --> ProcessingLayer
    Fetcher --> Parser
    Parser --> Sanitizer
    Sanitizer --> DB
    
    Workers --> Integrations
    Integrations --> Pocket
    Integrations --> Telegram
    Integrations --> Matrix
    
    FeedProcessor --> DB
    Workers --> DB
    Auth --> DB
    
    %% Styling
    classDef server fill:#1a75ff,color:white
    classDef ui fill:#4d94ff,color:white
    classDef api fill:#0052cc,color:white
    classDef service fill:#3385ff,color:white
    classDef security fill:#ff9933,color:white
    classDef integration fill:#00cc66,color:white
    classDef external fill:#99ff99,color:black
    classDef database fill:#9966ff,color:white

    %% Legend
    subgraph Legend
        L1["Server Component"]:::server
        L2["UI Component"]:::ui
        L3["API Component"]:::api
        L4["Service Component"]:::service
        L5["Security Component"]:::security
        L6["Integration Component"]:::integration
        L7["External Service"]:::external
        L8[(Database)]:::database
    end
```
