# kayamasoft/ksmeasuring architecture

> Architecture diagram of the GitHub repository kayamasoft/ksmeasuring, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kayamasoft/ksmeasuring
- Repository: https://github.com/kayamasoft/ksmeasuring

## Overview

##### Project type and purpose
- This is a native Android application (“app” module) written in Kotlin/Jetpack Compose.
- Its goal is to collect and display mobile network metrics (RSRP, SINR, RSRQ, speeds), graph histories, and record logs as CSV.

##### File structure
Top-level:
- build files (Gradle Kotlin DSL)
- “app/” module containing APK output, Proguard, source, resources, tests
app/src/main/java/com/kayamasoft/ksmeasuring:
- MainActivity.kt – host for the Compose UI
- SignalLoggingService.kt – background Service for polling and logging
- BandMapper.kt – helper to map raw radio parameters
- ui/theme – Compose theming
app/src/main/res: layouts, drawables, XML rules (backup, data extraction)
Tests in androidTest/ and test/

##### README insights
- Uses Android permissions (location, phone state, network, storage)
- Writes CSV under /Documents/ksmeasuring
- Displays graphs (RSRP history), tables, neighbor-cell lists

##### Main components and their interactions
A. Android UI Layer
– MainActivity + Compose screens for:
- Real-time metrics display
- Neighbor-cell list
- RSRP history graph
- CSV log download interface
B. SignalLoggingService (Background Service)
– Runs on a periodic scheduler or bound by the UI
– Invokes Android TelephonyManager, ConnectivityManager, LocationManager to fetch: RSRP, SINR, RSRQ, speed, neighbors
– Emits updates via a local Binder or LiveData/Flow
– Appends records to CSV file in external storage
C. File Storage
– Android File API writing to Documents/ksmeasuring/*.csv
D. Android OS Telephony & Network APIs
– TelephonyManager for radio metrics
– ConnectivityManager for data rates
– LocationManager for cell info if needed
E. Optional Charting Library (third-party or Compose Canvas)
– Renders RSRP history graph

##### Architectural patterns and principles
- Separation of concerns: UI vs. background measurement vs. storage
- Service pattern: long-running work in SignalLoggingService
- Unidirectional data flow: Service → UI observers → screens
- Single Android module: no microservices or remote backend

## Diagram (Mermaid)

```mermaid
graph TB
  subgraph "Android App"
    subgraph "UI Layer"
      MainActivity["MainActivity & Compose Screens"]:::ui
      Screens["Compose Screens (Graphs, Tables, Neighbor List, CSV Download)"]:::ui
      Theming["Compose Theme & Styles"]:::ui
    end
    subgraph "Service Layer"
      Service["SignalLoggingService"]:::service
      Mapper["BandMapper"]:::service
    end
    subgraph "Storage"
      CSV["CSV Writer"]:::storage
    end
    Manifest["AndroidManifest.xml"]:::config
    BackupRules["Backup Rules (backup_rules.xml)"]:::config
    DataExtraction["Data Extraction Rules (data_extraction_rules.xml)"]:::config
  end

  subgraph "Android OS APIs"
    Telephony["TelephonyManager"]:::api
    Connectivity["ConnectivityManager"]:::api
    Location["LocationManager"]:::api
  end

  ExternalStorage["External Storage (Documents/ksmeasuring/*.csv)"]:::external

  MainActivity -->|"binds to"| Service
  Service -->|"fetchMetrics()"| Telephony
  Service -->|"fetchMetrics()"| Connectivity
  Service -->|"fetchMetrics()"| Location
  Service -->|"emitFlow()"| Screens
  Service -->|"writeCsv()"| CSV
  CSV -->|"stores files"| ExternalStorage

  click MainActivity "https://github.com/kayamasoft/ksmeasuring/blob/master/app/src/main/java/com/kayamasoft/ksmeasuring/MainActivity.kt"
  click Screens "https://github.com/kayamasoft/ksmeasuring/tree/master/app/src/main/java/com/kayamasoft/ksmeasuring/ui"
  click Theming "https://github.com/kayamasoft/ksmeasuring/tree/master/app/src/main/java/com/kayamasoft/ksmeasuring/ui/theme"
  click Service "https://github.com/kayamasoft/ksmeasuring/blob/master/app/src/main/java/com/kayamasoft/ksmeasuring/SignalLoggingService.kt"
  click Mapper "https://github.com/kayamasoft/ksmeasuring/blob/master/app/src/main/java/com/kayamasoft/ksmeasuring/BandMapper.kt"
  click BackupRules "https://github.com/kayamasoft/ksmeasuring/blob/master/app/src/main/res/xml/backup_rules.xml"
  click DataExtraction "https://github.com/kayamasoft/ksmeasuring/blob/master/app/src/main/res/xml/data_extraction_rules.xml"
  click Manifest "https://github.com/kayamasoft/ksmeasuring/blob/master/app/src/main/AndroidManifest.xml"

  classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6
  classDef service fill:#DFF2D8,stroke:#28a745,color:#28a745
  classDef storage fill:#FFE5B4,stroke:#FF8C00,color:#8B4513
  classDef api fill:#E2E3E5,stroke:#6c757d,color:#6c757d
  classDef external fill:#F5E1C3,stroke:#A0522D,color:#A0522D
  classDef config fill:#F0F0F0,stroke:#343a40,color:#343a40
```
