# stmarya/aifrodevelopers5 architecture

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

- Interactive diagram: https://gitdiagram.com/stmarya/aifrodevelopers5
- Repository: https://github.com/stmarya/aifrodevelopers5

## Overview

##### Project type and purpose
- This is a full-stack monorepo combining:
- An Express.js backend that exposes REST API endpoints for text, image, document, and audio processing using the Google Gemini AI model
- A static HTML/CSS/JavaScript frontend chatbot UI served by the same Express server
- Purpose: provide a chat interface that can send various media and receive AI-generated responses.

##### File structure
- Top-level monorepo with one “backend” folder; within it:
- public/ – static files (index.html, script.js, style.css)
- src/ – server code broken down into controllers, routes, services, utils, plus index.js
- uploads/ – temporary storage for file uploads
- configuration files (.env, package.json)
- No separate “frontend” repo; frontend is static assets under backend/public
- No database layer or external persistent storage except temporary uploads
- Build/deploy artifacts: Dockerfile, docker-compose.yml at root

##### README for additional insights
- Lists features and API endpoints
- Describes configuration via environment variables
- Indicates use of Google Gemini API client in services/geminiClient.js
- Suggests development vs. production startup scripts (npm run dev, npm start)

- Sub-components inside “Express.js Server”:
- Routes layer (src/routes): maps endpoints to controllers
- Controllers layer (src/controllers): validate input, orchestrate services
- Services layer (src/services): geminiClient.js calls external API
- Utils layer (src/utils): fileHelper.js manages temporary files
- Static asset server (serves /public files)
- How middleware (file upload) sits between Routes and Controllers for file endpoints

## Diagram (Mermaid)

```mermaid
graph TB
    Browser["Client Browser"]:::external

    subgraph "Frontend UI"
        direction TB
        Index["index.html"]:::frontend
        Script["script.js"]:::frontend
        Style["style.css"]:::frontend
    end

    Browser -->|"GET /"| Index
    Browser -->|"GET /script.js"| Script
    Browser -->|"GET /style.css"| Style
    Browser -->|"POST /api/*"| ExpressServer

    subgraph "Deployment Environment (Docker)" style dashed
        subgraph "Express.js Server"
            direction TB
            ExpressServer["Express.js Server"]:::backend
            StaticServer["Static Asset Server"]:::backend

            subgraph "AI Generation API"
                direction TB
                Routes["Routes Layer"]:::backend
                Controllers["Controllers Layer"]:::backend
                Services["Services Layer"]:::backend
            end

            Utils["Utilities Layer"]:::backend
            Uploads["Local Uploads Storage"]:::storage
        end
    end

    Script -->|"served by"| StaticServer
    Style -->|"served by"| StaticServer
    Index -->|"served by"| StaticServer

    ExpressServer -->|"/api/*"| Routes
    Routes -->|calls| Controllers
    Controllers -->|orchestrates| Services
    Controllers -->|reads/writes| Uploads
    Services -->|calls| GeminiAPI

    subgraph "External Services"
        GeminiAPI["Google Gemini AI Service"]:::external
    end

    classDef frontend fill:#D6EAF8,stroke:#3498DB,color:#154360;
    classDef backend fill:#E8F8F5,stroke:#1ABC9C,color:#0E6251;
    classDef external fill:#F5EEF8,stroke:#9B59B6,color:#4A235A;
    classDef storage fill:#FEF9E7,stroke:#F4D03F,color:#7D6608;
    classDef deployment fill:#F2F3F4,stroke-dasharray: 5 5,color:#566573;

    click Index "https://github.com/stmarya/aifrodevelopers5/blob/main/backend/public/index.html"
    click Script "https://github.com/stmarya/aifrodevelopers5/blob/main/backend/public/script.js"
    click Style "https://github.com/stmarya/aifrodevelopers5/blob/main/backend/public/style.css"
    click ExpressServer "https://github.com/stmarya/aifrodevelopers5/blob/main/backend/src/index.js"
    click Routes "https://github.com/stmarya/aifrodevelopers5/blob/main/backend/src/routes/gemini.js"
    click Controllers "https://github.com/stmarya/aifrodevelopers5/blob/main/backend/src/controllers/gemini.js"
    click Services "https://github.com/stmarya/aifrodevelopers5/blob/main/backend/src/services/geminiClient.js"
    click Utils "https://github.com/stmarya/aifrodevelopers5/blob/main/backend/src/utils/fileHelper.js"
    click Package "https://github.com/stmarya/aifrodevelopers5/blob/main/backend/package.json"
    click Gitignore "https://github.com/stmarya/aifrodevelopers5/blob/main/backend/.gitignore"
    click Readme "https://github.com/stmarya/aifrodevelopers5/blob/main/readme.md"
```
