# rush-perera/local-fileshare architecture

> Architecture diagram of the GitHub repository rush-perera/local-fileshare, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rush-perera/local-fileshare
- Repository: https://github.com/rush-perera/local-fileshare

## Overview

##### Project type and purpose
- This is a lightweight, single-page web application packaged as a standalone Windows executable.
- It uses Flask (Python microframework) to provide a local file-sharing HTTP server with a mobile-friendly UI and real-time upload progress.

##### File structure
- Top level:
- main.py – Python entrypoint that starts the Flask server and defines upload/download endpoints.
- main.exe – Windows‐packaged version (PyInstaller or similar) of the same Flask app.
- dist/FileShareApp – bundled executable and internal Python/Flask/Tk data for standalone distribution.
- screenshots – documentation assets only.
- No separate “frontend” directory: static HTML/JS/CSS and Flask templates are embedded under the Flask application.
- No external database: files are stored in the host file system (likely an “uploads/” folder managed by main.py).
- Configuration is minimal—defaults are in code, and no cloud or external services are referenced.

##### Key insights from README
- Serves entirely over local Wi-Fi (no Internet).
- Supports multiple file uploads/downloads via REST endpoints.
- Real-time progress bar indicates use of chunked uploads or AJAX.
- Packaged for Windows; distribution includes all dependencies.

##### Main components
a. Clients
- Mobile browser (iPhone, Android)
- Desktop browser (Windows PC, Mac)
b. Flask Server (monolith)
- HTTP API layer (endpoints: /upload, /files, /download)
- Static file server (HTML/CSS/JS assets)
- Upload progress handler (AJAX/WebSocket)
- File storage manager (writes/reads files on local disk)
c. File System
- “uploads/” directory or equivalent
d. Build/Packaging tool (optional, for build‐time view)
- PyInstaller (bundles Python interpreter + dependencies into main.exe)

##### Relationships & interactions
- Clients ↔ HTTP(S) over LAN ↔ Flask server
- Flask server → local disk (writes uploaded files, reads for download)
- Build tool → main.exe (one-time, offline process)

##### Architectural patterns & design principles
- Monolithic MVC-style: Flask routes (controller) serve templates (view) + handle file I/O (model).
- RESTful API for file operations.
- Single process, single port (e.g., 5000) listening on 0.0.0.0 for local network traffic.
- No external dependencies at runtime (self-contained).

##### Relevant technologies & frameworks
- Python 3.x
- Flask 3.1.0
- ItsDangerous, Jinja2/MarkupSafe, Werkzeug as internal Flask dependencies
- PyInstaller (or similar) for packaging
- HTML5/CSS3/JavaScript for front end, possibly using Bootstrap or vanilla JS for progress bar

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build/Packaging"
        PyInstaller["PyInstaller"]:::build
        EntryMain["main.py"]:::build
        ExeTop["main.exe"]:::build
        PackagedExe["dist/FileShareApp/FileShareApp.exe"]:::build
        InternalDeps["_internal/"]:::build
        Screenshots["screenshots/"]:::build
        Readme["README.md"]:::build
    end

    subgraph "Flask Server (Monolith)"
        HTTP["HTTP API Layer"]:::server
        Static["Static Assets (HTML/CSS/JS)"]:::server
        Progress["Upload Progress Handler"]:::server
        FileManager["File Storage Manager"]:::server
    end

    subgraph "Clients"
        ClientMobile["Mobile Browser"]:::client
        ClientDesktop["Desktop Browser"]:::client
    end

    subgraph "Storage"
        Storage["Local File Store (uploads/)"]:::storage
    end

    PyInstaller -->|"builds"|ExeTop
    PyInstaller -->|"bundles"|PackagedExe
    PackagedExe -->|"includes"|InternalDeps

    ExeTop -->|"runs"|HTTP
    HTTP -->|"serves static"|Static
    HTTP -->|"handles progress events"|Progress
    Progress -->|"manages file I/O"|FileManager

    ClientMobile -->|"POST /upload\nGET /files\nGET /download/<file>"|HTTP
    ClientDesktop -->|"POST /upload\nGET /files\nGET /download/<file>"|HTTP

    FileManager -->|"Read/Write"|Storage

    classDef build fill:#EEEEEE,stroke:#333,stroke-width:1px
    classDef server fill:#DFFFE0,stroke:#333,stroke-width:1px
    classDef client fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef storage fill:#FFF4B3,stroke:#333,stroke-width:1px

    click EntryMain "https://github.com/rush-perera/local-fileshare/blob/main/main.py"
    click ExeTop "https://github.com/rush-perera/local-fileshare/blob/main/main.exe"
    click PackagedExe "https://github.com/rush-perera/local-fileshare/blob/main/dist/FileShareApp/FileShareApp.exe"
    click InternalDeps "https://github.com/rush-perera/local-fileshare/tree/main/dist/FileShareApp/_internal/"
    click Screenshots "https://github.com/rush-perera/local-fileshare/tree/main/screenshots/"
    click Readme "https://github.com/rush-perera/local-fileshare/blob/main/README.md"
```
