# ama-matioc/genart architecture

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

- Interactive diagram: https://gitdiagram.com/ama-matioc/genart
- Repository: https://github.com/ama-matioc/genart

## Overview

##### Project type and purpose
- From the file tree and minimal README, we see a frontend folder with a React application (components, contexts, Firebase integrations) and a backend folder containing Python scripts (app.py, img2img.py, txt2img.py).
- This is a full-stack web application for “GenArt,” a generative-art platform built as a bachelor thesis. The frontend provides a single-page UI for users to register/login, generate images from text or images, view a gallery, and store results. The backend exposes REST endpoints to orchestrate ML generation pipelines. Firebase handles authentication and storage of generated assets.

##### File structure
- Top-level directories:
- backend/ (Python Flask or FastAPI app with two generation modules)
- frontend/ (React SPA with Context API & Firebase integration)
- Key patterns:
- SPA communicates over HTTP to a backend API
- BaaS for user management and storage (Firebase)
- Config files: package.json (frontend dependencies), backend/app.py (API server bootstrap).

##### README for additional insights

a. Main components
- User’s Browser (UI)
- React SPA (components, AuthContext)
- Firebase Auth (external service)
- Firebase Storage (external)
- Backend API server (app.py)
- ML Modules (txt2img.py, img2img.py)
- Optional: Web server / hosting (e.g., Netlify, AWS S3 + CloudFront)
b. Relationships and interactions
- User → React SPA (UI interactions)
- React SPA ↔ Firebase Auth (sign-up / login / JWT issuance)
- React SPA → Backend API (HTTP POST /generate-txt2img or /generate-img2img with auth token)
- Backend API → ML Modules (library calls, local function invocation)
- Backend API → Firebase Storage (upload generated images)
- React SPA → Firebase Storage (retrieve images for gallery)
c. Architectural patterns / design principles
- Single‐page application front-end
- RESTful API backend
- Separation of concerns: UI, business logic, ML processing, storage, auth
- External BaaS for common cross‐cutting requirements
d. Relevant technologies/frameworks
- Frontend: React, Context API, Firebase JS SDK, CSS
- Backend: Python (Flask or FastAPI), ML libraries in txt2img.py and img2img.py
- External services: Google Firebase Auth & Storage

##### Detail
- Subcomponents inside the SPA: AuthContext, Generator components.
- Python scripts as distinct modules invoked by the API server.
- Data payload structure (e.g., image bytes, tokens).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    Browser["User's Browser"]:::client

    %% Frontend Subgraph
    subgraph "Frontend (React SPA)"
        IDX["index.js"]:::frontend
        APP["App.js"]:::frontend
        AUTHCTX["AuthContext.js"]:::frontend
        FB_AUTH_CODE["Auth.js"]:::frontend
        FB_INIT["FirebaseHandler.js"]:::frontend
        FB_STORAGE_CODE["FirebaseStorage.js"]:::frontend
        NAV["Navbar.js"]:::frontend
        HOME["Homepage.js"]:::frontend
        LOGIN["Login.js"]:::frontend
        REGISTER["Register.js"]:::frontend
        PROFILE["Profile.js"]:::frontend
        GENPAGE["GeneratePage.js"]:::frontend
        TXTUI["Txt2ImgGenerator.js"]:::frontend
        IMGUI["Img2ImgGenerator.js"]:::frontend
        GALLERY["Gallery.js"]:::frontend
    end

    %% Backend Subgraph
    subgraph "Backend API Server"
        API["app.py"]:::backend
        TXT2IMG["txt2img.py"]:::backend
        IMG2IMG["img2img.py"]:::backend
    end

    %% External Services
    subgraph "External Services"
        FBAuth["Firebase Auth"]:::external
        FBStore["Firebase Storage"]:::external
    end

    %% Connections
    Browser --> IDX
    IDX --> APP
    APP --> AUTHCTX
    AUTHCTX --> FB_AUTH_CODE
    AUTHCTX --> FB_INIT
    AUTHCTX --> FBAuth
    FBAuth --> AUTHCTX
    AUTHCTX -->|issue JWT| APP

    APP --> NAV
    NAV --> HOME
    NAV --> GENPAGE
    NAV --> GALLERY
    NAV --> PROFILE

    APP --> LOGIN
    APP --> REGISTER
    LOGIN --> AUTHCTX
    REGISTER --> AUTHCTX

    GENPAGE --> TXTUI
    GENPAGE --> IMGUI

    TXTUI -->|POST /generate-txt2img| API
    IMGUI -->|POST /generate-img2img| API

    API --> TXT2IMG
    API --> IMG2IMG
    API --> FBStore

    GALLERY --> FBStore
    Browser -->|view assets| FBStore

    %% Click events
    click IDX "https://github.com/ama-matioc/genart/blob/main/frontend/src/index.js"
    click APP "https://github.com/ama-matioc/genart/blob/main/frontend/src/App.js"
    click AUTHCTX "https://github.com/ama-matioc/genart/blob/main/frontend/src/contexts/AuthContext.js"
    click FB_AUTH_CODE "https://github.com/ama-matioc/genart/blob/main/frontend/src/firebase/Auth.js"
    click FB_INIT "https://github.com/ama-matioc/genart/blob/main/frontend/src/firebase/FirebaseHandler.js"
    click FB_STORAGE_CODE "https://github.com/ama-matioc/genart/blob/main/frontend/src/firebase/FirebaseStorage.js"
    click TXTUI "https://github.com/ama-matioc/genart/blob/main/frontend/src/components/Txt2ImgGenerator.js"
    click IMGUI "https://github.com/ama-matioc/genart/blob/main/frontend/src/components/Img2ImgGenerator.js"
    click GENPAGE "https://github.com/ama-matioc/genart/blob/main/frontend/src/components/GeneratePage.js"
    click GALLERY "https://github.com/ama-matioc/genart/blob/main/frontend/src/components/Gallery.js"
    click HOME "https://github.com/ama-matioc/genart/blob/main/frontend/src/components/Homepage.js"
    click LOGIN "https://github.com/ama-matioc/genart/blob/main/frontend/src/components/Login.js"
    click REGISTER "https://github.com/ama-matioc/genart/blob/main/frontend/src/components/Register.js"
    click PROFILE "https://github.com/ama-matioc/genart/blob/main/frontend/src/components/Profile.js"
    click NAV "https://github.com/ama-matioc/genart/blob/main/frontend/src/components/Navbar.js"
    click API "https://github.com/ama-matioc/genart/blob/main/backend/app.py"
    click TXT2IMG "https://github.com/ama-matioc/genart/blob/main/backend/txt2img.py"
    click IMG2IMG "https://github.com/ama-matioc/genart/blob/main/backend/img2img.py"

    %% Styles
    classDef client fill:#cfe2f3,stroke:#0366d6,color:#000;
    classDef frontend fill:#e8f0fe,stroke:#1a73e8,color:#000;
    classDef backend fill:#e6f4ea,stroke:#34a853,color:#000;
    classDef external fill:#fff4e5,stroke:#fbbc04,color:#000;
```
