# shinabr2/sworld architecture

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

- Interactive diagram: https://gitdiagram.com/shinabr2/sworld
- Repository: https://github.com/shinabr2/sworld

## Overview

##### Main Components
- Monorepo Structure: The root contains configuration files (.firebaserc, firebase.json, turbo.json, pnpm-workspace.yaml) and multiple directories.
- Individual Frontend Applications:
- Docs: A documentation website (built with Docusaurus/Vite setups).
- Game: A web-based game (using Phaser with its own asset and scenes structure).
- Listen: Likely a media/audio-related application (with e2e tests, React components, and Playwright setup).
- Til: A blog or “today I learned” site with markdown-based posts and routing.
- Watch: A video or media consumption app (with several components for video handling).
- Main: Possibly a landing page or one of the core personal sites.
- Shared Packages:
- packages/core: Domain logic, GraphQL, hooks, providers, and common functions used by several apps.
- packages/ui: A common UI library that provides themed components and re-usable UI elements for many of the apps.
- Supporting Infrastructure:
- GitHub workflows (CI/CD pipelines for unit tests, live previews) are defined under .github/workflows.
- Build and testing configurations using Vite, Jest, ESLint, and others.

##### Relationships and Interactions
- The apps are independently built (each has its own vite.config.ts and build scripts) but follow consistent patterns (e.g., similar source structure and routing).
- Configuration files for Firebase, GitHub Actions, and testing hint at an integrated deployment and CI/CD pipeline. Represent these as auxiliary components that affect all apps.
- That some packages (such as eslint-config-custom, tsconfig) support the overall coding standards and build configuration across the monorepo.

##### Architectural Patterns and Design Principles
- Modular/Monorepo Architecture: Emphasize how the project is split into multiple, self-contained applications while sharing core services and UI components.
- Separation of Concerns: Frontend apps are clearly isolated (each in separate directories) while shared libraries centralize common functionality (business logic, UI components, hooks).
- CI/CD Integration: GitHub workflows and Firebase configurations indicate automated testing, deployment, and possibly preview environments.

##### Relevant Technologies and Frameworks
- Frontend Frameworks: React (based on the TypeScript/tsx files), along with specific libraries like Phaser for the game and Docusaurus for docs.
- Bundling and Build Tools: Vite (vite.config.ts files across apps), Babel (for docs), and TypeScript.
- Testing: Jest, Playwright, and ESlint for quality checks.
- Shared Code: GraphQL support in packages/core, and thematic/styled components in packages/ui.
- Deployment: Firebase is suggested by the presence of .firebaserc and firebase.json.

##### Elements
- From each app to shared libraries to denote dependency.
- From GitHub workflows to apps indicating the continuous integration/test pipelines.
- From apps to Firebase (or other deployment infrastructure) showing deployment flows.
- Brief annotations/sticky notes for sections like “Phaser Game Engine”, “React Components”, “GraphQL/Custom Hooks”, or “Markdown/Documentation Engine” to capture essential details.

## Diagram (Mermaid)

```mermaid
graph TD
    root["Monorepo Root (Config Files)"]:::root
    subgraph "Monorepo"
        subgraph "Frontend Applications"
            docs["Docs (Documentation Website)"]:::app
            game["Game (Game Application)"]:::app
            listen["Listen (Audio/Media App)"]:::app
            til["TIL (Blog/TIL)"]:::app
            watch["Watch (Video App)"]:::app
            main["Main (Landing Page)"]:::app
        end
        subgraph "Shared Libraries"
            core["Core (Domain Logic & GraphQL)"]:::lib
            ui["UI (Themed UI Components)"]:::lib
        end
    end
    infraCI["CI/CD (GitHub Workflows)"]:::infra
    firebase["Firebase (Deployment)"]:::infra

    %% Relationships: Monorepo Root contains components
    root -->|"contains"| docs
    root -->|"contains"| game
    root -->|"contains"| listen
    root -->|"contains"| til
    root -->|"contains"| watch
    root -->|"contains"| main
    root -->|"contains"| core
    root -->|"contains"| ui
    root -->|"contains"| infraCI

    %% Each Frontend App uses shared libraries
    docs -->|"uses"| core
    docs -->|"uses"| ui
    game -->|"uses"| core
    game -->|"uses"| ui
    listen -->|"uses"| core
    listen -->|"uses"| ui
    til -->|"uses"| core
    til -->|"uses"| ui
    watch -->|"uses"| core
    watch -->|"uses"| ui
    main -->|"uses"| core
    main -->|"uses"| ui

    %% CI/CD triggers apps build/test pipelines
    infraCI -->|"triggers"| docs
    infraCI -->|"triggers"| game
    infraCI -->|"triggers"| listen
    infraCI -->|"triggers"| til
    infraCI -->|"triggers"| watch
    infraCI -->|"triggers"| main

    %% Deployment flows from apps to Firebase
    docs -->|"deploysTo"| firebase
    game -->|"deploysTo"| firebase
    listen -->|"deploysTo"| firebase
    til -->|"deploysTo"| firebase
    watch -->|"deploysTo"| firebase
    main -->|"deploysTo"| firebase

    classDef app fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef lib fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef root fill:#D3D3D3,stroke:#333,stroke-width:2px;
    classDef infra fill:#90EE90,stroke:#333,stroke-width:2px;

click root "https://github.com/shinabr2/sworld/blob/main/."
click docs "https://github.com/shinabr2/sworld/tree/main/apps/docs"
click game "https://github.com/shinabr2/sworld/tree/main/apps/game"
click listen "https://github.com/shinabr2/sworld/tree/main/apps/listen"
click til "https://github.com/shinabr2/sworld/tree/main/apps/til"
click watch "https://github.com/shinabr2/sworld/tree/main/apps/watch"
click main "https://github.com/shinabr2/sworld/tree/main/apps/main"
click core "https://github.com/shinabr2/sworld/tree/main/packages/core"
click ui "https://github.com/shinabr2/sworld/tree/main/packages/ui"
click infraCI "https://github.com/shinabr2/sworld/tree/main/.github/workflows"
```
