# rolandasrazma/rrpeeanalyzer architecture

> Architecture diagram of the GitHub repository rolandasrazma/rrpeeanalyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rolandasrazma/rrpeeanalyzer
- Repository: https://github.com/rolandasrazma/rrpeeanalyzer

## Overview

1. **Project shape**
   - This is a single iOS app, built in Xcode with CocoaPods, centered on capturing photos of urine test strips and analyzing their color pads.
   - The app is not a generic camera app: the hardware setup in the README is part of the system boundary. The phone is mounted in a box with controlled lighting so image processing becomes reliable.

2. **Top-level runtime**
   - The app starts from `main.m` into `RRAppDelegate`, then into a storyboard-driven UI under `Resources/Base.lproj/Main.storyboard`.
   - The main execution path is a standard iOS app lifecycle, but the core domain logic lives in the model layer and is invoked from view controllers.

3. **UI / interaction layer**
   - `RRCaptureViewController` is the capture workflow entry point: it likely manages live camera view, taking snapshots, and presenting results.
   - `RRStripSetupViewController` and `RRTestColorSetupViewController` are calibration/setup screens. These suggest the app has explicit configuration steps for strip geometry and expected color references rather than fully automatic analysis only.

4. **Capture and session management**
   - `RRCaptureSession` is the key capture abstraction. It likely wraps camera/session state, frame acquisition, and timing, so controllers don’t talk directly to low-level camera APIs.
   - This forms the boundary between UIKit-driven screens and the image-processing pipeline.

5. **Analysis engine**
   - `RRStripAnalyzer` is the core domain component. It is implemented in `RRStripAnalyzer.mm`, which means Objective-C++ is used so the app can bridge between Cocoa objects and C++/OpenCV-style processing.
   - Based on the README, this engine detects the test-strip squares/rectangles and compares sampled colors to known values to derive the medical strip readings.

6. **Image-processing support**
   - The `Support` folder contains several `UIImage` categories and C++ helpers that likely normalize image input, convert between UIKit images and OpenCV/cv::Mat representations, and perform drawing/transform/color utility work.
   - `UIImage+OpenCVAdditions.mm` and `RRCVAdditions.cpp/.hpp` are the most important bridging files: they indicate the project depends on OpenCV-style processing even though the app UI is native iOS.

7. **Calibration and domain data**
   - `Resources/DUS10/DUS10.plist` appears to hold reference data for a specific test-strip product or color model.
   - This is an important data boundary: analysis is not purely algorithmic; it is parameterized by strip-specific calibration/reference values stored as app resources.

8. **Data flow through the system**
   - User mounts the strip in the physical jig, opens the app, and captures an image.
   - The image passes through the capture/session layer, then into the analyzer, which identifies strip regions, transforms the image if needed, and compares each pad’s color against configured references.
   - Results are then surfaced back through the view controllers for display or review.

9. **Hardware assumptions that affect architecture**
   - The README makes clear the app depends on controlled, repeatable lighting and a fixed strip position. That means the software architecture is intentionally coupled to a physical enclosure.
   - This reduces the need for complex general-purpose computer vision, because the camera position, strip location, and illumination are constrained.

10. **Persistence and test assets**
   - The `Images/Samples` folder contains time-series sample captures, which likely served as development/test inputs for tuning the analyzer.
   - The `RRStripAnalyzerTest` target indicates there is at least some unit-test coverage around the analyzer logic, reinforcing that the analysis pipeline is a separable subsystem.

11. **External dependencies / tooling**
   - CocoaPods is used, and OpenCV is the major external technology implied by the code and README.
   - The important architectural implication is that this app is a hybrid native iOS + OpenCV image-processing application, not a purely UIKit-driven app.

12. **How to draw the architecture**
   - A good diagram should show four main blocks: iOS UI controllers, capture/session management, OpenCV-based strip analysis, and calibration/resource data.
   - The hardware enclosure and lighting should be shown as an external physical dependency feeding the camera input, because the app’s accuracy depends on it as much as on the code.

