# 0d9e-tech/archiiv architecture

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

- Interactive diagram: https://gitdiagram.com/0d9e-tech/archiiv
- Repository: https://github.com/0d9e-tech/archiiv

## Overview

##### Main Components Identification

a) API Layer
- Represented by `endpoints.go` and `routes.go`
- Entry point for all client interactions

b) Authentication System
- Evidenced by `auth.go` and `user.go`
- Handles user management and permissions

c) File System Management
- Located in the `fs` package (`fs/fs.go`, `fs/filemeta.go`)
- Handles media storage operations

d) Cryptographic Services
- Shown by `crypto.go`
- Handles security-related operations

e) Identity Management
- Found in the `id` package (`id/id.go`)
- Manages unique identifiers

**[Client Applications]**
- ↓
**[Load Balancer/Reverse Proxy]***
- ↓
**[API Gateway Layer]**
- ↓
**┌─────────────────────────────┐**
- Archív Core         │
- ┤
- ┌─────┐    ┌──────────┐   │
- Auth │←→  │User Mgmt │   │
- ┘    └──────────┘   │
- ↓                     │
- ┌─────────────────┐       │
- Request Router   │       │
- ┘       │
- ↓                     │
- ┌─────────────────┐       │
- File System Mgmt │       │
- ┘       │
- ↓                     │
- ┌─────────────────┐       │
- Crypto Services  │       │
- ┘       │
- ┘
- ↓
**[Physical Storage Layer]**

##### Component Interactions

- Double lines: High-bandwidth operations (like file transfers)

##### Technical Details

Annotations for:
- Go-specific implementation details
- Authentication flow
- File storage patterns
- Cryptographic operations
- API endpoints grouping

##### User permission model

Remember to include notes about:
- Scalability considerations (from back_of_the_envelope_calculations.md)
- Security implementation details
- Storage backend flexibility
- Authentication flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        Client["Client Applications"]
        LB["Load Balancer/Reverse Proxy"]:::optional
    end

    subgraph API
        Gateway["API Gateway"]:::api
        Router["Request Router"]:::router
    end

    subgraph Core["Archív Core"]
        Main["Main Application"]:::core
        Auth["Authentication System"]:::auth
        UserMgmt["User Management"]:::auth
        FSMgmt["File System Management"]:::fs
        Crypto["Cryptographic Services"]:::security
        Identity["Identity Management"]:::core
        Encoding["Data Encoding"]:::core
    end

    subgraph Storage
        Physical["Physical Storage Layer"]:::storage
    end

    %% Connections
    Client --> LB
    LB --> Gateway
    Gateway --> Router
    Router --> Auth
    Router --> FSMgmt
    Auth <--> UserMgmt
    FSMgmt --> Crypto
    FSMgmt --> Identity
    FSMgmt --> Encoding
    FSMgmt --> Physical

    %% Click Events
    click Router "https://github.com/0d9e-tech/archiiv/blob/amogus/routes.go"
    click Gateway "https://github.com/0d9e-tech/archiiv/blob/amogus/endpoints.go"
    click Auth "https://github.com/0d9e-tech/archiiv/blob/amogus/auth.go"
    click UserMgmt "https://github.com/0d9e-tech/archiiv/blob/amogus/user.go"
    click FSMgmt "https://github.com/0d9e-tech/archiiv/blob/amogus/fs/fs.go"
    click Crypto "https://github.com/0d9e-tech/archiiv/blob/amogus/crypto.go"
    click Identity "https://github.com/0d9e-tech/archiiv/blob/amogus/id/id.go"
    click Main "https://github.com/0d9e-tech/archiiv/blob/amogus/main.go"
    click Encoding "https://github.com/0d9e-tech/archiiv/blob/amogus/encoding.go"

    %% Styling
    classDef api fill:#2374ab
    classDef router fill:#2374ab,stroke:#333
    classDef auth fill:#57a773
    classDef core fill:#ffc857
    classDef security fill:#ef476f
    classDef storage fill:#808080
    classDef fs fill:#f7d794
    classDef optional stroke-dasharray: 5 5

    %% Legend
    subgraph Legend
        API_L["API Components"]:::api
        Auth_L["Authentication"]:::auth
        Core_L["Core Components"]:::core
        Security_L["Security"]:::security
        Storage_L["Storage"]:::storage
        FS_L["File System"]:::fs
        Optional_L["Optional Component"]:::optional
    end
```
