canmetry

Architecture

Canmetry Community is a fully client-side CAN log analysis app built with React, TanStack Router, and browser-side parsers for BLF / ASC / CSV / MF4 plus DBC decoding.

The repository is organized around one core idea:

Load raw CAN logs and DBC files in the browser, build an in-memory analysis session, then expose the same session through three UI surfaces: Graph, Trace, and DBC.

High-level flow

User files
  ├─ CAN log (.blf / .asc / .csv / .log / .mf4)
  └─ DBC files (.dbc)
        ↓
Browser file reads
        ↓
Format-specific parsers in src/lib/can/
        ↓
ClientAnalysisSession (single local workspace state)
        ├─ rawFrames
        ├─ decoded signal points
        ├─ DBC metadata
        ├─ channel ↔ DBC mapping
        └─ saved workspace layout
        ↓
UI tabs
  ├─ Graph  (decoded signals / chart workspace)
  ├─ Trace  (raw frames / decoded row detail)
  └─ DBC    (DBC browser / bit layout / attributes)

Runtime model

Single-page app shell

This means all three views share the same loaded files and session state.

Session-first architecture

The main client-side state container is ClientAnalysisSession in src/modules/analyses/client-session.ts.

It owns:

The session is exposed to React through useSyncExternalStore, so the app can keep one mutable analysis workspace without adding a global client state library.

Core modules

1. Log parsing

Location: src/lib/can/

Parsers are implemented in the browser and do not require a backend.

Shared frame shape:

The parser stage is intentionally loss-light: it first turns every supported format into a common frame model before higher-level decoding happens.

2. DBC loading and decoding

Location: src/lib/can/client-decode.ts

Responsibilities:

Important behavior:

3. DBC catalog / viewer model

Location: src/lib/can/dbc-catalog.ts

This module builds a richer inspection model from DBC text for the DBC tab:

This is separate from the runtime decode index because the DBC tab needs browse-oriented structures, not just ID lookup.

4. Project/workspace persistence

Location:

Project export/import stores:

The exported file is .blfproject.json.

UI architecture

Main route and tab layout

src/routes/index.tsx renders a shared top toolbar and one of three panes:

The active tab is persisted into the layout snapshot so imported projects can reopen in the same view.

Graph

Main modules:

The Graph tab is a small workspace inside the app:

The chart implementation is custom rather than Recharts-driven, because the app needs:

Trace

Main modules:

Trace uses pre-extracted rawFrames from the session and layers on:

DBC

Main modules:

The DBC tab is independent from signal parsing in the sense that:

The layout is optimized for fast inspection:

Data lifecycle

Loading a log

  1. User selects a log file
  2. ClientAnalysisSession.loadLog() validates size and format
  3. extractRawFramesFromLog() scans frames into a common raw row model
  4. Channels are detected from the parsed frames
  5. Graph/Trace reset to uploaded state

Loading DBC files

  1. User adds one or more .dbc files
  2. DBC text is read in-browser
  3. Files are stored in session by generated local IDs
  4. No decode happens yet until channel mapping + parse

Parsing

  1. User maps DBC files to channels on the Channel Mapping card
  2. Clicking Start parsing on that card applies the mapping and starts decode (no separate menu step required)
  3. decodeLogWithDbcs() iterates log frames again
  4. Matching frame IDs are decoded into signal values
  5. A signal catalog + point arrays are built
  6. Trace rows are annotated with frame/message names
  7. Graph becomes ready and auto-adds the first signal when appropriate

Deployment model

The app is designed for static hosting.

No server-side parsing, database, queue, or worker is required for the community edition.

Important implementation constraints

Key files

Path Purpose
src/routes/index.tsx Main page and Graph/Trace/DBC tab switching
src/modules/analyses/client-session.ts Local analysis session state
src/lib/can/client-decode.ts DBC decode pipeline, raw rows, parse results
src/lib/can/iterate-log.ts Format detection and parser dispatch
src/lib/analysis-project.ts Project export/import schema
src/blocks/signal-workspace/ Graph workspace
src/blocks/frame-viewer/ Trace UI
src/blocks/dbc-viewer/ DBC browser UI