Main entry points: [`RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRStripAnalyzer/RRStripAnalyzer.mm`](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRStripAnalyzer/RRStripAnalyzer.mm) (Strip analyzer), [`RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRCaptureViewController.m`](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRCaptureViewController.m) (Capture screen), [`RRPeeAnalyzer/RRPeeAnalizer/Resources/Base.lproj/Main.storyboard`](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Resources/Base.lproj/Main.storyboard) (Main storyboard), [`RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRCaptureSession.m`](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRCaptureSession.m) (Capture session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_physical["Physical setup"]
  node_enclosure["Light box<br/>physical fixture"]
end

subgraph group_ui["UIKit flow"]
  node_main_m["main.m<br/>app entry<br/>[main.m]"]
  node_app_delegate["App delegate<br/>lifecycle<br/>[RRAppDelegate.m]"]
  node_storyboard["Main storyboard<br/>ui layout<br/>[Main.storyboard]"]
  node_capture_vc["Capture screen<br/>view controller"]
  node_strip_setup_vc["Strip setup<br/>view controller"]
  node_color_setup_vc["Color setup<br/>view controller"]
end

subgraph group_capture["Capture boundary"]
  node_capture_session["Capture session<br/>camera/session<br/>[RRCaptureSession.m]"]
end

subgraph group_analysis["Strip analysis"]
  node_strip_analyzer["Strip analyzer<br/>opencv analysis<br/>[RRStripAnalyzer.mm]"]
  node_strip_test["Analyzer test<br/>test harness"]
end

subgraph group_support["Support code"]
  node_cv_additions["CV additions<br/>c++ bridge<br/>[RRCVAdditions.cpp]"]
  node_ui_image_opencv["UIImage+OpenCV<br/>bridge category"]
  node_ui_image_transform["UIImage transforms<br/>image helpers"]
  node_ui_image_draw["UIImage drawing<br/>image helpers"]
  node_ui_image_color["UIImage color<br/>image helpers"]
  node_ui_image_string["UIImage strings<br/>utility category"]
end

subgraph group_data["Calibration data"]
  node_dus10["DUS10 plist<br/>calibration data<br/>[DUS10.plist]"]
  node_samples["Sample images<br/>reference images"]
end

node_enclosure -->|"feeds images"| node_capture_vc
node_main_m -->|"starts"| node_app_delegate
node_app_delegate -->|"loads"| node_storyboard
node_storyboard -->|"opens"| node_capture_vc
node_storyboard -->|"opens"| node_strip_setup_vc
node_storyboard -->|"opens"| node_color_setup_vc
node_capture_vc -->|"uses"| node_capture_session
node_capture_vc -->|"invokes"| node_strip_analyzer
node_strip_setup_vc -->|"configures"| node_strip_analyzer
node_color_setup_vc -->|"configures"| node_strip_analyzer
node_capture_session -->|"converts"| node_ui_image_opencv
node_strip_analyzer -->|"relies on"| node_cv_additions
node_strip_analyzer -->|"transforms"| node_ui_image_transform
node_strip_analyzer -->|"annotates"| node_ui_image_draw
node_strip_analyzer -->|"samples"| node_ui_image_color
node_strip_analyzer -->|"reads refs"| node_dus10
node_strip_analyzer -.->|"tuned by"| node_samples
node_strip_analyzer -.->|"validated by"| node_strip_test
node_capture_session -->|"serves"| node_capture_vc
node_strip_analyzer -->|"returns results"| node_capture_vc

click node_main_m "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/main.m"
click node_app_delegate "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/RRAppDelegate.m"
click node_storyboard "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Resources/Base.lproj/Main.storyboard"
click node_capture_vc "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRCaptureViewController.m"
click node_strip_setup_vc "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRStripSetupViewController.m"
click node_color_setup_vc "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRTestColorSetupViewController.m"
click node_capture_session "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRCaptureSession.m"
click node_strip_analyzer "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRStripAnalyzer/RRStripAnalyzer.mm"
click node_strip_test "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRStripAnalyzer/RRStripAnalyzerTest.m"
click node_cv_additions "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/RRCVAdditions/RRCVAdditions.cpp"
click node_ui_image_opencv "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+OpenCVAdditions.mm"
click node_ui_image_transform "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+RRTransformsAdditions.m"
click node_ui_image_draw "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+RRDrawingAddition.m"
click node_ui_image_color "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+UIColorAdditions.m"
click node_ui_image_string "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+NSStringAdditions.m"
click node_dus10 "https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Resources/DUS10/DUS10.plist"
click node_samples "https://github.com/rolandasrazma/rrpeeanalyzer/tree/master/Images/Samples"

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_enclosure toneBlue
class node_main_m,node_app_delegate,node_storyboard,node_capture_vc,node_strip_setup_vc,node_color_setup_vc toneAmber
class node_capture_session toneMint
class node_strip_analyzer,node_strip_test toneRose
class node_cv_additions,node_ui_image_opencv,node_ui_image_transform,node_ui_image_draw,node_ui_image_color,node_ui_image_string toneIndigo
class node_dus10,node_samples toneTeal
```

## Components

### Physical setup

External enclosure and lighting that constrain capture conditions.

- **Light box**: physical fixture · Controlled enclosure and fixed lighting used to make strip images repeatable.

### UIKit flow

Storyboard-driven screens and app lifecycle.

- [main.m](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/main.m): app entry · iOS application entry point. · `RRPeeAnalyzer/RRPeeAnalizer/main.m`
- [App delegate](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/RRAppDelegate.m): lifecycle · Application startup and lifecycle coordination. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/RRAppDelegate.m`
- [Main storyboard](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Resources/Base.lproj/Main.storyboard): ui layout · Storyboard defining the primary screen flow. · `RRPeeAnalyzer/RRPeeAnalizer/Resources/Base.lproj/Main.storyboard`
- [Capture screen](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRCaptureViewController.m): view controller · Entry point for capture, snapshot, and result display. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRCaptureViewController.m`
- [Strip setup](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRStripSetupViewController.m): view controller · Calibration screen for strip geometry and placement. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRStripSetupViewController.m`
- [Color setup](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRTestColorSetupViewController.m): view controller · Calibration screen for expected color references. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/Controller/RRTestColorSetupViewController.m`

### Capture boundary

Camera/session coordination between UI and analysis.

- [Capture session](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRCaptureSession.m): camera/session · Wraps camera state, frame acquisition, and capture timing. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRCaptureSession.m`

### Strip analysis

OpenCV-backed image processing and strip interpretation.

- [Strip analyzer](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRStripAnalyzer/RRStripAnalyzer.mm): opencv analysis · Objective-C++ core that detects pads and compares colors. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRStripAnalyzer/RRStripAnalyzer.mm`
- [Analyzer test](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRStripAnalyzer/RRStripAnalyzerTest.m): test harness · Target-specific test coverage for the analysis pipeline. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/Model/RRStripAnalyzer/RRStripAnalyzerTest.m`

### Support code

Image conversion, transforms, drawing, and color helpers.

- [CV additions](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/RRCVAdditions/RRCVAdditions.cpp): c++ bridge · C++ helper layer for OpenCV-oriented processing. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/RRCVAdditions/RRCVAdditions.cpp`
- [UIImage+OpenCV](https://github.com/rolandasrazma/rrpeeanalyzer/blob/HEAD/RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage%20Additions/UIImage%2BOpenCVAdditions.mm): bridge category · Converts between UIKit images and OpenCV-friendly representations. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+OpenCVAdditions.mm`
- [UIImage transforms](https://github.com/rolandasrazma/rrpeeanalyzer/blob/HEAD/RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage%20Additions/UIImage%2BRRTransformsAdditions.m): image helpers · Image transformation utilities used by the analysis flow. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+RRTransformsAdditions.m`
- [UIImage drawing](https://github.com/rolandasrazma/rrpeeanalyzer/blob/HEAD/RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage%20Additions/UIImage%2BRRDrawingAddition.m): image helpers · Drawing utilities for overlays and diagnostics. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+RRDrawingAddition.m`
- [UIImage color](https://github.com/rolandasrazma/rrpeeanalyzer/blob/HEAD/RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage%20Additions/UIImage%2BUIColorAdditions.m): image helpers · Color-related helpers for sampling and comparison support. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+UIColorAdditions.m`
- [UIImage strings](https://github.com/rolandasrazma/rrpeeanalyzer/blob/HEAD/RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage%20Additions/UIImage%2BNSStringAdditions.m): utility category · String-related image helper category. · `RRPeeAnalyzer/RRPeeAnalizer/Classes/Support/UIImage Additions/UIImage+NSStringAdditions.m`

### Calibration data

Strip-specific reference resources and sample captures.

- [DUS10 plist](https://github.com/rolandasrazma/rrpeeanalyzer/blob/master/RRPeeAnalyzer/RRPeeAnalizer/Resources/DUS10/DUS10.plist): calibration data · Reference values for a specific test-strip product or color model. · `RRPeeAnalyzer/RRPeeAnalizer/Resources/DUS10/DUS10.plist`
- [Sample images](https://github.com/rolandasrazma/rrpeeanalyzer/tree/master/Images/Samples): reference images · Captured example images used for development and tuning. · `Images/Samples`

## Connections

- Light box → Capture screen: feeds images · Controlled lighting and fixed positioning make capture reliable.
- main.m → App delegate: starts · Standard iOS entry into the app lifecycle.
- App delegate → Main storyboard: loads · App startup is storyboard-driven.
- Main storyboard → Capture screen: opens · Primary workflow begins in the capture screen.
- Main storyboard → Strip setup: opens · Setup flow for strip geometry calibration.
- Main storyboard → Color setup: opens · Setup flow for color reference calibration.
- Capture screen → Capture session: uses · Controller delegates camera/session work to the capture abstraction.
- Capture screen → Strip analyzer: invokes · Captured images are passed to the analysis engine.
- Strip setup → Strip analyzer: configures · Setup screens tune strip detection parameters.
- Color setup → Strip analyzer: configures · Setup screens tune expected color references.
- Capture session → UIImage+OpenCV: converts · Frames are adapted for OpenCV-style processing.
- Strip analyzer → CV additions: relies on · Core analysis uses C++ helper functions.
- Strip analyzer → UIImage transforms: transforms · Images are normalized and rectified before sampling.
- Strip analyzer → UIImage drawing: annotates · Debug or result overlays may be drawn on images.
- Strip analyzer → UIImage color: samples · Pad colors are extracted and compared.
- Strip analyzer → DUS10 plist: reads refs · Analysis is parameterized by strip-specific calibration data.
- Strip analyzer → Sample images: tuned by · Reference captures support development and tuning.
- Strip analyzer → Analyzer test: validated by · Unit tests exercise the separable analysis subsystem.
- Capture session → Capture screen: serves · Provides capture state and frames back to the UI.
- Strip analyzer → Capture screen: returns results · Analysis results are surfaced to the user interface.
