# yoni-tad/fastdrop architecture

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

- Interactive diagram: https://gitdiagram.com/yoni-tad/fastdrop
- Repository: https://github.com/yoni-tad/fastdrop

## Overview

##### Project Type and Purpose
- FastDrop is a web-based file sharing and upload service.
- It is a full-stack application with a clear separation of backend API logic and a static frontend.
- The main goal is to provide quick file uploads, unique download links, and timed file expiration.

##### File Structure
- Top-level files and directories include:
- server.js: Entry point for the Node.js server.
- controller: Contains logic for handling file-related requests (e.g., file_controller.js).
- model: Likely defines the file data schema (e.g., file_model.js) using Mongoose.
- routes: Handles application routing (e.g., file_route.js) for API endpoints.
- middlewares: Contains middleware for file uploads (file_upload.js) using Multer.
- cron: Contains scheduled tasks like file_clean.js for auto-deleting expired files.
- public: Houses static assets including index.html, CSS/JS files, and images.
- Configuration and dependency files (package.json, .gitignore) are set up properly.

- These directories imply a layered MVC-like separation where controllers handle business logic, models manage the database interactions, and routes define the endpoints.

##### Elements
- Labels: Clearly identify components such as “Frontend (public assets)”, “Express Server (server.js)”, “File Controller”, “Routes”, “File Middleware (Multer)”, “MongoDB”, “Cron Jobs”, etc.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend Layer"
        FE("Frontend (Static Assets)"):::frontend
    end

    %% Backend API
    subgraph "Backend API"
        SE("Express Server (server.js)"):::backend
        RT("Routes (file_route.js)"):::backend
        MU("File Upload Middleware"):::middleware
        FC("File Controller"):::backend
        FM("File Model"):::backend
    end

    %% Supporting Services
    subgraph "Supporting Services"
        CJ("Cron Job (file_clean.js)"):::cron
        DB("MongoDB"):::database
        FS("Local File Storage"):::storage
    end

    %% Data Flow
    FE -->|"FileUploadRequest"| SE
    SE -->|"RouteRequest"| RT
    RT -->|"InvokeMiddleware"| MU
    MU -->|"ProcessFile"| FC
    FC -->|"SaveMetadata"| FM
    FC -->|"StoreFile"| FS
    FM -->|"StoreData"| DB
    CJ -->|"CleanupExpired"| FM
    FM -->|"DeleteFile"| FS

    %% Click Events
    click FE "https://github.com/yoni-tad/fastdrop/tree/main/public/"
    click SE "https://github.com/yoni-tad/fastdrop/blob/main/server.js"
    click RT "https://github.com/yoni-tad/fastdrop/blob/main/routes/file_route.js"
    click MU "https://github.com/yoni-tad/fastdrop/blob/main/middlewares/file_upload.js"
    click FC "https://github.com/yoni-tad/fastdrop/blob/main/controller/file_controller.js"
    click FM "https://github.com/yoni-tad/fastdrop/blob/main/model/file_model.js"
    click CJ "https://github.com/yoni-tad/fastdrop/blob/main/cron/file_clean.js"

    %% Styles
    classDef frontend fill:#FFA500,stroke:#333,stroke-width:2px;
    classDef backend fill:#87CEFA,stroke:#333,stroke-width:2px;
    classDef middleware fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef cron fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef database fill:#98FB98,stroke:#333,stroke-width:2px;
    classDef storage fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
