# ottomated/crewlink architecture

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

- Interactive diagram: https://gitdiagram.com/ottomated/crewlink
- Repository: https://github.com/ottomated/crewlink

## Overview

#### Purpose and Runtime
CrewLink is a desktop Electron client providing proximity voice chat for Among Us. It reads live game state from the local Among Us process, sends/receives voice through a separate CrewLink server, and renders an in-game-style overlay plus settings UI. Packaging targets a Windows installer via `electron-builder.yml`.

#### Process Entry Points
The Electron main process starts at `src/main/index.ts`; it owns native process access, game-state polling, and IPC registration. The renderer starts at `src/renderer/index.ts` and mounts the React UI rooted at `src/renderer/App.tsx`. Shared cross-process contracts live in `src/common/ipc-messages.ts` and `src/common/AmongUsState.ts`.

#### Game Hook and State Acquisition
`src/main/hook.ts` attaches to the Among Us process, while `src/main/GameReader.ts` interprets process memory into player/game information. `src/main/offsetStore.ts` centralizes version-sensitive memory offsets. This is the critical native boundary: failure or incompatibility is surfaced through shared errors in `src/common/Errors.ts`, rather than renderer-side memory access.

#### Main-to-Renderer Control Boundary
`src/main/ipc-handlers.ts` exposes main-process operations and state updates to the UI using Electron IPC. `src/common/ipc-messages.ts` defines message names/contracts, and `src/common/ISettings.d.ts` defines persisted or exchanged settings shape. Renderer components should request privileged actions through IPC; native hooks and game memory remain isolated in `src/main/`.

#### Voice and Proximity Pipeline
The renderer contains the real-time voice-facing UI/logic, centered on `src/renderer/Voice.tsx` and `src/renderer/vad.ts`. Live game positions from the main process drive proximity/spatial-audio decisions for remote participants. Voice connectivity depends on the externally deployed CrewLink server repository; the README recommends a private server for development. Audio assets include `static/chime.mp3` and `static/reverb.ogx`.

#### User Interface and Overlay
`src/renderer/App.tsx` composes the primary client experience. `src/renderer/Overlay.tsx` presents game-adjacent player/voice state, while `src/renderer/Menu.tsx` and `src/renderer/settings/Settings.tsx` provide configuration and controls. Shared renderer state is provided through `src/renderer/contexts.tsx`; visual behavior is split between `src/renderer/css/index.css` and `src/renderer/css/overlay.css`.

#### Identity and Cosmetics
Player representation is rendered through `src/renderer/Avatar.tsx` and mapped from game cosmetics in `src/renderer/cosmetics.ts`. Static cosmetic resources are bundled under `static/hats`, `static/skins`, and `static/players`, allowing the overlay to mirror Among Us player appearance without querying an external asset service.

#### Infrastructure and Constraints
The app is TypeScript/React in Electron, with native memory integration represented by `src/main/memoryjs.d.ts` and binary-structure typing in `src/main/structron.d.ts`. It requires Node.js/Yarn for development and Python as a listed prerequisite. CI is AppVeyor (`appveyor.yml`); release packaging is configured in `electron-builder.yml`.

