# krishnagavali/chitrush architecture

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

- Interactive diagram: https://gitdiagram.com/krishnagavali/chitrush
- Repository: https://github.com/krishnagavali/chitrush

## Overview

##### Project type and purpose
- This is a full-stack, real-time multiplayer web application: a browser-based remake of the Marathi game “Charr Charr Chithya,” built with React on the frontend, Express.js on the backend, and Socket.IO for real-time communication.

##### File structure
- Top level:
- client/ – React application (Vite)
– src/Components split into Home, Lobby, and Game components
– Context providers for sockets and user/game session state
– Routes for navigation (Home, Lobby)
- server/ – Node/Express server with Socket.IO handlers
- No database directory—game state is held in-memory per room/session
- Config/build files: client/vite.config.js, server/index.js, package.json files

##### README for additional insights
- Tech stack confirmation: React, Express.js, Socket.IO
- Deployment: Hosted on a GCP VM, domain via Namecheap, SSL via Let’s Encrypt
- Key features: real-time multiplayer, socket-driven game flow, responsive UI

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Infrastructure Layer
    subgraph "External Infrastructure" 
        direction TB
        DNS["Namecheap DNS"]:::infra
        SSL["Let's Encrypt SSL"]:::infra
        VM["GCP Compute Engine VM"]:::infra
    end

    %% Frontend Layer
    subgraph "Frontend (React SPA)" 
        direction TB
        HTML["HTML Template"]:::frontend
        VITE["Vite Config"]:::frontend
        ENTRY["React SPA Entry Point\n(main.jsx)"]:::frontend
        SHELL["React App Shell\n(App.jsx)"]:::frontend

        subgraph "Router & Navigation"
            direction TB
            HOME_ROUTE["Home Route"]:::frontend
            LOBBY_ROUTE["Lobby Route"]:::frontend
        end

        subgraph "Context Providers"
            direction TB
            SOCKET_CTX["Socket Context Provider"]:::frontend
            GAME_SESSION_CTX["Game Session State Context"]:::frontend
            USERS_CTX["Users Context Provider"]:::frontend
        end

        subgraph "Home Components"
            direction TB
            CREATE_ROOM["Create Room Screen"]:::frontend
            JOIN_ROOM["Join Room Screen"]:::frontend
        end

        subgraph "Lobby Components"
            direction TB
            EMOJI_SEL["Emoji Selector"]:::frontend
            GAME_SCREEN["Game Screen"]:::frontend
            USER_CARD["User Card"]:::frontend
            USERS_LIST["Users List"]:::frontend
            WINNER_SCREEN["Winner Screen"]:::frontend
        end

        subgraph "Game Components"
            direction TB
            CARD["Card Component"]:::frontend
            PLAY_INFO["Playing Info"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend (Express.js + Socket.IO)"
        direction TB
        SERVER["Server Entry Point\n(server/index.js)"]:::backend
        SESSION_STORE["In-Memory Game Session Store"]:::datastore
        SOCKET_IO["Socket.IO Handlers"]:::backend
    end

    %% Connections
    DNS -->|resolves| VM
    VM -->|serves via HTTPS| HTML
    VM -->|hosts| ENTRY

    HTML -->|loads| ENTRY
    ENTRY -->|imports| SHELL
    SHELL -->|configures routes| HOME_ROUTE
    SHELL -->|configures routes| LOBBY_ROUTE

    SHELL -->|injects| SOCKET_CTX
    SHELL -->|injects| GAME_SESSION_CTX
    SHELL -->|injects| USERS_CTX

    HOME_ROUTE -->|renders| CREATE_ROOM
    HOME_ROUTE -->|renders| JOIN_ROOM

    LOBBY_ROUTE -->|renders| EMOJI_SEL
    LOBBY_ROUTE -->|renders| GAME_SCREEN
    LOBBY_ROUTE -->|renders| USERS_LIST
    LOBBY_ROUTE -->|renders| USER_CARD
    LOBBY_ROUTE -->|renders| WINNER_SCREEN

    GAME_SCREEN -->|uses| CARD
    GAME_SCREEN -->|displays| PLAY_INFO

    ENTRY -->|connects via WebSocket| SOCKET_IO

    SOCKET_IO -->|reads/writes| SESSION_STORE
    SESSION_STORE -->|broadcast updates| SOCKET_IO
    SOCKET_IO -->|emits events| SOCKET_CTX

    SOCKET_CTX -->|provides socket| SHELL
    GAME_SESSION_CTX -->|updates UI on| SHELL
    USERS_CTX -->|updates UI on| SHELL

    %% Stylings
    classDef frontend fill:#D6E9FF,stroke:#333,stroke-width:1px
    classDef backend fill:#D6FFD6,stroke:#333,stroke-width:1px
    classDef infra fill:#FFDABA,stroke:#333,stroke-width:1px
    classDef datastore fill:#FFE0B2,stroke:#333,stroke-width:1px

    %% Click Events
    click ENTRY "https://github.com/krishnagavali/chitrush/blob/main/client/src/main.jsx"
    click SHELL "https://github.com/krishnagavali/chitrush/blob/main/client/src/App.jsx"
    click HTML "https://github.com/krishnagavali/chitrush/blob/main/client/index.html"
    click VITE "https://github.com/krishnagavali/chitrush/blob/main/client/vite.config.js"
    click HOME_ROUTE "https://github.com/krishnagavali/chitrush/blob/main/client/src/Routes/Home.jsx"
    click LOBBY_ROUTE "https://github.com/krishnagavali/chitrush/blob/main/client/src/Routes/Lobby.jsx"
    click CREATE_ROOM "https://github.com/krishnagavali/chitrush/blob/main/client/src/Components/HomeComponents/CreateRoomScreen.jsx"
    click JOIN_ROOM "https://github.com/krishnagavali/chitrush/blob/main/client/src/Components/HomeComponents/JoinRoomScreen.jsx"
    click EMOJI_SEL "https://github.com/krishnagavali/chitrush/blob/main/client/src/Components/LobbyComponents/EmojiSelector.jsx"
    click GAME_SCREEN "https://github.com/krishnagavali/chitrush/blob/main/client/src/Components/LobbyComponents/GameScreen.jsx"
    click USER_CARD "https://github.com/krishnagavali/chitrush/blob/main/client/src/Components/LobbyComponents/UserCard.jsx"
    click USERS_LIST "https://github.com/krishnagavali/chitrush/blob/main/client/src/Components/LobbyComponents/Users.jsx"
    click WINNER_SCREEN "https://github.com/krishnagavali/chitrush/blob/main/client/src/Components/LobbyComponents/WinnerScreen.jsx"
    click CARD "https://github.com/krishnagavali/chitrush/blob/main/client/src/Components/GameComponents/Card.jsx"
    click PLAY_INFO "https://github.com/krishnagavali/chitrush/blob/main/client/src/Components/GameComponents/PlayingInfo.jsx"
    click SOCKET_CTX "https://github.com/krishnagavali/chitrush/blob/main/client/src/Context/SocketContext/SocketContext.jsx"
    click GAME_SESSION_CTX "https://github.com/krishnagavali/chitrush/blob/main/client/src/Context/GameSessionSocket/GameSessionState.jsx"
    click USERS_CTX "https://github.com/krishnagavali/chitrush/blob/main/client/src/Context/UsersContext/UsersContext.jsx"
    click SERVER "https://github.com/krishnagavali/chitrush/blob/main/server/index.js"
    click SESSION_STORE "https://github.com/krishnagavali/chitrush/blob/main/server/index.js"
```
