# 84adam/arkfile architecture

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

- Interactive diagram: https://gitdiagram.com/84adam/arkfile
- Repository: https://github.com/84adam/arkfile

## Overview

##### Component Relationships

A. Primary Data Flows:
- Client → WASM Encryption → Server → B2 Storage
- Server → SQLite (metadata storage)

- Client → Server → B2 Storage → Client
- Server → SQLite (metadata retrieval)

- Client → JWT Auth → Server

##### External Services Integration
- Caddy Web Server (as reverse proxy)
- TLS termination point
- Connection to main server

##### Security Layers
- Red border: Client-side encryption zone
- Blue border: TLS protection zone
- Green border: Server-side security measures

##### Technical Details
Annotations for:
- WASM compilation process
- JWT token flow
- Encryption/decryption points
- Database schema reference
- API endpoints

##### Specific Implementation Notes
Callouts for:
- Environment variables configuration
- File size limitations
- Authentication mechanisms
- Error handling paths

##### Architectural Patterns
Highlight:
- Clean architecture boundaries
- Separation of concerns
- Security layers
- Stateless design

- Rectangles: Services and applications
- Hexagons: Security components
- Clouds: External services

- Using clear hierarchical layout
- Grouping related components
- Maintaining consistent spacing
- Adding brief explanatory notes

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        WI["Web Interface"]:::frontend
        JS["JavaScript Runtime"]:::frontend
        WASM["WebAssembly Module"]:::frontend
        WI --> JS
        JS --> WASM
    end

    subgraph Server
        EHS["Echo HTTP Server"]:::server
        JWT["JWT Authentication"]:::security
        RH["Request Handlers"]:::server
        LS["Logging System"]:::server
        CS["Configuration Service"]:::server
        
        EHS --> JWT
        JWT --> RH
        RH --> LS
        RH --> CS
    end

    subgraph "Storage Layer"
        DB[(SQLite Database)]:::storage
        B2[("Backblaze B2")]:::storage
    end

    subgraph "External Services"
        CRP["Caddy Reverse Proxy"]:::proxy
    end

    %% Data Flows
    WI --> CRP
    CRP --> EHS
    RH --> DB
    RH --> B2
    
    %% Security Flow
    WASM -- "Encrypted Data" --> RH
    B2 -- "Encrypted Data" --> WASM

    %% Component Mappings
    click WI "https://github.com/84adam/arkfile/tree/main/client/static/"
    click JS "https://github.com/84adam/arkfile/blob/main/client/static/js/app.js"
    click WASM "https://github.com/84adam/arkfile/blob/main/client/main.go"
    click JWT "https://github.com/84adam/arkfile/blob/main/auth/jwt.go"
    click RH "https://github.com/84adam/arkfile/blob/main/handlers/handlers.go"
    click LS "https://github.com/84adam/arkfile/blob/main/logging/logging.go"
    click CS "https://github.com/84adam/arkfile/blob/main/config/config.go"
    click DB "https://github.com/84adam/arkfile/blob/main/database/database.go"
    click B2 "https://github.com/84adam/arkfile/blob/main/storage/minio.go"
    click CRP "https://github.com/84adam/arkfile/tree/main/Caddyfile"

    %% Styles
    classDef frontend fill:#f9f,stroke:#333,stroke-width:2px
    classDef server fill:#bbf,stroke:#333,stroke-width:2px
    classDef security fill:#ff9,stroke:#333,stroke-width:2px
    classDef storage fill:#9f9,stroke:#333,stroke-width:2px
    classDef proxy fill:#f99,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        S[Server]:::server
        SEC[Security]:::security
        ST[Storage]:::storage
        P[Proxy]:::proxy
    end
```
