# truongluu46/vocalens architecture

> Architecture diagram of the GitHub repository truongluu46/vocalens, 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/truongluu46/vocalens
- Repository: https://github.com/truongluu46/vocalens

## Overview

VocaLens is an Android vocabulary-learning app: a learner enters through the app, authenticates, then discovers vocabulary with camera recognition or dictionary lookup, saves words and collections, studies flashcards or practice lessons, and reviews progress and rankings. Local Room storage supports learning offline; Firebase handles authentication, library synchronization, ranking/XP services, with a callable backend validating flashcard-session XP. Edges are limited to relationships visible in excerpts or the SOURCE INDEX; several product branches are represented at their source directories because their implementation was not sampled.

Main entry points: [`app/src/main/java/com/luudev/vocalens/MainActivity.kt`](https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/MainActivity.kt) (App entry), [`app/src/main/java/com/luudev/vocalens/data/repository/LocalFlashcardRepositoryImpl.kt`](https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/repository/LocalFlashcardRepositoryImpl.kt) (Flashcard persistence), [`functions/application/submit_flashcard_session.py`](https://github.com/truongluu46/vocalens/blob/main/functions/application/submit_flashcard_session.py) (Submit session), [`app/src/main/java/com/luudev/vocalens/data/sync/XpSyncWorker.kt`](https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/sync/XpSyncWorker.kt) (XP sync worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Android experience"]
  node_activity["App entry<br/>[MainActivity.kt]"]
  node_navigation["App navigation"]
  node_authui["Sign-in and onboarding"]
end

subgraph group_learning["Learning workflows"]
  node_camera["Object recognition"]
  node_dictionary["Dictionary lookup"]
  node_vocabulary["Vocabulary library"]
  node_flashcards["Flashcard study"]
  node_practice["Practice lessons"]
  node_dashboard["Learning dashboard"]
  node_profile["Learner profile"]
  node_ranking["Ranking"]
  node_domain["Learning rules"]
end

subgraph group_storage["Local data"]
  node_db[("Room database")]
  node_localrepos["Local repositories"]
  node_stats["Learning statistics"]
  node_flashrepo["Flashcard persistence"]
end

subgraph group_cloud["Firebase services"]
  node_sync["Library synchronization"]
  node_syncworker["XP sync worker<br/>[XpSyncWorker.kt]"]
  node_firebase["Firebase services"]
  node_authrepo["Firebase authentication"]
end

subgraph group_backend["XP backend"]
  node_xpentry["Session XP callable<br/>[main.py]"]
  node_submit["Submit session"]
  node_rules["Validate and award XP"]
  node_ledger[("Firestore XP ledger")]
end

node_learner(("Learner"))

node_learner -->|"opens app"| node_activity
node_activity -->|"hosts"| node_navigation
node_activity -->|"creates view model"| node_camera
node_activity -->|"configures"| node_authrepo
node_authrepo -.->|"uses auth client"| node_firebase
node_activity -->|"wires study"| node_flashrepo
node_activity -->|"wires sync"| node_sync
node_activity -->|"schedules XP sync"| node_syncworker
node_activity -->|"wires collections"| node_vocabulary
node_activity -->|"wires lookup"| node_dictionary
node_activity -->|"wires ranking"| node_ranking
node_activity -->|"wires profile"| node_profile
node_activity -->|"wires lessons"| node_practice
node_activity -->|"wires dashboard"| node_dashboard
node_activity -->|"hosts sign-in"| node_authui
node_flashrepo -->|"records sessions"| node_db
node_flashrepo -.->|"XP informs totals"| node_stats
node_flashrepo -->|"enqueues completed XP"| node_syncworker
node_syncworker -->|"uses Firebase clients"| node_firebase
node_sync -->|"reads and applies changes"| node_db
node_localrepos -.->|"persists learning data"| node_db
node_xpentry -->|"routes callable"| node_submit
node_submit -->|"validates session"| node_rules
node_submit -->|"awards XP"| node_ledger

click node_activity "https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/MainActivity.kt"
click node_navigation "https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/navigation"
click node_authui "https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/login"
click node_camera "https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/camera"
click node_dictionary "https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/repository/RemoteDictionaryRepositoryImpl.kt"
click node_vocabulary "https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/vocabulary"
click node_flashcards "https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/flashcard"
click node_practice "https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/practice"
click node_dashboard "https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/home"
click node_profile "https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/profile"
click node_ranking "https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/ranking"
click node_domain "https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/domain/usecase"
click node_db "https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/local/database/VocabLensDatabase.kt"
click node_localrepos "https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/data/repository"
click node_stats "https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/local/LocalLearningStatistics.kt"
click node_flashrepo "https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/repository/LocalFlashcardRepositoryImpl.kt"
click node_sync "https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/repository/FirebaseLibrarySyncRepository.kt"
click node_syncworker "https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/sync/XpSyncWorker.kt"
click node_firebase "https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/remote/FirebaseServices.kt"
click node_authrepo "https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/repository/FirebaseAuthRepositoryImpl.kt"
click node_xpentry "https://github.com/truongluu46/vocalens/blob/main/functions/main.py"
click node_submit "https://github.com/truongluu46/vocalens/blob/main/functions/application/submit_flashcard_session.py"
click node_rules "https://github.com/truongluu46/vocalens/blob/main/functions/domain/flashcard_session.py"
click node_ledger "https://github.com/truongluu46/vocalens/blob/main/functions/data/firestore_xp_ledger.py"

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_activity,node_navigation,node_authui toneBlue
class node_camera,node_dictionary,node_vocabulary,node_flashcards,node_practice,node_dashboard,node_profile,node_ranking,node_domain toneAmber
class node_db,node_localrepos,node_stats,node_flashrepo toneMint
class node_sync,node_syncworker,node_firebase,node_authrepo toneRose
class node_xpentry,node_submit,node_rules,node_ledger,node_learner toneIndigo
```

## Components

### Android experience

- [App entry](https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/MainActivity.kt): `app/src/main/java/com/luudev/vocalens/MainActivity.kt`
- [App navigation](https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/navigation): `app/src/main/java/com/luudev/vocalens/presentation/navigation`
- [Sign-in and onboarding](https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/login): `app/src/main/java/com/luudev/vocalens/presentation/login`

### Learning workflows

- [Object recognition](https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/camera): `app/src/main/java/com/luudev/vocalens/presentation/camera`
- [Dictionary lookup](https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/repository/RemoteDictionaryRepositoryImpl.kt): `app/src/main/java/com/luudev/vocalens/data/repository/RemoteDictionaryRepositoryImpl.kt`
- [Vocabulary library](https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/vocabulary): `app/src/main/java/com/luudev/vocalens/presentation/vocabulary`
- [Flashcard study](https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/flashcard): `app/src/main/java/com/luudev/vocalens/presentation/flashcard`
- [Practice lessons](https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/practice): `app/src/main/java/com/luudev/vocalens/presentation/practice`
- [Learning dashboard](https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/home): `app/src/main/java/com/luudev/vocalens/presentation/home`
- [Learner profile](https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/profile): `app/src/main/java/com/luudev/vocalens/presentation/profile`
- [Ranking](https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/presentation/ranking): `app/src/main/java/com/luudev/vocalens/presentation/ranking`
- [Learning rules](https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/domain/usecase): `app/src/main/java/com/luudev/vocalens/domain/usecase`

### Local data

- [Room database](https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/local/database/VocabLensDatabase.kt): `app/src/main/java/com/luudev/vocalens/data/local/database/VocabLensDatabase.kt`
- [Local repositories](https://github.com/truongluu46/vocalens/tree/main/app/src/main/java/com/luudev/vocalens/data/repository): `app/src/main/java/com/luudev/vocalens/data/repository`
- [Learning statistics](https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/local/LocalLearningStatistics.kt): `app/src/main/java/com/luudev/vocalens/data/local/LocalLearningStatistics.kt`
- [Flashcard persistence](https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/repository/LocalFlashcardRepositoryImpl.kt): `app/src/main/java/com/luudev/vocalens/data/repository/LocalFlashcardRepositoryImpl.kt`

### Firebase services

- [Library synchronization](https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/repository/FirebaseLibrarySyncRepository.kt): `app/src/main/java/com/luudev/vocalens/data/repository/FirebaseLibrarySyncRepository.kt`
- [XP sync worker](https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/sync/XpSyncWorker.kt): `app/src/main/java/com/luudev/vocalens/data/sync/XpSyncWorker.kt`
- [Firebase services](https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/remote/FirebaseServices.kt): `app/src/main/java/com/luudev/vocalens/data/remote/FirebaseServices.kt`
- [Firebase authentication](https://github.com/truongluu46/vocalens/blob/main/app/src/main/java/com/luudev/vocalens/data/repository/FirebaseAuthRepositoryImpl.kt): `app/src/main/java/com/luudev/vocalens/data/repository/FirebaseAuthRepositoryImpl.kt`

### XP backend

- [Session XP callable](https://github.com/truongluu46/vocalens/blob/main/functions/main.py): `functions/main.py`
- [Submit session](https://github.com/truongluu46/vocalens/blob/main/functions/application/submit_flashcard_session.py): `functions/application/submit_flashcard_session.py`
- [Validate and award XP](https://github.com/truongluu46/vocalens/blob/main/functions/domain/flashcard_session.py): `functions/domain/flashcard_session.py`
- [Firestore XP ledger](https://github.com/truongluu46/vocalens/blob/main/functions/data/firestore_xp_ledger.py): `functions/data/firestore_xp_ledger.py`

### Other components

- **Learner**

## Connections

- Learner → App entry: opens app
- App entry → App navigation: hosts (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- App entry → Object recognition: creates view model (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- App entry → Firebase authentication: configures (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- Firebase authentication → Firebase services: uses auth client
- App entry → Flashcard persistence: wires study (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- App entry → Library synchronization: wires sync (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- App entry → XP sync worker: schedules XP sync (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- App entry → Vocabulary library: wires collections (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- App entry → Dictionary lookup: wires lookup (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- App entry → Ranking: wires ranking (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- App entry → Learner profile: wires profile (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- App entry → Practice lessons: wires lessons (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- App entry → Learning dashboard: wires dashboard (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- App entry → Sign-in and onboarding: hosts sign-in (evidence: `app/src/main/java/com/luudev/vocalens/MainActivity.kt`)
- Flashcard persistence → Room database: records sessions (evidence: `app/src/main/java/com/luudev/vocalens/data/repository/LocalFlashcardRepositoryImpl.kt`)
- Flashcard persistence → Learning statistics: XP informs totals
- Flashcard persistence → XP sync worker: enqueues completed XP (evidence: `app/src/main/java/com/luudev/vocalens/data/repository/LocalFlashcardRepositoryImpl.kt`)
- XP sync worker → Firebase services: uses Firebase clients (evidence: `app/src/main/java/com/luudev/vocalens/data/sync/XpSyncWorker.kt`)
- Library synchronization → Room database: reads and applies changes (evidence: `app/src/main/java/com/luudev/vocalens/data/repository/FirebaseLibrarySyncRepository.kt`)
- Local repositories → Room database: persists learning data (evidence: `app/src/main/java/com/luudev/vocalens/data/repository/FirebaseLibrarySyncRepository.kt`)
- Session XP callable → Submit session: routes callable (evidence: `functions/main.py`)
- Submit session → Validate and award XP: validates session (evidence: `functions/application/submit_flashcard_session.py`)
- Submit session → Firestore XP ledger: awards XP (evidence: `functions/data/firestore_xp_ledger.py`)
