# vastsa/filecodebox architecture

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

- Interactive diagram: https://gitdiagram.com/vastsa/filecodebox
- Repository: https://github.com/vastsa/filecodebox

## Overview

##### Project type and purpose
- FileCodeBox is a monolithic full-stack application for anonymous file/text sharing, built with FastAPI (backend) and Vue 3 (frontend).
- The backend serves both the REST API and the compiled Vue frontend assets (in `themes/2023` and `themes/2024`).
- Core features: upload/download via extraction codes, admin panel, pluggable storage (local, S3, OneDrive), rate limiting, expiration.

##### File structure
- Top-level:
- `main.py` – entrypoint to start FastAPI.
- `apps/` – application modules:
– `apps/base/` (upload/download business logic)
– `apps/admin/` (management UI APIs)
- `core/` – shared services: configuration, DB session, storage abstraction, logger, background tasks.
- `themes/` – compiled Vue 3 frontend for two UI themes; includes `index.html` and static assets.
- `docs/` – documentation site (VitePress) – not part of runtime.
- `docker-compose.yml` / `Dockerfile` – container definitions.
- Config: `requirements.txt`, `.env` loaded by `core/settings.py`.
- Data directories: at runtime a `data` volume for SQLite and uploaded files.

##### README for additional insights
- Stack: FastAPI, SQLite (default), Vue3 + ElementUI.
- Features: extraction codes, expiration, admin dashboard, storage engines.
- Deployment: Docker CLI / Compose, or manual `python main.py`.
- Admin panel at `/#/admin`, protected by a password.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    Browser["Browser UI (Vue3)"]:::frontend
    CLI["CLI (Optional)"]:::frontend

    %% Docker Container Boundary
    subgraph "Docker Container" 
        direction TB
        FastAPI["FastAPI App\n(API & Static Server)"]:::backend

        subgraph "Static Frontend Assets"
            direction TB
            Theme2023["Theme 2023\n(static files)"]:::frontend
            Theme2024["Theme 2024\n(static files)"]:::frontend
        end

        subgraph "Application Modules"
            direction TB
            Base["Base Module\n(apps/base)"]:::module
            Admin["Admin Module\n(apps/admin)"]:::module
        end

        subgraph "Core Services"
            direction TB
            DBService["Database Service\n(core/database.py)"]:::datastore
            StorageService["Storage Service\n(core/storage.py)"]:::datastore
            Tasks["Background Tasks\n(core/tasks.py)"]:::tasks
            Settings["Settings\n(core/settings.py)"]:::config
            Logger["Logger\n(core/logger.py)"]:::config
            Response["Responses\n(core/response.py)"]:::config
            Utils["Utils\n(core/utils.py)"]:::config
        end

        DockerfileDef["Dockerfile"]:::infra
        Compose["docker-compose.yml"]:::infra
        Requirements["requirements.txt"]:::infra
    end

    %% Data Stores (Volume)
    subgraph "Data Volume"
        direction TB
        SQLite["SQLite DB File"]:::datastore
        FileStorage["File Storage Volume"]:::datastore
    end

    %% External Services
    subgraph "External Storage" 
        style ExternalStorage stroke-dasharray: 5 5
        S3["S3-Compatible Storage"]:::external
        OneDrive["OneDrive Storage"]:::external
    end

    %% Interactions
    Browser -->|HTTP Request| FastAPI
    CLI -->|HTTP Request| FastAPI
    FastAPI -->|serves| Theme2023
    FastAPI -->|serves| Theme2024
    FastAPI -->|routes to| Base
    FastAPI -->|routes to| Admin
    Base -->|uses| DBService
    Base -->|uses| StorageService
    Admin -->|uses| DBService
    Admin -->|uses| StorageService
    Tasks -->|cleanup| DBService
    Tasks -->|cleanup| FileStorage
    DBService -->|stores metadata| SQLite
    StorageService -->|reads/writes files| FileStorage
    StorageService -->|optional cloud| S3
    StorageService -->|optional cloud| OneDrive
    FastAPI -->|mounts| FileStorage

    %% Click Events
    click Theme2023 "https://github.com/vastsa/filecodebox/blob/master/themes/2023/index.html"
    click Theme2024 "https://github.com/vastsa/filecodebox/blob/master/themes/2024/index.html"
    click FastAPI "https://github.com/vastsa/filecodebox/blob/master/main.py"
    click Base "https://github.com/vastsa/filecodebox/blob/master/apps/base/views.py"
    click Admin "https://github.com/vastsa/filecodebox/blob/master/apps/admin/views.py"
    click DBService "https://github.com/vastsa/filecodebox/blob/master/core/database.py"
    click StorageService "https://github.com/vastsa/filecodebox/blob/master/core/storage.py"
    click Tasks "https://github.com/vastsa/filecodebox/blob/master/core/tasks.py"
    click Settings "https://github.com/vastsa/filecodebox/blob/master/core/settings.py"
    click Logger "https://github.com/vastsa/filecodebox/blob/master/core/logger.py"
    click Response "https://github.com/vastsa/filecodebox/blob/master/core/response.py"
    click Utils "https://github.com/vastsa/filecodebox/blob/master/core/utils.py"
    click DockerfileDef "https://github.com/vastsa/filecodebox/tree/master/Dockerfile"
    click Compose "https://github.com/vastsa/filecodebox/blob/master/docker-compose.yml"
    click Requirements "https://github.com/vastsa/filecodebox/blob/master/requirements.txt"

    %% Styles
    classDef frontend fill:#D6E9FE,stroke:#3178C6;
    classDef backend fill:#E8F1FF,stroke:#1F4E79;
    classDef module fill:#F0F8E8,stroke:#2D8F3F;
    classDef datastore fill:#E8F5E9,stroke:#387C3C;
    classDef tasks fill:#FFEFD6,stroke:#E78A00;
    classDef config fill:#F5F5F5,stroke:#AAAAAA;
    classDef infra fill:#F0F0F0,stroke:#666666;
    classDef external fill:#F5F5F5,stroke-dasharray: 5 5,stroke:#888888;
```
