orbit-client-docs/docs/architecture.md

40 lines
1.6 KiB
Markdown

# Architecture
Orbit is a small, modular React app. No framework magic — a thin IRC layer feeds a zustand store,
which renders components.
## Project tree
```
src/
config.ts App.tsx main.tsx index.css
lib/ format.tsx editor.ts ← presentation + editor helpers
ui/ theme.ts prefs.ts viewport.ts
services/ notify.ts push.ts avatars.ts
irc/ parser client modes numerics casemap types caps ctcp
store.ts store/text.ts store/persistence.ts
components/
Chat.tsx ← thin assembler
chat/ MessageList Composer Sidebar Topbar MemberList Banners
settings/ SettingsModal
profile/ ProfileModal
modals/ Modals
Avatar ConnectScreen Turnstile
```
## Layers
- **`irc/`** — the protocol. `client.ts` is the WebSocket transport + CAP negotiation; `parser.ts`,
`modes.ts`, `casemap.ts`, `numerics.ts` are pure primitives. `caps.ts` lists the requested
capabilities.
- **`store.ts`** — turns IRC events into buffers, messages and members (zustand). Pure helpers split
into `store/text.ts` (masking, formatting) and `store/persistence.ts`.
- **`lib/`** — `format.tsx` renders mIRC formatting → React; `editor.ts` is the rich-composer
serialization.
- **`components/`** — the UI, grouped by area (`chat/`, `settings/`, `profile/`, `modals/`).
`Chat.tsx` is a ~30-line assembler.
## Quality
Vitest unit tests cover the pure modules (parser, casemap, masking). Lint + test + build run in CI,
and the self-hosted [push-to-deploy](/docs/push-to-deploy/) gates on the same.