# rommapp/romm architecture

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

- Interactive diagram: https://gitdiagram.com/rommapp/romm
- Repository: https://github.com/rommapp/romm

## Overview

##### Main Components Structure

a) Frontend Layer:
- Vue.js-based SPA (located in /frontend)
- Components for ROM management, game details, player interface
- Vuetify for UI components
- WebSocket client for real-time updates

b) Backend Layer:
- FastAPI application (located in /backend)
- Authentication system
- Database handlers
- File system handlers
- Task scheduling system

c) Storage Layer:
- PostgreSQL database (for ROM metadata, user data)
- Redis (for task queue and caching)
- File system storage (for ROMs, saves, screenshots)

##### Integration Points

Connections between:
- Frontend and Backend via REST API
- Backend and External Services (IGDB, MobyGames)
- Backend and Storage Systems
- WebSocket connections for real-time updates

##### Key Architectural Patterns

Patterns:
- Model-View-Controller (MVC) in the backend
- Component-based architecture in the frontend
- Repository pattern for data access
- Task queue pattern for async operations

##### Detailed Component Breakdown

Backend Services:
- Auth Service
- User Management
- Permission Control
- ROM Management
- Scanning Service
- Metadata Service
- File Management
- Platform Management
- Asset Management
- Screenshots
- Saves
- States

Frontend Modules:
- Core UI Components
- Game Gallery
- Game Details
- Player Interface
- Settings Management

##### Data Flow Representation

- User requests flow
- Authentication flow
- ROM scanning and metadata enrichment flow
- Game launching flow
- Asset management flow

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#2196F3,color:white
    classDef backend fill:#4CAF50,color:white
    classDef storage fill:#9C27B0,color:white
    classDef external fill:#FF9800,color:white
    classDef auth fill:#F44336,color:white
    classDef task fill:#795548,color:white

    %% Frontend Layer
    subgraph Frontend
        VueApp["Vue.js SPA"]:::frontend
        ROMManagement["ROM Management"]:::frontend
        GameDetails["Game Details"]:::frontend
        WSClient["WebSocket Client"]:::frontend
        PlayerInterface["Player Interface"]:::frontend
        Settings["Settings Management"]:::frontend
    end

    %% Backend Layer
    subgraph Backend
        FastAPI["FastAPI Application"]:::backend
        AuthSystem["Authentication System"]:::auth
        TaskScheduler["Task Scheduler"]:::task
        Worker["Worker System"]:::task
        
        subgraph Handlers
            ROMHandler["ROM Handler"]:::backend
            PlatformHandler["Platform Handler"]:::backend
            AssetsHandler["Assets Handler"]:::backend
            SocketHandler["Socket Handler"]:::backend
        end
        
        subgraph Tasks
            ScanLibrary["Scan Library"]:::task
            MetadataEnrich["Metadata Enrichment"]:::task
        end
    end

    %% Storage Layer
    subgraph Storage
        PostgreSQL[(PostgreSQL)]:::storage
        Redis[(Redis)]:::storage
        FileSystem["File System Storage"]:::storage
    end

    %% External Services
    subgraph External
        IGDB["IGDB API"]:::external
        MobyGames["MobyGames API"]:::external
    end

    %% Connections
    VueApp --> FastAPI
    WSClient --> SocketHandler
    FastAPI --> AuthSystem
    FastAPI --> Handlers
    TaskScheduler --> Tasks
    Worker --> Tasks
    ROMHandler --> PostgreSQL
    PlatformHandler --> PostgreSQL
    Tasks --> Redis
    AssetsHandler --> FileSystem
    MetadataEnrich --> IGDB
    MetadataEnrich --> MobyGames

    %% Click Events
    click VueApp "https://github.com/rommapp/romm/blob/release/frontend/src/RomM.vue"
    click ROMManagement "https://github.com/rommapp/romm/tree/release/frontend/src/components/Gallery/"
    click GameDetails "https://github.com/rommapp/romm/tree/release/frontend/src/components/Details/"
    click WSClient "https://github.com/rommapp/romm/blob/release/frontend/src/services/socket.ts"
    click FastAPI "https://github.com/rommapp/romm/blob/release/backend/main.py"
    click TaskScheduler "https://github.com/rommapp/romm/blob/release/backend/scheduler.py"
    click Worker "https://github.com/rommapp/romm/blob/release/backend/worker.py"
    click AuthSystem "https://github.com/rommapp/romm/tree/release/backend/handler/auth/"
    click ROMHandler "https://github.com/rommapp/romm/blob/release/backend/handler/database/roms_handler.py"
    click PlatformHandler "https://github.com/rommapp/romm/blob/release/backend/handler/database/platforms_handler.py"
    click AssetsHandler "https://github.com/rommapp/romm/blob/release/backend/handler/filesystem/assets_handler.py"
    click ScanLibrary "https://github.com/rommapp/romm/blob/release/backend/tasks/scan_library.py"
    click SocketHandler "https://github.com/rommapp/romm/blob/release/backend/handler/socket_handler.py"

    %% Legend
    subgraph Legend
        Frontend_L["Frontend Component"]:::frontend
        Backend_L["Backend Component"]:::backend
        Storage_L["Storage Component"]:::storage
        External_L["External Service"]:::external
        Auth_L["Auth Component"]:::auth
        Task_L["Task Component"]:::task
    end
```