Main entry points: [`src/renderer/App.tsx`](https://github.com/ottomated/crewlink/blob/master/src/renderer/App.tsx) (App shell), [`src/renderer/Voice.tsx`](https://github.com/ottomated/crewlink/blob/master/src/renderer/Voice.tsx) (Voice client), [`src/main/hook.ts`](https://github.com/ottomated/crewlink/blob/master/src/main/hook.ts) (Game hook), [`src/main/GameReader.ts`](https://github.com/ottomated/crewlink/blob/master/src/main/GameReader.ts) (Game reader)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_main["Electron Main"]
  node_main_entry["Main entry<br/>Electron main<br/>[index.ts]"]
  node_hook["Game hook<br/>process attachment<br/>[hook.ts]"]
  node_reader["Game reader<br/>memory parser<br/>[GameReader.ts]"]
  node_offsets["Offset store<br/>memory offsets<br/>[offsetStore.ts]"]
  node_ipc_handlers["IPC handlers<br/>Electron IPC<br/>[ipc-handlers.ts]"]
  node_memory_types["Native type declarations<br/>TypeScript declarations<br/>[memoryjs.d.ts]"]
end

subgraph group_shared["Shared Contracts"]
  node_ipc_contracts["IPC messages<br/>shared contracts<br/>[ipc-messages.ts]"]
  node_game_state["Among Us state<br/>shared state model<br/>[AmongUsState.ts]"]
  node_settings_contract["Settings contract<br/>shared settings type<br/>[ISettings.d.ts]"]
  node_errors["Shared errors<br/>error contracts<br/>[Errors.ts]"]
end

subgraph group_renderer["Electron Renderer"]
  node_renderer_entry["Renderer entry<br/>React bootstrap<br/>[index.ts]"]
  node_app["App shell<br/>React root<br/>[App.tsx]"]
  node_voice["Voice client<br/>real-time voice<br/>[Voice.tsx]"]
  node_vad["Voice activity detection<br/>audio processing<br/>[vad.ts]"]
  node_overlay["Game overlay<br/>React overlay<br/>[Overlay.tsx]"]
  node_settings_ui["Menu and settings<br/>React controls<br/>[Settings.tsx]"]
  node_renderer_state["Renderer contexts<br/>React state<br/>[contexts.tsx]"]
  node_avatar["Avatar cosmetics<br/>player rendering<br/>[Avatar.tsx]"]
end

node_amongus{{"Among Us process<br/>external game"}}
node_crewlink_server{{"CrewLink server<br/>external voice service"}}
node_audio_assets["Audio assets<br/>bundled media<br/>[chime.mp3]"]

node_main_entry -->|"starts"| node_hook
node_main_entry -->|"registers"| node_ipc_handlers
node_hook -->|"attaches to"| node_amongus
node_hook -->|"enables reads"| node_reader
node_reader -->|"uses"| node_offsets
node_reader -.->|"uses native bindings"| node_memory_types
node_reader -->|"produces"| node_game_state
node_hook -->|"reports failures"| node_errors
node_ipc_handlers -->|"implements"| node_ipc_contracts
node_ipc_handlers -->|"publishes"| node_game_state
node_ipc_handlers -->|"exchanges"| node_settings_contract
node_renderer_entry -->|"mounts"| node_app
node_app -->|"provides"| node_renderer_state
node_app -->|"renders"| node_overlay
node_app -->|"renders"| node_settings_ui
node_app -->|"hosts"| node_voice
node_renderer_state -->|"uses IPC"| node_ipc_contracts
node_renderer_state -->|"consumes"| node_game_state
node_voice -->|"uses"| node_vad
node_voice -->|"connects to"| node_crewlink_server
node_voice -->|"plays"| node_audio_assets
node_overlay -->|"renders players with"| node_avatar
node_voice -->|"uses positions"| node_game_state

click node_main_entry "https://github.com/ottomated/crewlink/blob/master/src/main/index.ts"
click node_hook "https://github.com/ottomated/crewlink/blob/master/src/main/hook.ts"
click node_reader "https://github.com/ottomated/crewlink/blob/master/src/main/GameReader.ts"
click node_offsets "https://github.com/ottomated/crewlink/blob/master/src/main/offsetStore.ts"
click node_ipc_handlers "https://github.com/ottomated/crewlink/blob/master/src/main/ipc-handlers.ts"
click node_memory_types "https://github.com/ottomated/crewlink/blob/master/src/main/memoryjs.d.ts"
click node_ipc_contracts "https://github.com/ottomated/crewlink/blob/master/src/common/ipc-messages.ts"
click node_game_state "https://github.com/ottomated/crewlink/blob/master/src/common/AmongUsState.ts"
click node_settings_contract "https://github.com/ottomated/crewlink/blob/master/src/common/ISettings.d.ts"
click node_errors "https://github.com/ottomated/crewlink/blob/master/src/common/Errors.ts"
click node_renderer_entry "https://github.com/ottomated/crewlink/blob/master/src/renderer/index.ts"
click node_app "https://github.com/ottomated/crewlink/blob/master/src/renderer/App.tsx"
click node_voice "https://github.com/ottomated/crewlink/blob/master/src/renderer/Voice.tsx"
click node_vad "https://github.com/ottomated/crewlink/blob/master/src/renderer/vad.ts"
click node_overlay "https://github.com/ottomated/crewlink/blob/master/src/renderer/Overlay.tsx"
click node_settings_ui "https://github.com/ottomated/crewlink/blob/master/src/renderer/settings/Settings.tsx"
click node_renderer_state "https://github.com/ottomated/crewlink/blob/master/src/renderer/contexts.tsx"
click node_avatar "https://github.com/ottomated/crewlink/blob/master/src/renderer/Avatar.tsx"
click node_audio_assets "https://github.com/ottomated/crewlink/blob/master/static/chime.mp3"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main_entry,node_hook,node_reader,node_offsets,node_ipc_handlers,node_memory_types toneBlue
class node_ipc_contracts,node_game_state,node_settings_contract,node_errors toneAmber
class node_renderer_entry,node_app,node_voice,node_vad,node_overlay,node_settings_ui,node_renderer_state,node_avatar toneMint
class node_amongus,node_crewlink_server,node_audio_assets toneNeutral
```

## Components

### Electron Main

Privileged native runtime and game-state bridge.

- [Main entry](https://github.com/ottomated/crewlink/blob/master/src/main/index.ts): Electron main · `src/main/index.ts`
- [Game hook](https://github.com/ottomated/crewlink/blob/master/src/main/hook.ts): process attachment · `src/main/hook.ts`
- [Game reader](https://github.com/ottomated/crewlink/blob/master/src/main/GameReader.ts): memory parser · Interprets game memory as player and game state. · `src/main/GameReader.ts`
- [Offset store](https://github.com/ottomated/crewlink/blob/master/src/main/offsetStore.ts): memory offsets · Version-sensitive Among Us memory offsets. · `src/main/offsetStore.ts`
- [IPC handlers](https://github.com/ottomated/crewlink/blob/master/src/main/ipc-handlers.ts): Electron IPC · Exposes privileged operations and state updates. · `src/main/ipc-handlers.ts`
- [Native type declarations](https://github.com/ottomated/crewlink/blob/master/src/main/memoryjs.d.ts): TypeScript declarations · `src/main/memoryjs.d.ts`

### Shared Contracts

Cross-process message, state, settings, and error types.

- [IPC messages](https://github.com/ottomated/crewlink/blob/master/src/common/ipc-messages.ts): shared contracts · `src/common/ipc-messages.ts`
- [Among Us state](https://github.com/ottomated/crewlink/blob/master/src/common/AmongUsState.ts): shared state model · `src/common/AmongUsState.ts`
- [Settings contract](https://github.com/ottomated/crewlink/blob/master/src/common/ISettings.d.ts): shared settings type · `src/common/ISettings.d.ts`
- [Shared errors](https://github.com/ottomated/crewlink/blob/master/src/common/Errors.ts): error contracts · Reports hook and compatibility failures to the UI. · `src/common/Errors.ts`

### Electron Renderer

React UI, overlay, and real-time voice experience.

- [Renderer entry](https://github.com/ottomated/crewlink/blob/master/src/renderer/index.ts): React bootstrap · `src/renderer/index.ts`
- [App shell](https://github.com/ottomated/crewlink/blob/master/src/renderer/App.tsx): React root · Composes the primary client experience. · `src/renderer/App.tsx`
- [Voice client](https://github.com/ottomated/crewlink/blob/master/src/renderer/Voice.tsx): real-time voice · Applies proximity and spatial-audio behavior for participants. · `src/renderer/Voice.tsx`
- [Voice activity detection](https://github.com/ottomated/crewlink/blob/master/src/renderer/vad.ts): audio processing · `src/renderer/vad.ts`
- [Game overlay](https://github.com/ottomated/crewlink/blob/master/src/renderer/Overlay.tsx): React overlay · Shows game-adjacent player and voice state. · `src/renderer/Overlay.tsx`
- [Menu and settings](https://github.com/ottomated/crewlink/blob/master/src/renderer/settings/Settings.tsx): React controls · `src/renderer/settings/Settings.tsx`
- [Renderer contexts](https://github.com/ottomated/crewlink/blob/master/src/renderer/contexts.tsx): React state · `src/renderer/contexts.tsx`
- [Avatar cosmetics](https://github.com/ottomated/crewlink/blob/master/src/renderer/Avatar.tsx): player rendering · Maps game cosmetics to bundled player visuals. · `src/renderer/Avatar.tsx`

### Other components

- **Among Us process**: external game · Local process providing live game state.
- **CrewLink server**: external voice service · Separately deployed voice connectivity backend.
- [Audio assets](https://github.com/ottomated/crewlink/blob/master/static/chime.mp3): bundled media · `static/chime.mp3`

## Connections

- Main entry → Game hook: starts
- Main entry → IPC handlers: registers
- Game hook → Among Us process: attaches to
- Game hook → Game reader: enables reads
- Game reader → Offset store: uses
- Game reader → Native type declarations: uses native bindings
- Game reader → Among Us state: produces
- Game hook → Shared errors: reports failures
- IPC handlers → IPC messages: implements
- IPC handlers → Among Us state: publishes
- IPC handlers → Settings contract: exchanges
- Renderer entry → App shell: mounts
- App shell → Renderer contexts: provides
- App shell → Game overlay: renders
- App shell → Menu and settings: renders
- App shell → Voice client: hosts
- Renderer contexts → IPC messages: uses IPC
- Renderer contexts → Among Us state: consumes
- Voice client → Voice activity detection: uses
- Voice client → CrewLink server: connects to
- Voice client → Audio assets: plays
- Game overlay → Avatar cosmetics: renders players with
- Voice client → Among Us state: uses positions
