# nsvoriginals/oasis architecture

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

- Interactive diagram: https://gitdiagram.com/nsvoriginals/oasis
- Repository: https://github.com/nsvoriginals/oasis

## Overview

##### Main system components
- Frontend Client: All files in the "client" directory indicate a React and TypeScript–based front-end leveraging Vite for build, and using Phaser for game elements. This component includes user interface elements, scene management (Canvas-based game scenes), and interactive tools (e.g., joystick, chat, video dialogs).
- Backend Server: The "server" directory contains server-side code using Express (and likely Colyseus for room management) with additional modules for room-specific commands and database schema management. This is where the core room state management and interaction handling occur.
- Database/State Persistence: Files such as server/db.ts and schema-related files indicate that the server maintains a persistent state (or interacts with a database) necessary for tracking virtual rooms and user states.
- Additional Assets and Utility Modules: From the file tree, the client’s assets (graphics, fonts, animations, map data) and utility modules (stores, custom events) support the real-time, interactive experience.

##### Depicting relationships and interactions
- That the Frontend integrates with the Real-Time Communication module (PeerJS & WebRTC) for video, audio, and screen sharing.
- Separate the game/Phaser engine within the client, possibly representing it as a nested module that receives game state data from backend services.
- Backend Server as interfacing with a database (or persistent state store) and managing room logic via Colyseus, illustrated by the “rooms” directory and its command files.
- External components such as deployment containers (Docker) to contextualize how the system is run in production.

##### Architectural patterns and technologies
- A clear separation between the client and server, aligning with modern full-stack best practices.
- Use of MVC-like separation on the client (components, scenes, assets) and service-oriented/microservices patterns on the server (each “room” command acting as discrete handlers).
- Use of real-time event-driven communication patterns especially in handling WebRTC sessions and game updates.
- Use of TypeScript throughout which enforces type-safety across both front- and back-end.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client Side"
        FE["Frontend Client (React/Phaser)"]:::frontend
        UI["Assets and Utility Modules"]:::assets
        FE -->|"loads_assets"| UI
    end

    subgraph "Real-Time Communication Layer"
        RTC["Real-Time Communication (WebRTC/PeerJS)"]:::realTime
    end

    subgraph "Server Side"
        BE["Backend Server (Express/Colyseus)"]:::backend
        DB["Database/State Persistence"]:::backend
        BE -->|"persists_state"| DB
    end

    FE -->|"api_calls_state_sync"| BE
    FE -->|"multimedia_comm"| RTC
    BE -->|"room_events"| RTC

    subgraph "Deployment"
        DOCKER["Deployment Environment (Docker)"]:::backend
    end
    BE -->|"containerized_deployment"| DOCKER

    %% Click Events
    click FE "https://github.com/nsvoriginals/oasis/tree/main/client/"
    click UI "https://github.com/nsvoriginals/oasis/tree/main/client/public/assets/"
    click BE "https://github.com/nsvoriginals/oasis/tree/main/server/"
    click RTC "https://github.com/nsvoriginals/oasis/tree/main/client/src/web/"
    click DB "https://github.com/nsvoriginals/oasis/blob/main/server/db.ts"

    %% Styles
    classDef frontend fill:#a8dadc,stroke:#457b9d,stroke-width:2px;
    classDef backend fill:#f4a261,stroke:#e76f51,stroke-width:2px;
    classDef realTime fill:#e9c46a,stroke:#f4a261,stroke-width:2px;
    classDef assets fill:#2a9d8f,stroke:#264653,stroke-width:2px;
```
