# mrtracker-new/invisiovault architecture

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

- Interactive diagram: https://gitdiagram.com/mrtracker-new/invisiovault
- Repository: https://github.com/mrtracker-new/invisiovault

## Overview

##### Project Type and Purpose
- This is a two-tier full-stack application. The frontend is a React single-page application (SPA). The backend is a Flask REST API that implements steganography and polyglot file utilities.
- Purpose: Let users hide arbitrary files or text inside images (steganography mode) or create dual-format “polyglot” files (carrier + hidden payload) with optional password encryption.

##### File Structure
- Top-level directories:
- backend/ – Flask application
- frontend/ – React SPA
- backend/ contains:
- api/routes.py – REST endpoint definitions
- utils/ – core steganography, polyglot, validation, and cleanup logic
- config/settings.py – environment and CORS configuration
- app.py – application factory and entry point
- frontend/ contains:
- src/components – HideFile, ExtractFile, Polyglot components
- config/api.js – Axios base URL
- main.jsx & App.jsx – React entry and router
- Deployment files:
- Procfile, railway.json for backend
- vercel.json for frontend

##### Extract Additional Architectural Insights from README
- RESTful API design with endpoints for hide, extract, download, health check
- Two main modes of operation: steganography and polyglot
- Temporary file storage (uploads directory) and automatic cleanup
- Security features: CORS, file type/size validation, encryption modules (Fernet, AES-256)

##### Main Components
a. Frontend (React SPA)
- UI components for HideFile, ExtractFile, Polyglot
- HTTP client (Axios) and routing (React Router via App.jsx)
- Environment config (VITE_API_URL)
b. Backend (Flask REST API)
- API Layer (routes.py)
- Service Layer (utils steganography, polyglot, validators, cleanup)
- Configuration Layer (settings.py, .env)
- Temporary File Storage (uploads folder)
c. External Interfaces
- Browser (user)
- HTTP/HTTPS between frontend and backend
d. Data Storage & Flow
- Incoming file payload → backend → utility modules → generated file kept in uploads → returned to frontend → user downloads
e. Security & Support Services
- Encryption libraries (Cryptography, Pyzipper)
- CORS module
- Zlib for compression

##### Relationships and Interactions
- Browser/React SPA sends REST calls (POST /api/hide, POST /api/extract, GET /api/download/{id})
- Flask API receives request, invokes utility module, writes temp file, returns a download token or file stream
- Cleanup module removes temp files after a configured time
- React receives response, triggers file download or displays extracted text

##### Architectural Patterns & Design Principles
- Separation of concerns: UI vs. API vs. core logic
- Modular utility libraries (each stego/polyglot step isolated)
- Stateless HTTP endpoints (all state in temporary files)
- Environment-based configuration (12-factor)
- Security first: validation, encryption, cleanup

##### Details
- Every module and external dependency (e.g., Vite, Flask-CORS) is visible

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    UserBrowser((User/Browser)):::user

    %% Frontend Layer
    subgraph "React SPA" 
        style ReactSPA fill:none,stroke:none
        ReactSPA["React SPA"]:::frontend
        HideFile["HideFile UI"]:::frontend
        ExtractFile["ExtractFile UI"]:::frontend
        Polyglot["Polyglot UI"]:::frontend
        AxiosClient["Axios HTTP Client"]:::frontend
        Router["Main Entry & Router"]:::frontend
        EnvFrontend[".env.example"]:::config
    end

    UserBrowser -->|"Interacts with UI"| ReactSPA
    ReactSPA -->|"POST /api/hide\nPOST /api/extract\nGET /api/download/{id}"| FlaskAPI

    %% Backend/API Layer
    subgraph "Flask REST API" 
        FlaskAPI["Flask REST API"]:::backend
        subgraph "API Layer"
            Routes["API Routes\n(routes.py)"]:::backend
            ConfigBE["Config & CORS\n(settings.py)"]:::backend
        end
        subgraph "Service Layer"
            Stego["Steganography Module"]:::utils
            Poly["Polyglot Module"]:::utils
            Validator["Validators"]:::utils
            CleanupUtil["Cleanup Utility"]:::utils
        end
    end

    FlaskAPI -->|invokes| Routes
    FlaskAPI -->|uses| ConfigBE
    Routes -->|calls| Stego
    Routes -->|calls| Poly
    Routes -->|validates via| Validator
    Routes -->|schedules| CleanupUtil

    %% Storage & Cleanup
    Stego -->|writes temp file| Storage
    Poly -->|writes temp file| Storage
    Storage[(Uploads Storage)]:::storage
    CleanupProcess((Cleanup Daemon)):::process
    CleanupProcess -->|removes old files| Storage

    %% Response Flow
    FlaskAPI -->|"Returns file stream or token"| ReactSPA
    ReactSPA -->|Trigger download| UserBrowser

    %% Security & Compression Annotations
    Stego -.-> Cryptography
    Stego -.-> Pyzipper
    Stego -.-> Zlib

    Cryptography["Cryptography\n(Fernet/AES-256)"]:::annotation
    Pyzipper["Pyzipper\n(Zip Encryption)"]:::annotation
    Zlib["Zlib\n(Compression)"]:::annotation

    %% Click Events
    click ReactSPA "https://github.com/mrtracker-new/invisiovault/tree/master/frontend/src"
    click HideFile "https://github.com/mrtracker-new/invisiovault/blob/master/frontend/src/components/HideFile.jsx"
    click ExtractFile "https://github.com/mrtracker-new/invisiovault/blob/master/frontend/src/components/ExtractFile.jsx"
    click Polyglot "https://github.com/mrtracker-new/invisiovault/blob/master/frontend/src/components/Polyglot.jsx"
    click AxiosClient "https://github.com/mrtracker-new/invisiovault/blob/master/frontend/src/config/api.js"
    click Router "https://github.com/mrtracker-new/invisiovault/blob/master/frontend/src/main.jsx"
    click EnvFrontend "https://github.com/mrtracker-new/invisiovault/blob/master/frontend/.env.example"
    click FlaskAPI "https://github.com/mrtracker-new/invisiovault/blob/master/backend/app.py"
    click Routes "https://github.com/mrtracker-new/invisiovault/blob/master/backend/api/routes.py"
    click ConfigBE "https://github.com/mrtracker-new/invisiovault/blob/master/backend/config/settings.py"
    click Stego "https://github.com/mrtracker-new/invisiovault/blob/master/backend/utils/steganography.py"
    click Poly "https://github.com/mrtracker-new/invisiovault/blob/master/backend/utils/polyglot.py"
    click Validator "https://github.com/mrtracker-new/invisiovault/blob/master/backend/utils/validators.py"
    click CleanupUtil "https://github.com/mrtracker-new/invisiovault/blob/master/backend/utils/cleanup.py"
    click Storage "https://github.com/mrtracker-new/invisiovault/tree/master/backend/uploads"
    click CleanupProcess "https://github.com/mrtracker-new/invisiovault/blob/master/backend/utils/cleanup.py"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6
    classDef backend fill:#DFFFE0,stroke:#2c662d
    classDef utils fill:#F0F0F0,stroke:#666666
    classDef storage fill:#FFF5CC,stroke:#CCA000
    classDef process fill:#F5F5F5,stroke:#999999,stroke-dasharray: 5 5
    classDef annotation fill:#EEEEEE,stroke:#999999,stroke-dasharray: 2 2
    classDef user fill:#FFFFFF,stroke:#888888
    classDef config fill:#FFE4E1,stroke:#d14e31
```
