# floriannicolas/yeeet architecture

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

- Interactive diagram: https://gitdiagram.com/floriannicolas/yeeet
- Repository: https://github.com/floriannicolas/yeeet

## Overview

##### Project Overview
- YEEET is a secure file sharing platform offering user authentication, chunked file uploads, real-time progress tracking, and secure file downloads.
- It features a three-pronged architecture: a backend API server, a web client built in Next.js (React), and a desktop client using Tauri (Rust + React).

##### Main Components
a. Backend API Server:
- Based on Node.js with Express and TypeScript.
- Components include configuration, database connectivity (PostgreSQL with Drizzle ORM), authentication middleware, API routes (auth, files, user, cron jobs), background tasks, and services (email, storage, user-storage).
- Real-time communications via Socket.IO.
- Security features like session management (express-session) and bcrypt for password hashing.
b. Web Client (Next.js Application):
- Built with Next.js and React along with TypeScript.
- Organized into app routes, pages (login, register, forgot-password, reset-password), and components (dashboard, UI elements).
- Communicates with the backend for API calls (using Axios) and receives real-time updates.
c. Desktop Application:
- Built using Tauri (Rust for the backend, React with Vite for the frontend).
- Consists of a Tauri configuration and Rust source files (e.g., main.rs, lib.rs, tray, screenshot_watcher, etc.) along with a React-based UI structured similarly to the web client.
d. Database:
- A PostgreSQL database, with migrations and schemas defined in the backend.
e. External & Optional Services:
- File storage (local "uploads" folder or optionally S3 if enabled by configuration).
- Environmental configuration and secrets loaded via .env files in each component.

##### Relationships & Interactions
- Both the Next.js web client and the Tauri desktop client communicate with the Backend API Server via HTTP/WebSocket channels.
- The backend interacts with the PostgreSQL database for storage and retrieves or stores file metadata.
- The Desktop and Web clients receive real-time progress updates for file uploads via Socket.IO.
- Authentication flow where the clients send login/register requests to the Backend, which handles session management and token issuance.
- File upload processing: Client → Backend API → Storage (local file system or S3) with progress tracking.

##### Architectural Patterns & Design Principles
- Separation of concerns: Clearly delineated frontend, backend, and desktop client components.
- Modular design: Use of middleware in the backend (authentication, logging, etc.), service layers, and clearly separated routes.
- Reusability: Shared libraries and utilities across both clients.
- Security: Emphasize the session-based authentication, password hashing, and secure file downloads via unique tokens.
- Real-time communication: Represent Socket.IO communications as a separate bidirectional channel between clients and backend.

