# codemini100/mini-dropbox architecture

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

- Interactive diagram: https://gitdiagram.com/codemini100/mini-dropbox
- Repository: https://github.com/codemini100/mini-dropbox

## Overview

##### Main Components
- Client/Consumer: This represents any API consumer (e.g., a mobile/web client, API testing tool like Postman). Although there is no separate “frontend” directory, the client is abstracted by the REST API endpoints.
- Web Server/Application Layer:
- The main entry point is app.py (and demo_app.py for demo purposes) which ties everything together using Flask.
- This layer registers Flask Blueprints for each major module:
▫️ /auth for user authentication
▫️ /files for file management (upload, download, listing)
▫️ /sync for file versioning and syncing
▫️ /share for file sharing
- Service/Controller Layers:
- Each module (auth, files, sync, sharing) splits logic into a controller and a service. Controllers (e.g., auth_controller.py, file_controller.py) define the API endpoints while Services (e.g., auth_service.py, file_service.py, etc.) handle business logic.
- Config & Utility Components:
- config.py holds system settings like database URI, storage paths, and secret keys.
- The utils directory includes common functionalities such as logging (logger.py) and authentication helpers (auth_helpers.py).
- Database and Storage (External Dependencies):
- Although only pseudo-code is provided for DB operations, consider a database that stores user records, file metadata, sync version info, and share tokens.
- A file storage service or local file system is used to store the actual files.

##### Relationships and Interactions
- The Client sends HTTP requests (e.g., signup, login, file upload) to the Flask server.
- The Flask server routes requests to the appropriate Blueprint (auth, files, sync, sharing).
- Each Controller calls its corresponding Service to process business logic:
- For user management, the auth module hashes/verifies passwords.
- For file management, the files module handles saving a file and returning its metadata.
- The sync module provides endpoints for tracking file updates and resolving conflicts.
- The sharing module creates and validates share links.
- The Config module is used by different services to retrieve environment-specific settings.
- Utility components are accessed where needed to log events or assist with user authentication.

##### Fundamental Architectural Patterns and Design Principles
- Modularity: The project is split into discrete modules (auth, files, sync, sharing) that communicate through well-defined APIs.
- Separation of Concerns: Controllers handle HTTP request/response logic, while services encapsulate business rules and interactions with external systems (DB, file storage).
- Blueprint Method (in Flask): This pattern is used to keep the codebase scalable. Each major functionality is isolated in its own blueprint.
- Reusability: Utility components and configuration settings are centralized so that changes in one area (like switching the storage path) propagate throughout the app.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Client("Client (API Consumer)"):::client

    %% Flask Web Server Layer
    Server("Flask Web Server"):::server
    Client -->|"HTTP_request"| Server

    %% Entry Points inside Web Server
    AppPY("app.py"):::app
    DemoApp("demo_app.py"):::app
    Server -->|"routes_to"| AppPY
    Server -->|"demo_routes_to"| DemoApp

    %% Modules: Controllers and Services
    %% Auth Module
    AuthController("Auth Controller"):::controller
    AuthService("Auth Service"):::service
    AppPY -->|"handles_/auth"| AuthController
    AuthController -->|"calls"| AuthService

    %% Files Module
    FileController("File Controller"):::controller
    FileService("File Service"):::service
    AppPY -->|"handles_/files"| FileController
    FileController -->|"calls"| FileService

    %% Sync Module
    SyncController("Sync Controller"):::controller
    SyncService("Sync Service"):::service
    AppPY -->|"handles_/sync"| SyncController
    SyncController -->|"calls"| SyncService

    %% Sharing Module
    ShareController("Share Controller"):::controller
    ShareService("Share Service"):::service
    AppPY -->|"handles_/share"| ShareController
    ShareController -->|"calls"| ShareService

    %% Configuration & Utility Components
    Config("config.py"):::config
    UtilAuth("Auth Helpers"):::utils
    UtilLogger("Logger"):::utils

    %% Services using Config & Utils
    AuthService -->|"uses"| Config
    FileService -->|"uses"| Config
    SyncService -->|"uses"| Config
    ShareService -->|"uses"| Config

    AuthService -->|"utilizes"| UtilAuth
    FileService -->|"utilizes"| UtilAuth
    SyncService -->|"utilizes"| UtilAuth
    ShareService -->|"utilizes"| UtilAuth

    AuthService -->|"logs_with"| UtilLogger
    FileService -->|"logs_with"| UtilLogger
    SyncService -->|"logs_with"| UtilLogger
    ShareService -->|"logs_with"| UtilLogger

    %% External Dependencies
    Database("Database"):::db
    FileStorage("File Storage"):::storage

    AuthService -->|"DB_ops"| Database
    FileService -->|"file_ops"| FileStorage
    SyncService -->|"DB_ops"| Database
    ShareService -->|"DB_ops"| Database

    %% Demo Environment Detail
    Demo("Demo Endpoints"):::demo
    Server -->|"demo"| Demo
    Demo -->|"triggers"| DemoApp

    %% Click Events
    click AppPY "https://github.com/codemini100/mini-dropbox/blob/main/app.py"
    click DemoApp "https://github.com/codemini100/mini-dropbox/blob/main/examples/basic_sync_demo/demo_app.py"
    click AuthController "https://github.com/codemini100/mini-dropbox/blob/main/auth/auth_controller.py"
    click AuthService "https://github.com/codemini100/mini-dropbox/blob/main/auth/auth_service.py"
    click FileController "https://github.com/codemini100/mini-dropbox/blob/main/files/file_controller.py"
    click FileService "https://github.com/codemini100/mini-dropbox/blob/main/files/file_service.py"
    click SyncController "https://github.com/codemini100/mini-dropbox/blob/main/sync/sync_controller.py"
    click SyncService "https://github.com/codemini100/mini-dropbox/blob/main/sync/sync_service.py"
    click ShareController "https://github.com/codemini100/mini-dropbox/blob/main/sharing/share_controller.py"
    click ShareService "https://github.com/codemini100/mini-dropbox/blob/main/sharing/share_service.py"
    click Config "https://github.com/codemini100/mini-dropbox/blob/main/config.py"
    click UtilAuth "https://github.com/codemini100/mini-dropbox/blob/main/utils/auth_helpers.py"
    click UtilLogger "https://github.com/codemini100/mini-dropbox/blob/main/utils/logger.py"

    %% Node Styles
    classDef client fill:#AED6F1,stroke:#2980B9,stroke-width:2px;
    classDef server fill:#A9DFBF,stroke:#27AE60,stroke-width:2px;
    classDef app fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef controller fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef service fill:#F5CBA7,stroke:#D35400,stroke-width:2px;
    classDef config fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px;
    classDef utils fill:#AED6F1,stroke:#5DADE2,stroke-width:2px;
    classDef db fill:#ECF0F1,stroke:#BDC3C7,stroke-width:2px;
    classDef storage fill:#ABEBC6,stroke:#28B463,stroke-width:2px;
    classDef demo fill:#FADBD8,stroke:#E74C3C,stroke-width:2px;
```
