# shivanshu11092003/salarybox architecture

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

- Interactive diagram: https://gitdiagram.com/shivanshu11092003/salarybox
- Repository: https://github.com/shivanshu11092003/salarybox

## Overview

SalaryBox is an offline attendance demo for staff and administrators. The primary workflow is staff sign-in, selfie capture, simulated verification and location, then a locally saved attendance record shown in confirmation and history; administrators add staff and enrol faces. The README describes a shared context, local DemoApi and MMKV persistence, while sampled code confirms capture orchestration and persistence boundaries. Several screen and service implementations were not excerpted, so their internal calls are omitted where the index does not establish them.

Main entry points: [`src/navigation/RootNavigator.tsx`](https://github.com/shivanshu11092003/salarybox/blob/main/src/navigation/RootNavigator.tsx) (Role-based navigator), [`src/services/api.ts`](https://github.com/shivanshu11092003/salarybox/blob/main/src/services/api.ts) (Demo API), [`src/hooks/useApp.tsx`](https://github.com/shivanshu11092003/salarybox/blob/main/src/hooks/useApp.tsx) (Shared app context), [`src/screens/AttendanceCameraScreen.tsx`](https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AttendanceCameraScreen.tsx) (Capture flow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_navigation["App navigation"]
  node_navigator["Role-based navigator<br/>[RootNavigator.tsx]"]
  node_login["Sign in<br/>[LoginScreen.tsx]"]
  node_app_state["Shared app context<br/>[useApp.tsx]"]
  node_ui["Shared UI components<br/>[ui.tsx]"]
  node_format["Date and time formatting<br/>[format.ts]"]
  node_theme["Visual theme<br/>[theme.ts]"]
end

subgraph group_attendance["Staff attendance"]
  node_staff_home["Staff home"]
  node_capture_screen["Capture flow"]
  node_camera["Selfie camera"]
  node_camera_adapter["Camera adapter<br/>[SelfieCamera.tsx]"]
  node_success["Success receipt"]
  node_failure["Failure guidance"]
  node_history["Attendance history"]
  node_detail["Attendance detail"]
  node_attendance_row["Attendance row<br/>[AttendanceRow.tsx]"]
  node_selfie_image["Selfie display<br/>[SelfieImage.tsx]"]
end

subgraph group_admin["Admin management"]
  node_admin_home["Admin dashboard"]
  node_add_staff["Add staff<br/>[AddStaffScreen.tsx]"]
  node_staff_profile["Staff profile"]
  node_settings["Settings and reset<br/>[SettingsScreen.tsx]"]
end

subgraph group_domain["Demo domain services"]
  node_api["Demo API<br/>[api.ts]"]
  node_validation["Attendance rules<br/>[attendance.ts]"]
  node_camera_service["Capture simulation<br/>[camera.ts]"]
  node_location_service["Location simulation<br/>[location.ts]"]
  node_aws_adapter["Demo verification adapter<br/>[aws.ts]"]
  node_seed["Seed data<br/>[seed.ts]"]
end

subgraph group_storage["Local data and media"]
  node_disk[("MMKV persistence<br/>[storage.ts]")]
  node_photos["Private photo storage<br/>[photos.ts]"]
end

node_staff_actor(("Staff user"))
node_admin_actor(("Admin user"))

node_staff_actor -->|"signs in"| node_login
node_admin_actor -->|"signs in"| node_login
node_login -->|"uses session"| node_app_state
node_navigator -->|"routes to"| node_login
node_navigator -->|"routes to"| node_staff_home
node_navigator -->|"routes to"| node_admin_home
node_navigator -->|"routes to"| node_capture_screen
node_navigator -->|"routes to"| node_success
node_navigator -->|"routes to"| node_failure
node_navigator -->|"routes to"| node_history
node_navigator -->|"routes to"| node_detail
node_navigator -->|"routes to"| node_settings
node_navigator -->|"routes to"| node_add_staff
node_navigator -->|"routes to"| node_staff_profile
node_app_state -->|"creates and observes"| node_api
node_app_state -->|"passes persistence"| node_disk
node_staff_home -->|"reads app state"| node_app_state
node_admin_home -->|"reads app state"| node_app_state
node_add_staff -->|"reads app state"| node_app_state
node_capture_screen -->|"calls capture"| node_app_state
node_capture_screen -->|"renders"| node_camera_adapter
node_camera_adapter -->|"delegates to"| node_camera
node_capture_screen -->|"saves and discards"| node_photos
node_capture_screen -->|"submits capture"| node_api
node_api -->|"checks rules"| node_validation
node_api -->|"captures selfie"| node_camera_service
node_api -->|"gets location"| node_location_service
node_api -->|"simulates verification"| node_aws_adapter
node_api -->|"loads defaults"| node_seed
node_staff_home -.->|"opens attendance"| node_history
node_history -->|"renders rows"| node_attendance_row
node_detail -->|"shows photo"| node_selfie_image
node_success -->|"shows photo"| node_selfie_image
node_settings -.->|"resets demo"| node_api
node_staff_home -->|"renders rows"| node_attendance_row
node_ui -->|"formats initials"| node_format

click node_navigator "https://github.com/shivanshu11092003/salarybox/blob/main/src/navigation/RootNavigator.tsx"
click node_login "https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/LoginScreen.tsx"
click node_app_state "https://github.com/shivanshu11092003/salarybox/blob/main/src/hooks/useApp.tsx"
click node_staff_home "https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/StaffHomeScreen.tsx"
click node_capture_screen "https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AttendanceCameraScreen.tsx"
click node_camera "https://github.com/shivanshu11092003/salarybox/blob/main/src/components/VisionSelfieCamera.tsx"
click node_camera_adapter "https://github.com/shivanshu11092003/salarybox/blob/main/src/components/SelfieCamera.tsx"
click node_success "https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AttendanceSuccessScreen.tsx"
click node_failure "https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AttendanceFailureScreen.tsx"
click node_history "https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AttendanceHistoryScreen.tsx"
click node_detail "https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AttendanceDetailScreen.tsx"
click node_admin_home "https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AdminDashboardScreen.tsx"
click node_add_staff "https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AddStaffScreen.tsx"
click node_staff_profile "https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/StaffProfileScreen.tsx"
click node_settings "https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/SettingsScreen.tsx"
click node_api "https://github.com/shivanshu11092003/salarybox/blob/main/src/services/api.ts"
click node_validation "https://github.com/shivanshu11092003/salarybox/blob/main/src/services/attendance.ts"
click node_camera_service "https://github.com/shivanshu11092003/salarybox/blob/main/src/services/camera.ts"
click node_location_service "https://github.com/shivanshu11092003/salarybox/blob/main/src/services/location.ts"
click node_aws_adapter "https://github.com/shivanshu11092003/salarybox/blob/main/src/services/aws.ts"
click node_seed "https://github.com/shivanshu11092003/salarybox/blob/main/src/services/seed.ts"
click node_disk "https://github.com/shivanshu11092003/salarybox/blob/main/src/services/storage.ts"
click node_photos "https://github.com/shivanshu11092003/salarybox/blob/main/src/services/photos.ts"
click node_attendance_row "https://github.com/shivanshu11092003/salarybox/blob/main/src/components/AttendanceRow.tsx"
click node_selfie_image "https://github.com/shivanshu11092003/salarybox/blob/main/src/components/SelfieImage.tsx"
click node_ui "https://github.com/shivanshu11092003/salarybox/blob/main/src/components/ui.tsx"
click node_format "https://github.com/shivanshu11092003/salarybox/blob/main/src/utils/format.ts"
click node_theme "https://github.com/shivanshu11092003/salarybox/blob/main/src/utils/theme.ts"

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_navigator,node_login,node_app_state,node_ui,node_format,node_theme,node_staff_actor,node_admin_actor toneBlue
class node_staff_home,node_capture_screen,node_camera,node_camera_adapter,node_success,node_failure,node_history,node_detail,node_attendance_row,node_selfie_image toneAmber
class node_admin_home,node_add_staff,node_staff_profile,node_settings toneMint
class node_api,node_validation,node_camera_service,node_location_service,node_aws_adapter,node_seed toneRose
class node_disk,node_photos toneIndigo
```

## Components

### App navigation

- [Role-based navigator](https://github.com/shivanshu11092003/salarybox/blob/main/src/navigation/RootNavigator.tsx): `src/navigation/RootNavigator.tsx`
- [Sign in](https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/LoginScreen.tsx): `src/screens/LoginScreen.tsx`
- [Shared app context](https://github.com/shivanshu11092003/salarybox/blob/main/src/hooks/useApp.tsx): `src/hooks/useApp.tsx`
- [Shared UI components](https://github.com/shivanshu11092003/salarybox/blob/main/src/components/ui.tsx): `src/components/ui.tsx`
- [Date and time formatting](https://github.com/shivanshu11092003/salarybox/blob/main/src/utils/format.ts): `src/utils/format.ts`
- [Visual theme](https://github.com/shivanshu11092003/salarybox/blob/main/src/utils/theme.ts): `src/utils/theme.ts`

### Staff attendance

- [Staff home](https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/StaffHomeScreen.tsx): `src/screens/StaffHomeScreen.tsx`
- [Capture flow](https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AttendanceCameraScreen.tsx): `src/screens/AttendanceCameraScreen.tsx`
- [Selfie camera](https://github.com/shivanshu11092003/salarybox/blob/main/src/components/VisionSelfieCamera.tsx): `src/components/VisionSelfieCamera.tsx`
- [Camera adapter](https://github.com/shivanshu11092003/salarybox/blob/main/src/components/SelfieCamera.tsx): `src/components/SelfieCamera.tsx`
- [Success receipt](https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AttendanceSuccessScreen.tsx): `src/screens/AttendanceSuccessScreen.tsx`
- [Failure guidance](https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AttendanceFailureScreen.tsx): `src/screens/AttendanceFailureScreen.tsx`
- [Attendance history](https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AttendanceHistoryScreen.tsx): `src/screens/AttendanceHistoryScreen.tsx`
- [Attendance detail](https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AttendanceDetailScreen.tsx): `src/screens/AttendanceDetailScreen.tsx`
- [Attendance row](https://github.com/shivanshu11092003/salarybox/blob/main/src/components/AttendanceRow.tsx): `src/components/AttendanceRow.tsx`
- [Selfie display](https://github.com/shivanshu11092003/salarybox/blob/main/src/components/SelfieImage.tsx): `src/components/SelfieImage.tsx`

### Admin management

- [Admin dashboard](https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AdminDashboardScreen.tsx): `src/screens/AdminDashboardScreen.tsx`
- [Add staff](https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/AddStaffScreen.tsx): `src/screens/AddStaffScreen.tsx`
- [Staff profile](https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/StaffProfileScreen.tsx): `src/screens/StaffProfileScreen.tsx`
- [Settings and reset](https://github.com/shivanshu11092003/salarybox/blob/main/src/screens/SettingsScreen.tsx): `src/screens/SettingsScreen.tsx`

### Demo domain services

- [Demo API](https://github.com/shivanshu11092003/salarybox/blob/main/src/services/api.ts): `src/services/api.ts`
- [Attendance rules](https://github.com/shivanshu11092003/salarybox/blob/main/src/services/attendance.ts): `src/services/attendance.ts`
- [Capture simulation](https://github.com/shivanshu11092003/salarybox/blob/main/src/services/camera.ts): `src/services/camera.ts`
- [Location simulation](https://github.com/shivanshu11092003/salarybox/blob/main/src/services/location.ts): `src/services/location.ts`
- [Demo verification adapter](https://github.com/shivanshu11092003/salarybox/blob/main/src/services/aws.ts): `src/services/aws.ts`
- [Seed data](https://github.com/shivanshu11092003/salarybox/blob/main/src/services/seed.ts): `src/services/seed.ts`

### Local data and media

- [MMKV persistence](https://github.com/shivanshu11092003/salarybox/blob/main/src/services/storage.ts): `src/services/storage.ts`
- [Private photo storage](https://github.com/shivanshu11092003/salarybox/blob/main/src/services/photos.ts): `src/services/photos.ts`

### Other components

- **Staff user**
- **Admin user**

## Connections

- Staff user → Sign in: signs in (evidence: `README.md`)
- Admin user → Sign in: signs in (evidence: `README.md`)
- Sign in → Shared app context: uses session (evidence: `src/screens/LoginScreen.tsx`)
- Role-based navigator → Sign in: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- Role-based navigator → Staff home: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- Role-based navigator → Admin dashboard: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- Role-based navigator → Capture flow: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- Role-based navigator → Success receipt: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- Role-based navigator → Failure guidance: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- Role-based navigator → Attendance history: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- Role-based navigator → Attendance detail: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- Role-based navigator → Settings and reset: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- Role-based navigator → Add staff: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- Role-based navigator → Staff profile: routes to (evidence: `src/navigation/RootNavigator.tsx`)
- Shared app context → Demo API: creates and observes (evidence: `src/hooks/useApp.tsx`)
- Shared app context → MMKV persistence: passes persistence (evidence: `src/hooks/useApp.tsx`)
- Staff home → Shared app context: reads app state (evidence: `src/screens/StaffHomeScreen.tsx`)
- Admin dashboard → Shared app context: reads app state (evidence: `src/screens/AdminDashboardScreen.tsx`)
- Add staff → Shared app context: reads app state (evidence: `src/screens/AddStaffScreen.tsx`)
- Capture flow → Shared app context: calls capture (evidence: `src/screens/AttendanceCameraScreen.tsx`)
- Capture flow → Camera adapter: renders (evidence: `src/screens/AttendanceCameraScreen.tsx`)
- Camera adapter → Selfie camera: delegates to (evidence: `src/components/SelfieCamera.tsx`)
- Capture flow → Private photo storage: saves and discards (evidence: `src/screens/AttendanceCameraScreen.tsx`)
- Capture flow → Demo API: submits capture (evidence: `src/screens/AttendanceCameraScreen.tsx`)
- Demo API → Attendance rules: checks rules (evidence: `src/services/api.ts`)
- Demo API → Capture simulation: captures selfie (evidence: `src/services/api.ts`)
- Demo API → Location simulation: gets location (evidence: `src/services/api.ts`)
- Demo API → Demo verification adapter: simulates verification (evidence: `src/services/api.ts`)
- Demo API → Seed data: loads defaults (evidence: `src/services/api.ts`)
- Staff home → Attendance history: opens attendance
- Attendance history → Attendance row: renders rows (evidence: `src/screens/AttendanceHistoryScreen.tsx`)
- Attendance detail → Selfie display: shows photo (evidence: `src/screens/AttendanceDetailScreen.tsx`)
- Success receipt → Selfie display: shows photo (evidence: `src/screens/AttendanceSuccessScreen.tsx`)
- Settings and reset → Demo API: resets demo
- Staff home → Attendance row: renders rows (evidence: `src/screens/StaffHomeScreen.tsx`)
- Shared UI components → Date and time formatting: formats initials (evidence: `src/components/ui.tsx`)
