# retheshvs/smartguard_final_product architecture

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

- Interactive diagram: https://gitdiagram.com/retheshvs/smartguard_final_product
- Repository: https://github.com/retheshvs/smartguard_final_product

## Overview

SmartGuard is an offline Android identity-based parental-control app: unlock or handover events trigger face verification, confirmed identity updates the active session, and device enforcement applies that role’s app and time rules. The graph includes enrollment, encrypted profile storage, policy assistance, and optional Device Owner controls alongside the main verification flow. Relationships are limited to those shown in excerpts, SOURCE INDEX references, or README statements; unsampled capabilities are represented without speculative internal call chains.

Main entry points: [`app/src/main/java/com/smartguard/recognition/pipeline/FaceRecognitionPipeline.kt`](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/recognition/pipeline/FaceRecognitionPipeline.kt) (Face recognition), [`app/src/main/java/com/smartguard/data/repository/ProfileRepository.kt`](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/data/repository/ProfileRepository.kt) (Profile repository), [`app/src/main/java/com/smartguard/handover/VerificationLauncher.kt`](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/handover/VerificationLauncher.kt) (Verification launcher), [`app/src/main/java/com/smartguard/policy/SessionController.kt`](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/policy/SessionController.kt) (Session controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity"]
  node_trigger["Unlock / motion trigger"]
  node_launcher["Verification launcher"]
  node_face_check["Visible face check"]
  node_camera_verify["Background camera check"]
  node_recognition["Face recognition"]
  node_face_models["Detection, liveness, matching"]
  node_enrollment["Guided enrollment"]
  node_profile_learning["Profile adaptation"]
end

subgraph group_sessions["Sessions"]
  node_session["Session controller"]
  node_session_state["Active role and state<br/>[SessionState.kt]"]
  node_handover["Temporary app handover<br/>[HandoverSession.kt]"]
  node_app["Application state and services<br/>[SmartGuardApp.kt]"]
end

subgraph group_controls["Parental Controls"]
  node_policy_engine["Policy engine<br/>[PolicyEngine.kt]"]
  node_policy_rules["App, time, emergency rules"]
  node_screen_time["Screen-time tracking"]
  node_kid_launcher["Allowed-app home"]
  node_parent_auth["Parent confirmation and PIN<br/>[ParentAuthGate.kt]"]
  node_policy_assistant["Natural-language policy assistant"]
end

subgraph group_storage["Local Data"]
  node_profile_repository["Profile repository"]
  node_encrypted_profiles[("Encrypted face profiles")]
end

subgraph group_device["Device Enforcement"]
  node_accessibility["App access enforcement"]
  node_device_owner["Device Owner controls<br/>[DeviceRules.kt]"]
end

node_phone_user(("Phone user"))
node_parent(("Parent"))
node_android_os["Android system"]

node_phone_user -->|"unlocks or picks up"| node_trigger
node_trigger -->|"requests check"| node_launcher
node_launcher -->|"launches visible check"| node_face_check
node_launcher -->|"starts camera service"| node_camera_verify
node_face_check -.->|"submits camera frames"| node_recognition
node_camera_verify -->|"processes camera frames"| node_recognition
node_recognition -->|"detects and matches"| node_face_models
node_recognition -->|"loads face gallery"| node_profile_repository
node_recognition -.->|"verification outcome"| node_session
node_enrollment -.->|"saves face samples"| node_profile_repository
node_recognition -->|"learns confirmed samples"| node_profile_learning
node_profile_repository -->|"stores encrypted vectors"| node_encrypted_profiles
node_session -->|"loads profile data"| node_profile_repository
node_session -->|"updates active session"| node_app
node_app -->|"holds current state"| node_session_state
node_session_state -->|"drives restrictions"| node_accessibility
node_policy_engine -->|"reads profile policies"| node_profile_repository
node_accessibility -->|"enforces app rules"| node_policy_rules
node_accessibility -->|"tracks usage"| node_screen_time
node_policy_rules -.->|"limits visible apps"| node_kid_launcher
node_parent -->|"enrolls family"| node_enrollment
node_parent -.->|"confirms changes"| node_parent_auth
node_parent -.->|"describes rules"| node_policy_assistant
node_policy_assistant -.->|"provides structured policy"| node_policy_engine
node_parent -.->|"lends selected apps"| node_handover
node_handover -->|"suppresses verification"| node_launcher
node_session_state -->|"applies device rules"| node_device_owner
node_device_owner -.->|"suspends apps"| node_android_os

click node_trigger "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/handover/SmartGuardMonitorService.kt"
click node_launcher "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/handover/VerificationLauncher.kt"
click node_face_check "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/ui/FaceCheckActivity.kt"
click node_camera_verify "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/handover/VerificationForegroundService.kt"
click node_recognition "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/recognition/pipeline/FaceRecognitionPipeline.kt"
click node_face_models "https://github.com/retheshvs/smartguard_final_product/tree/main/app/src/main/java/com/smartguard/recognition"
click node_enrollment "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/enrollment/EnrollmentActivity.kt"
click node_profile_learning "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/recognition/adaptive/FaceProfileLearner.kt"
click node_session "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/policy/SessionController.kt"
click node_session_state "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/policy/SessionState.kt"
click node_accessibility "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/accessibility/SmartGuardAccessibilityService.kt"
click node_device_owner "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/deviceowner/DeviceRules.kt"
click node_handover "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/handover/HandoverSession.kt"
click node_policy_engine "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/policy/PolicyEngine.kt"
click node_policy_rules "https://github.com/retheshvs/smartguard_final_product/tree/main/app/src/main/java/com/smartguard/policy"
click node_screen_time "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/policy/ScreenTimeTracker.kt"
click node_kid_launcher "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/ui/KidLauncherActivity.kt"
click node_parent_auth "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/ui/ParentAuthGate.kt"
click node_policy_assistant "https://github.com/retheshvs/smartguard_final_product/tree/main/app/src/main/java/com/smartguard/policy/llm"
click node_profile_repository "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/data/repository/ProfileRepository.kt"
click node_encrypted_profiles "https://github.com/retheshvs/smartguard_final_product/tree/main/app/src/main/java/com/smartguard/data/local"
click node_app "https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/SmartGuardApp.kt"

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_trigger,node_launcher,node_face_check,node_camera_verify,node_recognition,node_face_models,node_enrollment,node_profile_learning,node_phone_user toneBlue
class node_session,node_session_state,node_handover,node_app toneAmber
class node_policy_engine,node_policy_rules,node_screen_time,node_kid_launcher,node_parent_auth,node_policy_assistant toneMint
class node_profile_repository,node_encrypted_profiles toneRose
class node_accessibility,node_device_owner,node_parent,node_android_os toneIndigo
```

## Components

### Identity

- [Unlock / motion trigger](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/handover/SmartGuardMonitorService.kt): `app/src/main/java/com/smartguard/handover/SmartGuardMonitorService.kt`
- [Verification launcher](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/handover/VerificationLauncher.kt): `app/src/main/java/com/smartguard/handover/VerificationLauncher.kt`
- [Visible face check](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/ui/FaceCheckActivity.kt): `app/src/main/java/com/smartguard/ui/FaceCheckActivity.kt`
- [Background camera check](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/handover/VerificationForegroundService.kt): `app/src/main/java/com/smartguard/handover/VerificationForegroundService.kt`
- [Face recognition](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/recognition/pipeline/FaceRecognitionPipeline.kt): `app/src/main/java/com/smartguard/recognition/pipeline/FaceRecognitionPipeline.kt`
- [Detection, liveness, matching](https://github.com/retheshvs/smartguard_final_product/tree/main/app/src/main/java/com/smartguard/recognition): `app/src/main/java/com/smartguard/recognition`
- [Guided enrollment](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/enrollment/EnrollmentActivity.kt): `app/src/main/java/com/smartguard/enrollment/EnrollmentActivity.kt`
- [Profile adaptation](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/recognition/adaptive/FaceProfileLearner.kt): `app/src/main/java/com/smartguard/recognition/adaptive/FaceProfileLearner.kt`

### Sessions

- [Session controller](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/policy/SessionController.kt): `app/src/main/java/com/smartguard/policy/SessionController.kt`
- [Active role and state](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/policy/SessionState.kt): `app/src/main/java/com/smartguard/policy/SessionState.kt`
- [Temporary app handover](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/handover/HandoverSession.kt): `app/src/main/java/com/smartguard/handover/HandoverSession.kt`
- [Application state and services](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/SmartGuardApp.kt): `app/src/main/java/com/smartguard/SmartGuardApp.kt`

### Parental Controls

- [Policy engine](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/policy/PolicyEngine.kt): `app/src/main/java/com/smartguard/policy/PolicyEngine.kt`
- [App, time, emergency rules](https://github.com/retheshvs/smartguard_final_product/tree/main/app/src/main/java/com/smartguard/policy): `app/src/main/java/com/smartguard/policy`
- [Screen-time tracking](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/policy/ScreenTimeTracker.kt): `app/src/main/java/com/smartguard/policy/ScreenTimeTracker.kt`
- [Allowed-app home](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/ui/KidLauncherActivity.kt): `app/src/main/java/com/smartguard/ui/KidLauncherActivity.kt`
- [Parent confirmation and PIN](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/ui/ParentAuthGate.kt): `app/src/main/java/com/smartguard/ui/ParentAuthGate.kt`
- [Natural-language policy assistant](https://github.com/retheshvs/smartguard_final_product/tree/main/app/src/main/java/com/smartguard/policy/llm): `app/src/main/java/com/smartguard/policy/llm`

### Local Data

- [Profile repository](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/data/repository/ProfileRepository.kt): `app/src/main/java/com/smartguard/data/repository/ProfileRepository.kt`
- [Encrypted face profiles](https://github.com/retheshvs/smartguard_final_product/tree/main/app/src/main/java/com/smartguard/data/local): `app/src/main/java/com/smartguard/data/local`

### Device Enforcement

- [App access enforcement](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/accessibility/SmartGuardAccessibilityService.kt): `app/src/main/java/com/smartguard/accessibility/SmartGuardAccessibilityService.kt`
- [Device Owner controls](https://github.com/retheshvs/smartguard_final_product/blob/main/app/src/main/java/com/smartguard/deviceowner/DeviceRules.kt): `app/src/main/java/com/smartguard/deviceowner/DeviceRules.kt`

### Other components

- **Phone user**
- **Parent**
- **Android system**

## Connections

- Phone user → Unlock / motion trigger: unlocks or picks up
- Unlock / motion trigger → Verification launcher: requests check (evidence: `app/src/main/java/com/smartguard/handover/SmartGuardMonitorService.kt`)
- Verification launcher → Visible face check: launches visible check (evidence: `app/src/main/java/com/smartguard/handover/VerificationLauncher.kt`)
- Verification launcher → Background camera check: starts camera service (evidence: `app/src/main/java/com/smartguard/handover/VerificationLauncher.kt`)
- Visible face check → Face recognition: submits camera frames (evidence: `app/src/main/java/com/smartguard/ui/FaceCheckActivity.kt`)
- Background camera check → Face recognition: processes camera frames (evidence: `app/src/main/java/com/smartguard/handover/VerificationForegroundService.kt`)
- Face recognition → Detection, liveness, matching: detects and matches (evidence: `app/src/main/java/com/smartguard/recognition/pipeline/FaceRecognitionPipeline.kt`)
- Face recognition → Profile repository: loads face gallery (evidence: `app/src/main/java/com/smartguard/recognition/pipeline/FaceRecognitionPipeline.kt`)
- Face recognition → Session controller: verification outcome
- Guided enrollment → Profile repository: saves face samples
- Face recognition → Profile adaptation: learns confirmed samples (evidence: `app/src/main/java/com/smartguard/recognition/pipeline/FaceRecognitionPipeline.kt`)
- Profile repository → Encrypted face profiles: stores encrypted vectors (evidence: `app/src/main/java/com/smartguard/data/repository/ProfileRepository.kt`)
- Session controller → Profile repository: loads profile data (evidence: `app/src/main/java/com/smartguard/policy/SessionController.kt`)
- Session controller → Application state and services: updates active session (evidence: `app/src/main/java/com/smartguard/policy/SessionController.kt`)
- Application state and services → Active role and state: holds current state (evidence: `app/src/main/java/com/smartguard/SmartGuardApp.kt`)
- Active role and state → App access enforcement: drives restrictions (evidence: `app/src/main/java/com/smartguard/accessibility/SmartGuardAccessibilityService.kt`)
- Policy engine → Profile repository: reads profile policies (evidence: `app/src/main/java/com/smartguard/policy/PolicyEngine.kt`)
- App access enforcement → App, time, emergency rules: enforces app rules (evidence: `app/src/main/java/com/smartguard/accessibility/SmartGuardAccessibilityService.kt`)
- App access enforcement → Screen-time tracking: tracks usage (evidence: `app/src/main/java/com/smartguard/accessibility/SmartGuardAccessibilityService.kt`)
- App, time, emergency rules → Allowed-app home: limits visible apps (evidence: `app/src/main/java/com/smartguard/ui/KidLauncherActivity.kt`)
- Parent → Guided enrollment: enrolls family (evidence: `app/src/main/java/com/smartguard/enrollment/EnrollmentActivity.kt`)
- Parent → Parent confirmation and PIN: confirms changes
- Parent → Natural-language policy assistant: describes rules
- Natural-language policy assistant → Policy engine: provides structured policy
- Parent → Temporary app handover: lends selected apps
- Temporary app handover → Verification launcher: suppresses verification (evidence: `app/src/main/java/com/smartguard/handover/VerificationLauncher.kt`)
- Active role and state → Device Owner controls: applies device rules (evidence: `app/src/main/java/com/smartguard/SmartGuardApp.kt`)
- Device Owner controls → Android system: suspends apps
