# m1k1o/neko-rooms architecture

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

- Interactive diagram: https://gitdiagram.com/m1k1o/neko-rooms
- Repository: https://github.com/m1k1o/neko-rooms

## Overview

##### Project’s Main Purpose and Type
- The project is a full-stack application that combines a frontend (built using Vue.js) with a backend implemented in Go.
- Its purpose is room management for hosting browser-based “rooms” (for example, with Firefox and Chromium) using containerized environments managed via Docker. It also supports reverse proxying with Traefik or NGINX, and includes configuration for various deployment and installation methods.

##### File Structure to Identify Architectural Components
- The “client” directory holds all Vue.js frontend-related files (components, views, store, assets, and API services) that serve as the user interface.
- The “cmd” and “internal” directories include the core Go backend code. These include:
– API handling (internal/api)
– Configuration management (internal/config)
– Room management, proxy, and pull functionality (internal/room, internal/proxy, internal/pull)
– Supporting utilities and types.
- The “docker-compose.yml”, “Dockerfile”, and various “.env” files (found in directories like “dev”, “traefik”, and “nginx”) indicate that the system is containerized and can be deployed via Docker.
- There are also developer helper scripts (in folders like “community” and “dev”) to streamline installation and deployment.

##### Components
a. Frontend Client:
– Label a component representing the Vue.js application that includes the “client/src” portion.
– Show sub-components such as API communication (e.g., the api/ folder) and UI components.

b. Backend Service:
– Represent the Go backend server with components for API routing, configuration handling, room and pull management, and the core server orchestration found in “cmd” and “internal”.
– Subdivide it further into modules like “API”, “Room Management”, “Policy Enforcement” (noting separate directories for Firefox and Chromium policies), and “Proxy Management”.

c. Reverse Proxy / Load Balancer:
– Indicate components for reverse proxying deployed by Traefik or NGINX. There are dedicated directories (“traefik” and “nginx”) with their own configuration and installation scripts.

d. Container and Deployment Infrastructure:
– Include a Docker layer that orchestrates containers (using “docker-compose.yml”) which pulls different browser images (n.eko images for Firefox/Chromium and others).
– Mark the orchestration and configuration points including environment variable settings (for instance, to enable nvidia GPU support).

e. External Services and Dependencies:
– Show external dependencies like Let's Encrypt for HTTPS, and Docker images pulled from external registries.
– Optionally, highlight the external API endpoints that the frontend may use to interact with the backend.

##### Relationships and Data Flow
- Reverse proxy system (Traefik/NGINX) in front of the backend, receiving traffic and routing requests appropriately.
- Docker orchestration managing the start and shutdown of containers, with the backend container communicating with the browser containers for room sessions.

##### Architectural Design Patterns and Technologies
- The separation of components follows a modular design; the frontend and backend are decoupled and communicate via APIs.
- There is use of standard microservice/container orchestration patterns, given the multiple Docker deployment configurations.
- The system embraces reverse proxy management, secure HTTPS handling (via Let’s Encrypt), and optionally GPU-accelerated container use.
- Technologies include Vue.js for the frontend, Go for the backend, Docker for containerization, and Traefik/NGINX for routing.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        A["Vue.js Client"]:::frontend
    end

    %% Edge Layer (Reverse Proxy)
    subgraph "Reverse Proxy Layer"
        B["Traefik Reverse Proxy"]:::proxy
        C["NGINX Reverse Proxy"]:::proxy
    end

    %% Server Layer (Backend)
    subgraph "Server Layer"
        D["Go API Server"]:::backend
        subgraph "Go Modules"
            D1["API Handler"]:::backend
            D2["Configuration"]:::backend
            D3["Room Management"]:::backend
            D4["Proxy Handling"]:::backend
            D5["Pull Management"]:::backend
        end
    end

    %% Container & Deployment Infrastructure
    subgraph "Container & Deployment"
        E["Docker Orchestration"]:::container
        subgraph "Deployment Files"
            E1["Dockerfile"]:::container
            E2["Environment Config"]:::container
        end
    end

    %% Helpers & Documentation
    subgraph "Helpers & Docs"
        F["Developer Helpers"]:::helper
        G["Documentation"]:::doc
    end

    %% Connections
    A -->|"calls"| B
    A -->|"calls"| C
    B -->|"routes to"| D
    C -->|"routes to"| D
    D -->|"delegates to"| D1
    D -->|"delegates to"| D2
    D -->|"delegates to"| D3
    D -->|"delegates to"| D4
    D -->|"delegates to"| D5
    D3 -->|"manages containers"| E
    F -->|"triggers"| E
    D -->|"references"| G

    %% Click Events for Frontend
    click A "https://github.com/m1k1o/neko-rooms/tree/master/client/src"

    %% Click Events for Backend
    click D "https://github.com/m1k1o/neko-rooms/tree/master/cmd/neko_rooms"
    click D1 "https://github.com/m1k1o/neko-rooms/tree/master/internal/api"
    click D2 "https://github.com/m1k1o/neko-rooms/tree/master/internal/config"
    click D3 "https://github.com/m1k1o/neko-rooms/tree/master/internal/room"
    click D4 "https://github.com/m1k1o/neko-rooms/tree/master/internal/proxy"
    click D5 "https://github.com/m1k1o/neko-rooms/tree/master/internal/pull"

    %% Click Events for Reverse Proxy
    click B "https://github.com/m1k1o/neko-rooms/tree/master/traefik/"
    click C "https://github.com/m1k1o/neko-rooms/tree/master/nginx/"

    %% Click Events for Container & Deployment
    click E "https://github.com/m1k1o/neko-rooms/blob/master/docker-compose.yml"
    click E1 "https://github.com/m1k1o/neko-rooms/tree/master/Dockerfile"
    click E2 "https://github.com/m1k1o/neko-rooms/blob/master/dev/traefik/.env.example"

    %% Click Events for Developer Helpers & Documentation
    click F "https://github.com/m1k1o/neko-rooms/tree/master/dev/"
    click G "https://github.com/m1k1o/neko-rooms/blob/master/docs/architecture.drawio"

    %% Styles
    classDef frontend fill:#CCFFCC,stroke:#006600,stroke-width:2px;
    classDef backend fill:#CCCCFF,stroke:#000066,stroke-width:2px;
    classDef proxy fill:#FFE6CC,stroke:#FF8C00,stroke-width:2px;
    classDef container fill:#FFFFCC,stroke:#CCCC00,stroke-width:2px;
    classDef helper fill:#E6E6FA,stroke:#8A2BE2,stroke-width:2px;
    classDef doc fill:#FFCCCC,stroke:#CC0000,stroke-width:2px;
```
