# sameer-ssr99/web-steganography architecture

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

- Interactive diagram: https://gitdiagram.com/sameer-ssr99/web-steganography
- Repository: https://github.com/sameer-ssr99/web-steganography

## Overview

##### Project type and purpose
- This is a full-stack web application for performing steganography (hiding and extracting messages in image, audio, video, and text files).
- The frontend is a React single-page app; the backend is a Flask API that processes steganography operations.

##### File structure
- Top-level:
- frontend/ – React application with public assets and source pages (Index, Form, Result)
- backend/ – Flask application (app.py) plus a libs/ package for steganography implementations
- global .gitignore and root package-lock.json
- backend/libs/ contains four modules (image_steganography.py, audio_steganography.py, video_steganography.py, text_steganography.py) implementing each media-type algorithm
- backend/templates/ holds HTML templates, but the actual UI is served by React (these may be legacy or for fallback)
- backend/uploads/ and backend/processed/ are local file-system stores for incoming media and output stego files
- frontend/src/pages/ provides componentized pages for user input, status display, and results

##### Key insights from README
- No dedicated database; file system is used for persistence.
- Frontend talks to backend via REST endpoints (hosted on Render).
- Deployment uses Vercel (frontend) and Render.com (backend).
- Major dependencies: Flask-CORS for cross-origin, OpenCV/Pillow/Stegano in Python, React Router in frontend.

##### Main components and their relationships
a. Client (Browser)
- React app (hosted on Vercel) presenting form → upload media + secret message → API calls
b. API Gateway / Backend
- Flask app endpoints: /encode, /decode
- Receives HTTP multipart/form-data → stores input in uploads/
- Dispatches to appropriate steganography module in libs/ based on media type
- Modules use OpenCV, PIL, Stegano to process and generate stego file → placed in processed/
- Returns result URL or file download stream to frontend
c. File Storage
- uploads/: raw user files
- processed/: encoded/decoded results
d. External Services
- Vercel for static hosting of React
- Render for Flask backend runtime
e. (Optional) Browser local storage or caching for small interim data

##### Architectural patterns & design principles
- Separation of concerns: UI (React) vs Processing (Flask + libs)
- RESTful HTTP between frontend and backend
- Modular code: one steganography module per media type
- File-system as simple persistence layer (no DB)
- CORS to allow cross-origin calls
- Deployment as two independent services (micro-frontend + micro-backend)

## Diagram (Mermaid)

```mermaid
graph TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        Browser["User Browser"]:::external
        ReactApp["React Frontend"]:::frontend
        Browser -->|"Loads SPA"| ReactApp
    end

    %% API Layer
    subgraph "API Layer"
        FlaskAPI["Flask API"]:::backend
    end

    %% Processing Layer
    subgraph "Processing Layer"
        ImageModule["Image Steganography"]:::processing
        AudioModule["Audio Steganography"]:::processing
        VideoModule["Video Steganography"]:::processing
        TextModule["Text Steganography"]:::processing
    end

    %% Storage Layer
    subgraph "Storage Layer"
        Uploads[(uploads/)]:::storage
        Processed[(processed/)]:::storage
    end

    %% External Services
    subgraph "External Services"
        Vercel["Vercel (Frontend)"]:::external
        Render["Render (Backend)"]:::external
    end

    %% Connections
    ReactApp -->|"POST /encode, /decode"| FlaskAPI
    FlaskAPI -->|"calls"| ImageModule
    FlaskAPI -->|"calls"| AudioModule
    FlaskAPI -->|"calls"| VideoModule
    FlaskAPI -->|"calls"| TextModule
    FlaskAPI -->|"writes input"| Uploads
    ImageModule -->|"writes output"| Processed
    AudioModule -->|"writes output"| Processed
    VideoModule -->|"writes output"| Processed
    TextModule -->|"writes output"| Processed
    FlaskAPI -->|"returns download link"| ReactApp
    ReactApp --> Vercel
    FlaskAPI --> Render

    %% Click events for component mappings
    click ReactApp "https://github.com/sameer-ssr99/web-steganography/tree/main/frontend/"
    click Browser "https://github.com/sameer-ssr99/web-steganography/blob/main/frontend/src/index.js"
    click FlaskAPI "https://github.com/sameer-ssr99/web-steganography/blob/main/backend/app.py"
    click ImageModule "https://github.com/sameer-ssr99/web-steganography/blob/main/backend/libs/image_steganography.py"
    click AudioModule "https://github.com/sameer-ssr99/web-steganography/blob/main/backend/libs/audio_steganography.py"
    click VideoModule "https://github.com/sameer-ssr99/web-steganography/blob/main/backend/libs/video_steganography.py"
    click TextModule "https://github.com/sameer-ssr99/web-steganography/blob/main/backend/libs/text_steganography.py"
    click Uploads "https://github.com/sameer-ssr99/web-steganography/tree/main/backend/uploads/"
    click Processed "https://github.com/sameer-ssr99/web-steganography/tree/main/backend/processed/"
    click ReactApp "https://github.com/sameer-ssr99/web-steganography/blob/main/frontend/src/App.js"
    click ReactApp "https://github.com/sameer-ssr99/web-steganography/blob/main/frontend/src/pages/Index.jsx"
    click ReactApp "https://github.com/sameer-ssr99/web-steganography/blob/main/frontend/src/pages/Form.jsx"
    click ReactApp "https://github.com/sameer-ssr99/web-steganography/blob/main/frontend/src/pages/Result.jsx"
    click ReactApp "https://github.com/sameer-ssr99/web-steganography/blob/main/frontend/public/index.html"
    click FlaskAPI "https://github.com/sameer-ssr99/web-steganography/blob/main/backend/requirements.txt"
    click FlaskAPI "https://github.com/sameer-ssr99/web-steganography/blob/main/backend/runtime.txt"
    click FlaskAPI "https://github.com/sameer-ssr99/web-steganography/tree/main/backend/templates/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#333,stroke-width:1px
    classDef backend fill:#D0FFD6,stroke:#333,stroke-width:1px
    classDef processing fill:#FFF9C4,stroke:#333,stroke-width:1px
    classDef storage fill:#FFE0B2,stroke:#333,stroke-width:1px
    classDef external fill:#E0E0E0,stroke:#333,stroke-width:1px
```
