# phash5/crewmate architecture

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

- Interactive diagram: https://gitdiagram.com/phash5/crewmate
- Repository: https://github.com/phash5/crewmate

## Overview

##### Project type and purpose
- This is a single‐page browser prototype of an “Among Us”‐style game, built entirely with HTML5 and JavaScript (p5.js). There is no backend or networking—everything runs in the user’s browser.

##### File structure
- Top‐level files only:
- index.html – hosts the canvas, loads p5.js and sketch.js
- sketch.js – contains the entire game loop, state machine, rendering, input handling, and basic AI
- No separate frontend/backend folders, no server or data stores.

##### README for additional insights
- Game features (movement, tasks, kill/report mechanics, meetings, voting, win conditions) all implemented client‐side
- No external services—future networking is suggested but not yet implemented
- Uses p5.js as the drawing and interaction library

##### Detail is key
- Even though the code base is small, break it into all of the logical modules above
- Don’t skip the tiny AI voter or the win‐condition checker—include them as leaf nodes

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Browser and Library
    subgraph "Browser Environment"
        BE["Browser Environment<br/>(HTML5 + JS runtime)"]:::runtime
        PJ["p5.js Rendering Engine"]:::rendering
        SK["sketch.js"]:::logic
    end

    %% Game Modules Breakdown
    subgraph "Game Modules"
        GL["Game Loop & State Manager"]:::logic
        IH["Input Handler"]:::input
        subgraph "Game Logic Modules"
            PM["Player Module"]:::logic
            TM["Task Module"]:::logic
            KR["Kill/Report Module"]:::logic
            MV["Meeting & Voting Module"]:::logic
            WC["Win Condition Checker"]:::logic
            AI["Basic AI Voter Module"]:::logic
        end
        UI["UI Overlay Components"]:::rendering
    end

    %% Future Extension
    FN["Future Networking Layer"]:::extension

    %% Documentation
    DOC["Project Documentation"]:::docs

    %% Connections
    BE --> PJ
    PJ --> SK
    PJ -->|"draw loop"| GL
    IH -->|"events"| GL
    SK --> GL
    GL --> PM
    GL --> TM
    GL --> KR
    GL --> MV
    GL --> WC
    GL --> AI
    GL --> UI
    UI --> PJ
    DOC -.-> BE
    FN -.-> BE

    %% Click Events
    click BE "https://github.com/phash5/crewmate/blob/main/index.html"
    click PJ "https://github.com/phash5/crewmate/blob/main/index.html"
    click SK "https://github.com/phash5/crewmate/blob/main/sketch.js"
    click GL "https://github.com/phash5/crewmate/blob/main/sketch.js"
    click IH "https://github.com/phash5/crewmate/blob/main/sketch.js"
    click PM "https://github.com/phash5/crewmate/blob/main/sketch.js"
    click TM "https://github.com/phash5/crewmate/blob/main/sketch.js"
    click KR "https://github.com/phash5/crewmate/blob/main/sketch.js"
    click MV "https://github.com/phash5/crewmate/blob/main/sketch.js"
    click WC "https://github.com/phash5/crewmate/blob/main/sketch.js"
    click AI "https://github.com/phash5/crewmate/blob/main/sketch.js"
    click UI "https://github.com/phash5/crewmate/blob/main/sketch.js"
    click DOC "https://github.com/phash5/crewmate/blob/main/README.md"

    %% Styles
    classDef runtime fill:#e8f4fc,stroke:#1f78b4,stroke-width:2px
    classDef rendering fill:#e0f7e9,stroke:#2e7d32,stroke-width:2px
    classDef logic fill:#e0e7ff,stroke:#3f51b5,stroke-width:2px
    classDef input fill:#fff4e0,stroke:#f57c00,stroke-width:2px
    classDef extension fill:#f5f5f5,stroke:#9e9e9e,stroke-dasharray:5,stroke-width:2px
    classDef docs fill:#f0f0f0,stroke:#757575,stroke-width:1px,stroke-dasharray:2
```
