# khanh02-vin/smart-cam architecture

> Architecture diagram of the GitHub repository khanh02-vin/smart-cam, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khanh02-vin/smart-cam
- Repository: https://github.com/khanh02-vin/smart-cam

## Overview

SmartCamMobile is a React Native camera-coaching shell. The user grants camera and add-only photo-library permissions, views a live preview, and can capture/save a photo; frame samples go through MobileCoachBridge to the coaching core and resulting guidance is drawn as a Skia overlay. Pose inference is intended to use an optional local iOS MediaPipe provider, but the README says it is not yet verified and the current UI fails closed. The coaching-core source is outside this file tree, so its internal stages are not expanded here.

Main entry points: [`App.tsx`](https://github.com/khanh02-vin/smart-cam/blob/ios-shell/App.tsx) (Mobile app), [`src/PoseLandmarkerProvider.ts`](https://github.com/khanh02-vin/smart-cam/blob/ios-shell/src/PoseLandmarkerProvider.ts) (Provider registry), [`src/SmartCamPoseLandmarker.nitro.ts`](https://github.com/khanh02-vin/smart-cam/blob/ios-shell/src/SmartCamPoseLandmarker.nitro.ts) (Nitro pose contract), [`smartcam-pose/ios/SmartCamPoseLandmarker.swift`](https://github.com/khanh02-vin/smart-cam/blob/ios-shell/smartcam-pose/ios/SmartCamPoseLandmarker.swift) (iOS MediaPipe provider)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Camera and capture"]
  node_camera["Camera preview"]
  node_app["Mobile app<br/>[App.tsx]"]
  node_photo[("Photo library")]
end

subgraph group_coaching["Coaching interface"]
  node_bridge["Frame bridge"]
  node_overlay["Pose overlay<br/>[PoseOverlay.tsx]"]
end

subgraph group_pose["Pose provider"]
  node_provider["Provider registry"]
  node_contract["Nitro pose contract"]
  node_swift["iOS MediaPipe provider"]
end

node_user(("Camera user"))
node_mediapipe["MediaPipe Tasks Vision"]

node_user -->|"uses"| node_app
node_app -->|"configures preview"| node_camera
node_camera -->|"delivers frames"| node_app
node_app -->|"processes frames"| node_bridge
node_app -->|"initializes provider"| node_provider
node_app -->|"requests pose"| node_provider
node_provider -->|"uses contract"| node_contract
node_contract -.->|"implemented by"| node_swift
node_swift -->|"runs inference"| node_mediapipe
node_app -->|"renders guidance"| node_overlay
node_app -->|"saves captured photo"| node_photo
node_user -->|"grants add permission"| node_photo

click node_app "https://github.com/khanh02-vin/smart-cam/blob/ios-shell/App.tsx"
click node_bridge "https://github.com/khanh02-vin/smart-cam/blob/ios-shell/src/MobileCoachBridge.ts"
click node_overlay "https://github.com/khanh02-vin/smart-cam/blob/ios-shell/src/PoseOverlay.tsx"
click node_provider "https://github.com/khanh02-vin/smart-cam/blob/ios-shell/src/PoseLandmarkerProvider.ts"
click node_contract "https://github.com/khanh02-vin/smart-cam/blob/ios-shell/src/SmartCamPoseLandmarker.nitro.ts"
click node_swift "https://github.com/khanh02-vin/smart-cam/blob/ios-shell/smartcam-pose/ios/SmartCamPoseLandmarker.swift"

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_camera,node_app,node_photo,node_user toneBlue
class node_bridge,node_overlay toneAmber
class node_provider,node_contract,node_swift toneMint
class node_mediapipe toneRose
```

## Components

### Camera and capture

- **Camera preview**
- [Mobile app](https://github.com/khanh02-vin/smart-cam/blob/ios-shell/App.tsx): `App.tsx`
- **Photo library**

### Coaching interface

- [Frame bridge](https://github.com/khanh02-vin/smart-cam/blob/ios-shell/src/MobileCoachBridge.ts): `src/MobileCoachBridge.ts`
- [Pose overlay](https://github.com/khanh02-vin/smart-cam/blob/ios-shell/src/PoseOverlay.tsx): `src/PoseOverlay.tsx`

### Pose provider

- [Provider registry](https://github.com/khanh02-vin/smart-cam/blob/ios-shell/src/PoseLandmarkerProvider.ts): `src/PoseLandmarkerProvider.ts`
- [Nitro pose contract](https://github.com/khanh02-vin/smart-cam/blob/ios-shell/src/SmartCamPoseLandmarker.nitro.ts): `src/SmartCamPoseLandmarker.nitro.ts`
- [iOS MediaPipe provider](https://github.com/khanh02-vin/smart-cam/blob/ios-shell/smartcam-pose/ios/SmartCamPoseLandmarker.swift): `smartcam-pose/ios/SmartCamPoseLandmarker.swift`

### Other components

- **Camera user**
- **MediaPipe Tasks Vision**

## Connections

- Camera user → Mobile app: uses (evidence: `README.md`)
- Mobile app → Camera preview: configures preview (evidence: `App.tsx`)
- Camera preview → Mobile app: delivers frames (evidence: `App.tsx`)
- Mobile app → Frame bridge: processes frames (evidence: `App.tsx`)
- Mobile app → Provider registry: initializes provider (evidence: `App.tsx`)
- Mobile app → Provider registry: requests pose (evidence: `App.tsx`)
- Provider registry → Nitro pose contract: uses contract (evidence: `src/PoseLandmarkerProvider.ts`)
- Nitro pose contract → iOS MediaPipe provider: implemented by (evidence: `README.md`)
- iOS MediaPipe provider → MediaPipe Tasks Vision: runs inference (evidence: `smartcam-pose/ios/SmartCamPoseLandmarker.swift`)
- Mobile app → Pose overlay: renders guidance (evidence: `App.tsx`)
- Mobile app → Photo library: saves captured photo (evidence: `App.tsx`)
- Camera user → Photo library: grants add permission (evidence: `README.md`)
