Repository navigation
Architecture
BearSentinel is a React 19 + TypeScript single-page application built with Vite and bundled into a single self-contained HTML file via vite-plugin-singlefile. All logic runs in the browser; there is no backend.
BCD325P2 Scanner (USB)
|
| USB Serial at 115,200 baud
v
SerialMonitor (src/core/SerialMonitor.ts)
|
|-- raw text lines --> onRawLine subscribers
|-- EDACS lines -----> onEDACS subscribers --> ScannerDecoder.parseEDACS()
|-- GLG lines -------> onP25 subscribers --> ScannerDecoder.parseP25()
|-- status changes --> onStatusChange subscribers
v
SentinelStore (src/core/SentinelStore.ts)
|
|-- patches, grants, lcnMap, leaderboard, rawLog, p25Cards, sessionStats
v
React Components (src/components/)
|
|-- PatchMatrix, GrantFeed, Leaderboard, LCNMap, RawLogDrawer, ExportButton
v
Browser UI
The sole interface to the hardware. Responsibilities:
- Opens the serial port at 115,200 baud using the Web Serial API
- Streams incoming bytes through
TextDecoderStream, splitting on newlines - Routes each line to the appropriate event channel based on prefix pattern matching
- Maintains a command queue for outgoing serial writes; processes commands sequentially
- Sends
GLGpolling commands every 150ms when connected (Unified Mode) - Exposes four subscription methods that return unsubscribe functions:
onEDACS(),onP25(),onRawLine(),onStatusChange()
A pre-instantiated singleton (Serial) is exported for application-wide use.
Known issue (fixed in commit 685aa41, April 10, 2026): An earlier version had a this-binding crash when event handlers were detached from the class instance.
A stateless utility class with two static methods:
parseEDACS(line: string): EDACSEvent | null
| Output type | Trigger pattern | Key fields extracted |
|---|---|---|
SiteEvent |
SIT- prefix |
siteId |
PatchEvent |
PAT- + MEM-
|
patchId, memberId
|
GrantEvent |
TG-, CIP, CIV, CNM markers |
talkgroupId, logicalChannel, voiceChannel, unitId, grantType
|
UnknownEvent |
EDW or EDN prefix, unmatched |
raw line only |
parseP25(line: string): P25Event | null
Requires lines beginning with GLG, and at least 10 comma-separated fields. Key fields: tgid, systemName, groupName, channelName, isSquelchOpen.
The application's single source of truth. Implements an external store pattern compatible with React's useSyncExternalStore.
| Key | Type | Description |
|---|---|---|
siteId |
string |
Current EDACS site identifier |
patches |
Map<string, Patch> |
Active patches, keyed by patch ID |
grants |
GrantEvent[] |
Recent voice grants (time-limited) |
lcnMap |
Record<string, string> |
Auto-discovered LCN → VC hex mappings |
p25Cards |
P25Card[] |
Recent P25 talkgroup activity cards |
rawLog |
RawLogEntry[] |
Last 200 raw serial lines |
sessionStats |
SessionStats |
Patch count, grant count, P25 total, session start |
persistentSlers |
Record<string, number> |
Long-term hit counts (localStorage) |
persistentP25 |
Record<string, number> |
Long-term P25 hit counts (localStorage) |
p25HoldId |
string | null |
Currently held P25 talkgroup |
Static lookup table mapping frequency/talkgroup codes to agency name and abbreviation. Two helper functions:
-
agClass(code: string): string— returns a CSS class name for the agency category -
agColor(code: string): string— returns a CSS custom property reference for the agency color
| Tool | Version | Role |
|---|---|---|
| Vite | 8.0.4 | Dev server + production bundler |
| vite-plugin-singlefile | latest | Inlines all assets into one HTML file |
| TypeScript | 6.0.2 | Type checking + transpilation |
| React | 19.2.4 | UI framework |
| Lucide React | 1.8.0 | Icon library |
| ESLint | 9.39.4 | Linting |
The dev server uses HTTPS with a locally generated certificate — required because the Web Serial API is restricted to secure contexts.
BearSentinel/
├── src/
│ ├── components/ # React UI components
│ │ ├── ExportButton.tsx
│ │ ├── GrantFeed.tsx + .css
│ │ ├── LCNMap.tsx + .css
│ │ ├── Leaderboard.tsx + .css
│ │ ├── PatchMatrix.tsx + .css
│ │ └── RawLogDrawer.tsx + .css
│ ├── core/ # Business logic and state
│ │ ├── AgencyDB.ts
│ │ ├── Decoder.ts
│ │ ├── SentinelStore.ts
│ │ ├── SerialMonitor.ts
│ │ └── useSentinel.ts
│ ├── types/
│ │ └── index.ts
│ ├── App.tsx
│ └── main.tsx
├── Scripts/
│ └── cc_hunter.py
├── BearSentinel_v2.html # Pre-built EDACS Exclusive Mode
├── sentinel.html # Pre-built Unified Mode
└── README.md