How pallab-js/offgrid works
OffGrid is a LAN-hosted, local-first messaging and field-tools app: teammates join a room with a shared passphrase, then use browser features through a hub while keeping a local history mirror and queuing offline changes. The graph covers room setup, messaging and files, survival tools, browser sync, and hub persistence. Some capabilities are included from the README and source index even where their implementations were not excerpted; their internal wiring is omitted where evidence is insufficient.
Main entry points: chat.ts Message state · files.ts File state · index.ts HTTP API · join-flow.tsx Join room
Components 26
Room entry
- Join room
src/app/join/join-flow.tsx - Device session
src/stores/session.ts - Room encryption
src/lib/crypto/room.ts
Browser messaging and sync
- Channels and chat
src/components/chat/thread.tsx - Message state
src/stores/chat.ts - File sharing
src/components/files/files-page.tsx - File state
src/stores/files.ts - Transfer API
src/lib/files/api.ts - WebSocket client
src/lib/ws/client.ts - Frame protocol
src/lib/protocol/frames.ts - Local-first sync
src/lib/sync/outbox.ts
Field tools
- Checklists and guides
src/components/checklist/checklist-page.tsx - Offline map and waypoints
src/components/map/map-page.tsx - Beacon signaling
src/components/beacon/beacon-page.tsx - SOS distress
src/components/sos/sos-overlay.tsx - Shared notes
src/components/notes/notes-page.tsx - Status board
src/components/status/status-page.tsx
Hub services
- Hub startup
server/index.ts - HTTP API
server/http/index.ts - WebSocket dispatch
server/ws/dispatch.ts - Live connections
server/ws/registry.ts
Persistence
- Domain repository
server/db/repo.ts - SQLite database
server/db/index.ts - Browser IndexedDB
src/lib/idb/db.ts - Hub file storage
server/http/index.ts
Other components
- Teammate
Connections 29
- Teammate → Join room: joins room
README.md - Join room → Room encryption: derives key
src/app/join/join-flow.tsx - Join room → Device session: saves membership
src/app/join/join-flow.tsx - Teammate → Channels and chat: uses channels
README.md - Channels and chat → Message state: updates messages
src/components/chat/thread.tsx - Message state → WebSocket client: sends frames
src/stores/chat.ts - WebSocket client → Frame protocol: validates frames
src/lib/ws/client.ts - Message state → Local-first sync: queues offline
src/stores/chat.ts - Message state → Browser IndexedDB: stores history
src/stores/chat.ts - Teammate → File sharing: shares files
README.md - File sharing → File state: manages files
src/components/files/files-page.tsx - File state → Transfer API: transfers bytes
src/stores/files.ts - Transfer API → Room encryption: encrypts frames
src/lib/files/api.ts - File state → WebSocket client: syncs metadata
src/stores/files.ts - File state → Browser IndexedDB: caches files
src/stores/files.ts - Teammate → Checklists and guides: uses field kit
README.md - Teammate → Offline map and waypoints: sets waypoints
README.md - Teammate → Beacon signaling: signals beacon
README.md - Teammate → SOS distress: raises distress
README.md - Teammate → Shared notes: shares notes
README.md - Teammate → Status board: checks status
README.md - Hub startup → HTTP API: serves API
server/index.ts - Hub startup → WebSocket dispatch: attaches WebSocket
server/index.ts - HTTP API → Domain repository: handles room data
server/http/index.ts - HTTP API → Live connections: reads presence
server/http/index.ts - HTTP API → Hub file storage: stores uploads
server/http/index.ts - WebSocket dispatch → Domain repository: persists events
server/ws/dispatch.ts - WebSocket dispatch → Live connections: dispatches clients
server/ws/dispatch.ts - Domain repository → SQLite database: reads and writes
server/db/repo.ts