# nemo-lab-repo/cellninjia_desktop architecture

> Architecture diagram of the GitHub repository nemo-lab-repo/cellninjia_desktop, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nemo-lab-repo/cellninjia_desktop
- Repository: https://github.com/nemo-lab-repo/cellninjia_desktop

## Overview

CellNinjia Desktop captures modem diagnostics over USB serial, then either saves raw bytes for later decoding or decodes frames during capture. The decoder preprocesses HDLC-style frames and dispatches messages to the ASN.1 decoding library, which exposes LTE and 5G message decoders. The README also documents NAS, RRC, PDCP, RLC, MAC, and physical-layer coverage; those capabilities are represented at protocol-family level because their implementations live in the library under lib and were not sampled. Edges reflect shown calls or README-documented workflows.

Main entry points: [`lib`](https://github.com/nemo-lab-repo/cellninjia_desktop/tree/master/lib) (ASN.1 decode engine), [`src/main.cpp`](https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/src/main.cpp) (Serial collector), [`tools/decoder/decode.cpp`](https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/tools/decoder/decode.cpp) (Offline decoder CLI), [`src/decode_preprocess.cpp`](https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/src/decode_preprocess.cpp) (Frame preprocessing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Capture and configuration"]
  node_collector["Serial collector<br/>[main.cpp]"]
  node_diag_config["Diagnostic configuration"]
  node_raw_log["Raw capture file"]
end

subgraph group_decode["Frame processing"]
  node_frame_parser["Frame preprocessing"]
  node_live_decode["Live decode output"]
end

subgraph group_protocols["Protocol decoding"]
  node_asn1_engine["ASN.1 decode engine"]
  node_nas["NAS messages<br/>[host.h]"]
  node_rrc["RRC messages<br/>[host.h]"]
  node_pdcp_rlc["PDCP and RLC<br/>[host.h]"]
  node_mac_phy["MAC and physical<br/>[host.h]"]
  node_lte["LTE message decoders<br/>[host.h]"]
end

subgraph group_offline["Offline analysis"]
  node_offline_decoder["Offline decoder CLI<br/>[decode.cpp]"]
  node_decoded_file["Decoded output file"]
end

node_researcher(("Researcher"))
node_phone["Diagnostic modem"]

node_researcher -->|"configures capture"| node_collector
node_phone -->|"sends diagnostics"| node_collector
node_collector -->|"requests configuration"| node_diag_config
node_diag_config -->|"sends message mask"| node_phone
node_collector -->|"writes raw bytes"| node_raw_log
node_collector -->|"passes live bytes"| node_frame_parser
node_frame_parser -->|"dispatches message"| node_asn1_engine
node_asn1_engine -->|"prints decoded data"| node_live_decode
node_researcher -->|"starts batch decode"| node_offline_decoder
node_raw_log -->|"provides input"| node_offline_decoder
node_offline_decoder -->|"passes file bytes"| node_frame_parser
node_offline_decoder -->|"redirects output"| node_decoded_file
node_asn1_engine -.->|"decodes family"| node_nas
node_asn1_engine -.->|"decodes family"| node_rrc
node_asn1_engine -.->|"decodes family"| node_pdcp_rlc
node_asn1_engine -.->|"decodes family"| node_mac_phy
node_asn1_engine -.->|"decodes family"| node_lte

click node_collector "https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/src/main.cpp"
click node_diag_config "https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/src/decode_preprocess.cpp"
click node_frame_parser "https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/src/decode_preprocess.cpp"
click node_offline_decoder "https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/tools/decoder/decode.cpp"
click node_asn1_engine "https://github.com/nemo-lab-repo/cellninjia_desktop/tree/master/lib"
click node_nas "https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/include/asn1/host.h"
click node_rrc "https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/include/asn1/host.h"
click node_pdcp_rlc "https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/include/asn1/host.h"
click node_mac_phy "https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/include/asn1/host.h"
click node_lte "https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/include/asn1/host.h"

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_collector,node_diag_config,node_raw_log toneBlue
class node_frame_parser,node_live_decode toneAmber
class node_asn1_engine,node_nas,node_rrc,node_pdcp_rlc,node_mac_phy,node_lte toneMint
class node_offline_decoder,node_decoded_file toneRose
class node_researcher,node_phone toneIndigo
```

## Components

### Capture and configuration

- [Serial collector](https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/src/main.cpp): `src/main.cpp`
- [Diagnostic configuration](https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/src/decode_preprocess.cpp): `src/decode_preprocess.cpp`
- **Raw capture file**

### Frame processing

- [Frame preprocessing](https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/src/decode_preprocess.cpp): `src/decode_preprocess.cpp`
- **Live decode output**

### Protocol decoding

- [ASN.1 decode engine](https://github.com/nemo-lab-repo/cellninjia_desktop/tree/master/lib): `lib`
- [NAS messages](https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/include/asn1/host.h): `include/asn1/host.h`
- [RRC messages](https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/include/asn1/host.h): `include/asn1/host.h`
- [PDCP and RLC](https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/include/asn1/host.h): `include/asn1/host.h`
- [MAC and physical](https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/include/asn1/host.h): `include/asn1/host.h`
- [LTE message decoders](https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/include/asn1/host.h): `include/asn1/host.h`

### Offline analysis

- [Offline decoder CLI](https://github.com/nemo-lab-repo/cellninjia_desktop/blob/master/tools/decoder/decode.cpp): `tools/decoder/decode.cpp`
- **Decoded output file**

### Other components

- **Researcher**
- **Diagnostic modem**

## Connections

- Researcher → Serial collector: configures capture (evidence: `README.md`)
- Diagnostic modem → Serial collector: sends diagnostics (evidence: `README.md`)
- Serial collector → Diagnostic configuration: requests configuration (evidence: `src/main.cpp`)
- Diagnostic configuration → Diagnostic modem: sends message mask (evidence: `src/decode_preprocess.cpp`)
- Serial collector → Raw capture file: writes raw bytes (evidence: `src/main.cpp`)
- Serial collector → Frame preprocessing: passes live bytes (evidence: `src/main.cpp`)
- Frame preprocessing → ASN.1 decode engine: dispatches message (evidence: `src/decode_preprocess.cpp`)
- ASN.1 decode engine → Live decode output: prints decoded data (evidence: `README.md`)
- Researcher → Offline decoder CLI: starts batch decode (evidence: `README.md`)
- Raw capture file → Offline decoder CLI: provides input (evidence: `README.md`)
- Offline decoder CLI → Frame preprocessing: passes file bytes (evidence: `tools/decoder/decode.cpp`)
- Offline decoder CLI → Decoded output file: redirects output (evidence: `tools/decoder/decode.cpp`)
- ASN.1 decode engine → NAS messages: decodes family
- ASN.1 decode engine → RRC messages: decodes family
- ASN.1 decode engine → PDCP and RLC: decodes family
- ASN.1 decode engine → MAC and physical: decodes family
- ASN.1 decode engine → LTE message decoders: decodes family