- Each major component is clearly marked: Backend API Server, Next.js Web Client, Tauri Desktop Application, Database (PostgreSQL), and External Storage (optional S3).
- Labels for protocols (HTTP API, WebSocket) and specific technologies (e.g., Express, Socket.IO, Tauri, Next.js, PostgreSQL).
- Annotations or notes on authentication and security measures.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Backend API Server Subgraph
    subgraph "Backend API Server"
        BE["Backend API Server\n(Node.js, Express, TS)"]:::backend
        BE_Config["Configuration"]:::backend
        BE_DB_Config["Database Connectivity"]:::backend
        BE_Auth["Authentication Middleware"]:::backend
        BE_Routes["API Routes"]:::backend
        BE_Tasks["Background Tasks"]:::backend
        BE_Services["Services"]:::backend
        BE_Socket["Socket.IO Integration"]:::backend
    end

    %% Next.js Web Client Subgraph
    subgraph "Next.js Web Client"
        NW["Next.js Web Client"]:::next
        NW_AppRoutes["App Routes"]:::next
        NW_Login["Login Page"]:::next
        NW_Register["Register Page"]:::next
        NW_Forgot["Forgot Password"]:::next
        NW_Reset["Reset Password"]:::next
        NW_Components["UI Components"]:::next
    end

    %% Tauri Desktop Application Subgraph
    subgraph "Tauri Desktop Application"
        TA["Tauri Desktop Application"]:::tauri
        TA_Config["Tauri Config"]:::tauri
        TA_Main["Rust Main"]:::tauri
        TA_Lib["Rust Lib"]:::tauri
        TA_Screen["Screenshot Watcher"]:::tauri
        TA_Tray["Tray"]:::tauri
        TA_React["React UI"]:::tauri
    end

    %% Database Subgraph
    subgraph "Database"
        DB["PostgreSQL Database"]:::database
        DB_Schema["Migrations & Schema"]:::database
    end

    %% External Storage Node
    subgraph "External Storage"
        ES["File Storage (Local/S3)"]:::external
    end

    %% Relationships between Clients and Backend
    NW -->|"HTTP/WebSocket"| BE
    TA -->|"HTTP/WebSocket"| BE

    %% Backend Interaction with Database and Storage
    BE -->|"SQL"| DB
    BE -->|"FileUpload"| ES

    %% Internal Backend Components
    BE --> BE_Config
    BE --> BE_DB_Config
    BE --> BE_Auth
    BE --> BE_Routes
    BE --> BE_Tasks
    BE --> BE_Services
    BE --> BE_Socket

    %% Next.js Internal Flow
    NW --> NW_AppRoutes
    NW_AppRoutes --> NW_Login
    NW_AppRoutes --> NW_Register
    NW_AppRoutes --> NW_Forgot
    NW_AppRoutes --> NW_Reset
    NW --> NW_Components

    %% Tauri Internal Flow
    TA --> TA_Config
    TA --> TA_Main
    TA --> TA_Lib
    TA --> TA_Screen
    TA --> TA_Tray
    TA --> TA_React

    %% Database Internal Flow
    DB --> DB_Schema

    %% Click Events for Backend API Server
    click BE "https://github.com/floriannicolas/yeeet/tree/main/backend/src"
    click BE_Config "https://github.com/floriannicolas/yeeet/tree/main/backend/src/config"
    click BE_DB_Config "https://github.com/floriannicolas/yeeet/blob/main/backend/src/config/database.ts"
    click BE_Auth "https://github.com/floriannicolas/yeeet/blob/main/backend/src/middleware/auth.ts"
    click BE_Routes "https://github.com/floriannicolas/yeeet/tree/main/backend/src/routes"
    click BE_Tasks "https://github.com/floriannicolas/yeeet/tree/main/backend/src/tasks"
    click BE_Services "https://github.com/floriannicolas/yeeet/tree/main/backend/src/services"
    click BE_Socket "https://github.com/floriannicolas/yeeet/blob/main/backend/src/server.ts"

    %% Click Events for Next.js Web Client
    click NW "https://github.com/floriannicolas/yeeet/tree/main/next-client"
    click NW_AppRoutes "https://github.com/floriannicolas/yeeet/tree/main/next-client/src/app"
    click NW_Login "https://github.com/floriannicolas/yeeet/blob/main/next-client/src/app/login/page.tsx"
    click NW_Register "https://github.com/floriannicolas/yeeet/blob/main/next-client/src/app/register/page.tsx"
    click NW_Forgot "https://github.com/floriannicolas/yeeet/blob/main/next-client/src/app/forgot-password/page.tsx"
    click NW_Reset "https://github.com/floriannicolas/yeeet/blob/main/next-client/src/app/reset-password/[token]/page.tsx"
    click NW_Components "https://github.com/floriannicolas/yeeet/tree/main/next-client/src/components"

    %% Click Events for Tauri Desktop Application
    click TA "https://github.com/floriannicolas/yeeet/tree/main/app/src-tauri"
    click TA_Config "https://github.com/floriannicolas/yeeet/blob/main/app/src-tauri/tauri.conf.json"
    click TA_Main "https://github.com/floriannicolas/yeeet/blob/main/app/src-tauri/src/main.rs"
    click TA_Lib "https://github.com/floriannicolas/yeeet/blob/main/app/src-tauri/src/lib.rs"
    click TA_Screen "https://github.com/floriannicolas/yeeet/blob/main/app/src-tauri/src/screenshot_watcher.rs"
    click TA_Tray "https://github.com/floriannicolas/yeeet/blob/main/app/src-tauri/src/tray.rs"
    click TA_React "https://github.com/floriannicolas/yeeet/blob/main/app/src/App.tsx"

    %% Click Event for Database
    click DB "https://github.com/floriannicolas/yeeet/tree/main/backend/src/db"

    %% Styles
    classDef backend fill:#F1948A,stroke:#333,stroke-width:2px;
    classDef next fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef tauri fill:#C39BD3,stroke:#333,stroke-width:2px;
    classDef database fill:#F5B7B1,stroke:#333,stroke-width:2px;
    classDef external fill:#82E0AA,stroke:#333,stroke-width:2px;
```
