# upprsk/noroom architecture

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

- Interactive diagram: https://gitdiagram.com/upprsk/noroom
- Repository: https://github.com/upprsk/noroom

## Overview

##### Main Components

a) Frontend Layer (SvelteKit Application):
- Routes (Authentication, Classes, Pods, Users)
- Components Library
- Store Management
- PocketBase Client

b) Backend Services:
1. PocketBase Server (Authentication & Data Storage)
2. Pods Service (Real-time Communication)
3. RPC Service (Inter-service Communication)

c) WebSocket Layer:
- Real-time communication infrastructure between Pods and Clients

##### Component Relationships

- Frontend → PocketBase: REST API calls for data operations
- Frontend ↔ Pods Service: WebSocket connections for real-time features
- Pods Service ↔ RPC Service: Internal communication
- Hub Component → Bridge: Pod management

##### Architectural Patterns to Highlight

a) Client-Side:
- SvelteKit's file-based routing structure
- Component-based architecture
- Store management for state

b) Server-Side:
- Microservices architecture (PocketBase, Pods, RPC)
- WebSocket-based real-time communication
- Bridge pattern for pod management

##### Technical Details to Note

- Authentication flow through PocketBase
- Real-time presence tracking
- Pod management system
- File attachment handling
- Polling system

##### Data Storage Layer

Additional Considerations:
- Notes for important configuration points (e.g., TLS setup)
- Real-time features as they seem to be a core part of the application
- Relationship between pods and classes
- Where user tracking and presence monitoring occur

- How the different services interact
- The flow of data through the system
- Where real-time communications occur
- How authentication and authorization are handled
- The relationship between different components

Remember to maintain a level of abstraction that shows the system architecture without getting lost in implementation details while still providing enough information for understanding the system's operation.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph "Frontend Application"
        Routes["Routes"]:::frontend
        Components["Components Library"]:::frontend
        Store["Store Management"]:::frontend
        PBClient["PocketBase Client"]:::frontend
        Terminal["Real-time Terminal"]:::frontend
        Polling["Polling System"]:::frontend
        UserStore["User Store"]:::frontend
    end

    subgraph "Backend Services"
        PB["PocketBase Server"]:::backend
        Auth["Authentication Handler"]:::auth
        Presence["Presence Tracking"]:::backend
        Tracking["User Tracking"]:::backend

        subgraph "Real-time Services"
            Pods["Pods Service"]:::realtime
            Hub["Hub Component"]:::realtime
            Bridge["Bridge"]:::realtime
            WSServer["WebSocket Server"]:::realtime
        end

        RPC["RPC Service"]:::backend
    end

    Browser --> Routes
    Routes --> Components
    Routes --> Store
    Routes --> PBClient
    PBClient --> PB
    Terminal --> WSServer
    Store --> UserStore
    
    Hub --> Bridge
    Pods --> WSServer
    Pods --> RPC
    
    PB --> Auth
    PB --> Presence
    PB --> Tracking

    %% Click Events
    click Components "https://github.com/upprsk/noroom/tree/master/app/src/lib/components"
    click Routes "https://github.com/upprsk/noroom/tree/master/app/src/lib/routes"
    click Store "https://github.com/upprsk/noroom/tree/master/app/src/lib/stores"
    click PBClient "https://github.com/upprsk/noroom/blob/master/app/src/lib/pocketbase.ts"
    click PB "https://github.com/upprsk/noroom/tree/master/pb"
    click Pods "https://github.com/upprsk/noroom/tree/master/pods"
    click RPC "https://github.com/upprsk/noroom/tree/master/rpc"
    click Hub "https://github.com/upprsk/noroom/tree/master/pods/hub"
    click Bridge "https://github.com/upprsk/noroom/blob/master/pods/hub/bridge.go"
    click WSServer "https://github.com/upprsk/noroom/tree/master/pods/server"
    click Auth "https://github.com/upprsk/noroom/blob/master/pb/auth.go"
    click Presence "https://github.com/upprsk/noroom/blob/master/pb/presence.go"
    click UserStore "https://github.com/upprsk/noroom/blob/master/app/src/lib/stores/user.ts"
    click Terminal "https://github.com/upprsk/noroom/blob/master/app/src/routes/pods/[id]/Terminal.svelte"
    click Polling "https://github.com/upprsk/noroom/tree/master/app/src/routes/classes/[id]/poll"
    click Tracking "https://github.com/upprsk/noroom/blob/master/pb/tracking.go"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef realtime fill:#e74c3c,stroke:#c0392b,color:white
    classDef auth fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Components"]:::frontend
        Backend["Backend Services"]:::backend
        Realtime["Real-time Components"]:::realtime
        AuthComp["Authentication Components"]:::auth
    end
```
