# moturumonishpvt-byte/studentapp_sc architecture

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

- Interactive diagram: https://gitdiagram.com/moturumonishpvt-byte/studentapp_sc
- Repository: https://github.com/moturumonishpvt-byte/studentapp_sc

## Overview

Academic Monitor is a React Native student app for offline face authentication and BLE classroom attendance. A student can enroll a face profile, have embeddings synchronized from Supabase to local MMKV storage, authenticate against that cache using camera frames and native TFLite processing, then scan and join a nearby faculty session, pass RSSI proximity checks, and confirm with an OTP. The graph preserves documented capabilities, but some links—especially native inference internals and OTP policy—are based on README statements because their implementation excerpts were not provided.

Main entry points: [`App.js`](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/App.js) (App navigation), [`src/ble/StudentBLEModule.js`](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/ble/StudentBLEModule.js) (BLE session flow), [`src/services/faceService.ts`](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/services/faceService.ts) (Face matching), [`src/screens/FaceScanScreen.tsx`](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/screens/FaceScanScreen.tsx) (Face scan screen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App flow"]
  node_app["App navigation<br/>[App.js]"]
  node_auth["Auth state<br/>[AuthContext.js]"]
end

subgraph group_identity["Identity and enrollment"]
  node_face_screen["Face scan screen<br/>[FaceScanScreen.tsx]"]
  node_face_hook["Recognition loop"]
  node_native_face["TFLite inference<br/>[TFLiteModule.kt]"]
  node_liveness["Liveness checks"]
  node_image_enhance["Image enhancement<br/>[ImageEnhancer.kt]"]
  node_embedding["Embedding model<br/>[faceEmbedding.ts]"]
  node_face_service["Face matching<br/>[faceService.ts]"]
  node_face_compare["Similarity utilities<br/>[faceCompare.ts]"]
  node_register["Student registration<br/>[RegisterScreen.tsx]"]
end

subgraph group_data["Student data"]
  node_student_service["Profile sync<br/>[studentService.ts]"]
  node_storage[("Local MMKV cache<br/>[storageService.ts]")]
  node_supabase_client["Supabase client<br/>[supabaseClient.ts]"]
  node_supabase[("Supabase database")]
end

subgraph group_attendance["BLE attendance"]
  node_attendance["Attendance screen"]
  node_ble_module["BLE session flow"]
  node_ble_service["BLE transport<br/>[BLEService.js]"]
  node_ble_security["Join security<br/>[SecurityUtils.js]"]
  node_ble_constants["BLE protocol<br/>[BLEConstants.js]"]
end

node_student(("Student"))
node_faculty(("Faculty BLE device"))

node_student -->|"uses"| node_app
node_app -->|"provides"| node_auth
node_app -->|"routes to"| node_face_screen
node_app -->|"routes to"| node_register
node_app -->|"routes to"| node_attendance
node_app -->|"syncs on launch"| node_student_service
node_face_screen -->|"uses"| node_face_hook
node_face_hook -->|"invokes inference"| node_native_face
node_native_face -.->|"checks liveness"| node_liveness
node_native_face -.->|"enhances image"| node_image_enhance
node_face_hook -->|"matches embedding"| node_face_service
node_face_service -->|"loads model"| node_embedding
node_face_service -->|"compares vectors"| node_face_compare
node_face_service -->|"reads embeddings"| node_storage
node_register -->|"upserts profile"| node_supabase_client
node_register -->|"averages vectors"| node_face_compare
node_student_service -->|"fetches profiles"| node_supabase_client
node_student_service -->|"caches embeddings"| node_storage
node_supabase_client -->|"queries"| node_supabase
node_face_screen -.->|"sets verified user"| node_auth
node_attendance -->|"starts session flow"| node_ble_module
node_ble_module -->|"scans and connects"| node_ble_service
node_ble_module -->|"checks proximity"| node_ble_security
node_ble_module -->|"uses protocol"| node_ble_constants
node_ble_module -->|"joins and verifies OTP"| node_faculty
node_ble_service -.->|"exchanges BLE data"| node_faculty

click node_app "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/App.js"
click node_auth "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/auth/AuthContext.js"
click node_face_screen "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/screens/FaceScanScreen.tsx"
click node_face_hook "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/hooks/useFaceRecognition.ts"
click node_native_face "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/android/app/src/main/java/com/am_student_app/tflite/TFLiteModule.kt"
click node_liveness "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/android/app/src/main/java/com/am_student_app/tflite/LivenessDetector.kt"
click node_image_enhance "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/android/app/src/main/java/com/am_student_app/tflite/ImageEnhancer.kt"
click node_embedding "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/facerecg/faceEmbedding.ts"
click node_face_service "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/services/faceService.ts"
click node_face_compare "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/facerecg/faceCompare.ts"
click node_register "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/screens/RegisterScreen.tsx"
click node_student_service "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/services/studentService.ts"
click node_storage "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/services/storageService.ts"
click node_supabase_client "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/services/supabaseClient.ts"
click node_attendance "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/screens/AttendanceScreen.js"
click node_ble_module "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/ble/StudentBLEModule.js"
click node_ble_service "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/ble/BLEService.js"
click node_ble_security "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/ble/SecurityUtils.js"
click node_ble_constants "https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/ble/BLEConstants.js"

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_app,node_auth toneBlue
class node_face_screen,node_face_hook,node_native_face,node_liveness,node_image_enhance,node_embedding,node_face_service,node_face_compare,node_register toneAmber
class node_student_service,node_storage,node_supabase_client,node_supabase toneMint
class node_attendance,node_ble_module,node_ble_service,node_ble_security,node_ble_constants toneRose
class node_student,node_faculty toneIndigo
```

## Components

### App flow

- [App navigation](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/App.js): `App.js`
- [Auth state](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/auth/AuthContext.js): `src/auth/AuthContext.js`

### Identity and enrollment

- [Face scan screen](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/screens/FaceScanScreen.tsx): `src/screens/FaceScanScreen.tsx`
- [Recognition loop](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/hooks/useFaceRecognition.ts): `src/hooks/useFaceRecognition.ts`
- [TFLite inference](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/android/app/src/main/java/com/am_student_app/tflite/TFLiteModule.kt): `android/app/src/main/java/com/am_student_app/tflite/TFLiteModule.kt`
- [Liveness checks](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/android/app/src/main/java/com/am_student_app/tflite/LivenessDetector.kt): `android/app/src/main/java/com/am_student_app/tflite/LivenessDetector.kt`
- [Image enhancement](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/android/app/src/main/java/com/am_student_app/tflite/ImageEnhancer.kt): `android/app/src/main/java/com/am_student_app/tflite/ImageEnhancer.kt`
- [Embedding model](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/facerecg/faceEmbedding.ts): `src/facerecg/faceEmbedding.ts`
- [Face matching](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/services/faceService.ts): `src/services/faceService.ts`
- [Similarity utilities](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/facerecg/faceCompare.ts): `src/facerecg/faceCompare.ts`
- [Student registration](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/screens/RegisterScreen.tsx): `src/screens/RegisterScreen.tsx`

### Student data

- [Profile sync](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/services/studentService.ts): `src/services/studentService.ts`
- [Local MMKV cache](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/services/storageService.ts): `src/services/storageService.ts`
- [Supabase client](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/services/supabaseClient.ts): `src/services/supabaseClient.ts`
- **Supabase database**

### BLE attendance

- [Attendance screen](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/screens/AttendanceScreen.js): `src/screens/AttendanceScreen.js`
- [BLE session flow](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/ble/StudentBLEModule.js): `src/ble/StudentBLEModule.js`
- [BLE transport](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/ble/BLEService.js): `src/ble/BLEService.js`
- [Join security](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/ble/SecurityUtils.js): `src/ble/SecurityUtils.js`
- [BLE protocol](https://github.com/moturumonishpvt-byte/studentapp_sc/blob/main/src/ble/BLEConstants.js): `src/ble/BLEConstants.js`

### Other components

- **Student**
- **Faculty BLE device**

## Connections

- Student → App navigation: uses (evidence: `README.md`)
- App navigation → Auth state: provides (evidence: `App.js`)
- App navigation → Face scan screen: routes to (evidence: `App.js`)
- App navigation → Student registration: routes to (evidence: `App.js`)
- App navigation → Attendance screen: routes to (evidence: `App.js`)
- App navigation → Profile sync: syncs on launch (evidence: `App.js`)
- Face scan screen → Recognition loop: uses (evidence: `src/screens/FaceScanScreen.tsx`)
- Recognition loop → TFLite inference: invokes inference (evidence: `src/hooks/useFaceRecognition.ts`)
- TFLite inference → Liveness checks: checks liveness
- TFLite inference → Image enhancement: enhances image
- Recognition loop → Face matching: matches embedding (evidence: `src/hooks/useFaceRecognition.ts`)
- Face matching → Embedding model: loads model (evidence: `src/services/faceService.ts`)
- Face matching → Similarity utilities: compares vectors (evidence: `src/services/faceService.ts`)
- Face matching → Local MMKV cache: reads embeddings (evidence: `src/services/faceService.ts`)
- Student registration → Supabase client: upserts profile (evidence: `src/screens/RegisterScreen.tsx`)
- Student registration → Similarity utilities: averages vectors (evidence: `src/screens/RegisterScreen.tsx`)
- Profile sync → Supabase client: fetches profiles (evidence: `src/services/studentService.ts`)
- Profile sync → Local MMKV cache: caches embeddings (evidence: `src/services/studentService.ts`)
- Supabase client → Supabase database: queries
- Face scan screen → Auth state: sets verified user
- Attendance screen → BLE session flow: starts session flow (evidence: `src/screens/AttendanceScreen.js`)
- BLE session flow → BLE transport: scans and connects (evidence: `src/ble/StudentBLEModule.js`)
- BLE session flow → Join security: checks proximity (evidence: `src/ble/StudentBLEModule.js`)
- BLE session flow → BLE protocol: uses protocol (evidence: `src/ble/StudentBLEModule.js`)
- BLE session flow → Faculty BLE device: joins and verifies OTP (evidence: `README.md`)
- BLE transport → Faculty BLE device: exchanges BLE data
