# manavchaudhary1/telefetch architecture

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

- Interactive diagram: https://gitdiagram.com/manavchaudhary1/telefetch
- Repository: https://github.com/manavchaudhary1/telefetch

## Overview

##### Main Components

a) Client Layer:
- Web Interface (Vaadin-based frontend)
- REST API endpoints

b) Application Layer:
- Controllers
- Services
- Models
- Configuration

c) External Integration Layer:
- Telegram TDLib Integration
- File System Integration

##### Client Interface (Top Layer)
- Web UI (Vaadin Views)
- REST API Controllers

##### Application Core (Middle Layer)
- Controllers Package:
- AuthorizationController
- ChatHistoryController
- DownloadFileController
- GroupIdController
- UserController

- Service Layer:
- ChatHistoryService
- DownloadService
- GroupIdService
- UserService

- Model Layer:
- ChatHistoryTemplate
- ChatResponse
- GroupInfo
- MessageInfo

##### External Integration (Bottom Layer)
- TDLib Integration
- File System Storage

##### Dependencies and Connections
- Web UI → Controllers
- Controllers → Services
- Services → TDLib Integration
- Services → File System
- REST API → Services

##### Technical Details

Annotations for:
- Spring Boot 3.3.0
- TDLib 1.8.29
- Java 21 Runtime
- Required System Libraries (OpenSSL, zlib)

##### Authentication Flow
User → Authorization Controller → TDLib
##### Download Flow
User → Download Controller → Download Service → File System
##### Chat History Flow
User → Chat History Controller → Chat History Service → TDLib

##### Configuration Elements

A section showing:
- API Configuration (api_id, api_hash)
- System Configuration
- Database Encryption

Level of Detail:

- Major components
- Primary data flows
- Integration points
- System boundaries

This system design should clearly show how TeleFetch integrates with Telegram's TDLib while providing both web-based and API-based interfaces for users to interact with the system.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#f1c40f,stroke:#f39c12,color:black
    classDef model fill:#e74c3c,stroke:#c0392b,color:white
    classDef external fill:#e67e22,stroke:#d35400,color:white
    classDef config fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Client Layer
    subgraph ClientLayer["Client Layer"]
        WebUI["Web UI (Vaadin)"]:::frontend
        RestAPI["REST API"]:::api
    end

    %% Controllers Layer
    subgraph ControllerLayer["Controller Layer"]
        AuthController["Authorization Controller"]:::api
        ChatController["Chat History Controller"]:::api
        DownloadController["Download File Controller"]:::api
        GroupController["Group ID Controller"]:::api
        UserController["User Controller"]:::api
    end

    %% Service Layer
    subgraph ServiceLayer["Service Layer"]
        ChatService["Chat History Service"]:::service
        DownloadService["Download Service"]:::service
        GroupService["Group ID Service"]:::service
        UserService["User Service"]:::service
    end

    %% Model Layer
    subgraph ModelLayer["Model Layer"]
        ChatTemplate["Chat History Template"]:::model
        ChatResp["Chat Response"]:::model
        GroupInfo["Group Info"]:::model
        MsgInfo["Message Info"]:::model
    end

    %% External Integration Layer
    subgraph ExternalLayer["External Integration"]
        TDLib["TDLib Integration"]:::external
        FileSystem["File System Storage"]:::external
    end

    %% Configuration
    subgraph ConfigLayer["Configuration"]
        AppConfig["Application Config"]:::config
        SystemConfig["System Config"]:::config
    end

    %% Connections
    WebUI --> AuthController & ChatController & DownloadController & GroupController & UserController
    RestAPI --> AuthController & ChatController & DownloadController & GroupController & UserController
    
    AuthController --> UserService
    ChatController --> ChatService
    DownloadController --> DownloadService
    GroupController --> GroupService
    UserController --> UserService

    ChatService --> TDLib
    DownloadService --> TDLib & FileSystem
    GroupService --> TDLib
    UserService --> TDLib

    %% Click Events
    click WebUI "https://github.com/manavchaudhary1/TeleFetch/tree/master/src/main/java/dev/manav/telefetch/view/"
    click AuthController "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/controller/AuthorizationController.java"
    click ChatController "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/controller/ChatHistoryController.java"
    click DownloadController "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/controller/DownloadFileController.java"
    click GroupController "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/controller/GroupIdController.java"
    click UserController "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/controller/UserController.java"
    click ChatService "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/service/ChatHistoryService.java"
    click DownloadService "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/service/DownloadService.java"
    click GroupService "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/service/GroupIdService.java"
    click UserService "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/service/UserService.java"
    click ChatTemplate "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/model/ChatHistoryTemplate.java"
    click ChatResp "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/model/ChatResponse.java"
    click GroupInfo "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/model/GroupInfo.java"
    click MsgInfo "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/model/MessageInfo.java"
    click AppConfig "https://github.com/manavchaudhary1/TeleFetch/blob/master/src/main/java/dev/manav/telefetch/config/RestTemplateConfig.java"
    click TDLib "https://github.com/manavchaudhary1/TeleFetch/tree/master/libs/dev/voroby/spring-boot-starter-telegram/"

    %% Legend
    subgraph Legend
        Frontend["Frontend"]:::frontend
        APIComponent["API Component"]:::api
        ServiceComponent["Service Component"]:::service
        ModelComponent["Model Component"]:::model
        ExternalComponent["External Integration"]:::external
        ConfigComponent["Configuration"]:::config
    end
```
