# flamilani/libras-virtual architecture

> Architecture diagram of the GitHub repository flamilani/libras-virtual, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/flamilani/libras-virtual
- Repository: https://github.com/flamilani/libras-virtual

## Overview

##### Project Type and Purpose
- This is a hybrid mobile/Web application built with Angular (v16) and packaged using Capacitor into an Android native wrapper.
- The “src” directory contains the Angular Single-Page Application (SPA) (UI components, pages, services, shared modules).
- The “android” directory is the Capacitor-generated native Android project (MainActivity, AndroidManifest, Gradle scripts).
- It can be deployed as a PWA (netlify.toml, service worker config) or as an Android app via Capacitor.

##### File Structure Analysis
- Top-level:
- src/ – Angular app
- android/ – Native Android wrapper (capacitor.config.ts config)
- package.json, angular.json – Angular CLI build & project config
- netlify.toml, ngsw-config.json – PWA/web deploy configs
- src/app
- app.component, app.route – root component, router
- pages/ – feature modules (home/, quiz/, games, etc.) following Angular Router lazy loading
- shared/ – common components, services, constants, state management (CDK dialog, bottom-sheet, speech OCR, ML-model assets in src/assets/models)
- android/app/src/main/java – MainActivity extends CapacitorActivity to host the WebView
- assets/models – TensorFlow.js face detection model shards loaded at runtime

a. Main Containers
1. Angular SPA (Web Container)
- UI Layer: pages, components, shared UI modules
- Services Layer: datas.service, quiz.service, state.service, update.service
- Constants & Helpers: static data, route helpers
2. Capacitor Bridge
- JavaScript ↔ Native plugins (using Capacitor Plugins API)
3. Native Android Layer
- Android WebView host (MainActivity)
- Native plugins (Camera, FileSystem, Device)
b. Assets & Models
- Local ML Models (face_expression_model, tiny_face_detector_model) served from assets/models
c. PWA/Web Deployment
- Service Worker (ngsw-config.json)
- Netlify hosting (netlify.toml)

##### Relationships and Data Flows
- User → Angular UI (components/pages) → Angular Router
- UI Components ↔ Shared Services (business logic, state)
- Services load static data (constants), assets (models), or call external APIs if any
- For native features (camera, file paths, speech recognition) → Capacitor Bridge → Native Android plugins → Device hardware
- Build pipeline: Angular CLI → dist/ (www) → Capacitor copy to android/app/src/main/assets/public → Android build

##### Architectural Patterns & Principles
- Modular Angular design: feature modules (home.module.ts), shared module for reusability
- Dependency Injection for services
- Lazy loading of pages via Router
- Separation of concerns: UI vs business logic vs native interaction
- PWA support: service worker with offline cache of assets & models

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Angular SPA"
        subgraph "UI Components & Pages"
            AppComponent["App Component"]:::frontend
            AppRoute["App Route"]:::frontend
            CardUI["CardUI Component"]:::frontend
            ContentUI["ContentUI Component"]:::frontend
            HomeModule["Home Module"]:::frontend
            HomeComponent["Home Component"]:::frontend
            QuizComponent["Quiz Component"]:::frontend
            FacialComponent["FacialExpression Component"]:::frontend
        end
        subgraph "Shared Services & State"
            DataService["Datas Service"]:::frontend
            QuizService["Quiz Service"]:::frontend
            StateService["State Service"]:::frontend
            UpdateService["Update Service"]:::frontend
        end
        subgraph "Constants & Helpers"
            QuizConst["Quiz Constants"]:::frontend
            WordsConst["Words Constants"]:::frontend
            RouteHelper["Custom Route Helper"]:::frontend
        end
        subgraph "Shared UI Modules & CDK"
            SharedModule["Shared Module"]:::frontend
            DialogService["CDK Dialog Service"]:::frontend
            BottomSheet["BottomSheet Component"]:::frontend
        end
        subgraph "Assets & Models"
            FaceModel["Face Expression Model"]:::assets
            TinyModel["Tiny Face Detector Model"]:::assets
        end
    end

    Bridge["Capacitor Bridge"]:::bridge

    subgraph "Native Android Layer"
        WebViewHost["Android WebView Host"]:::native
        MainActivity["MainActivity"]:::native
        AndroidManifest["AndroidManifest.xml"]:::native
        ActivityLayout["activity_main.xml"]:::native
    end

    subgraph "PWA / Web Deployment"
        Netlify["Netlify Hosting"]:::deployment
        ServiceWorker["Service Worker"]:::deployment
    end

    AppComponent -->|uses| DataService
    AppComponent -->|router| AppRoute
    CardUI -->|used in| AppComponent
    ContentUI -->|used in| AppComponent
    HomeComponent -->|declared in| HomeModule
    QuizComponent -->|declared in| HomeModule
    FacialComponent -->|declared in| HomeModule
    HomeModule -->|lazy loads| AppRoute
    DataService -->|uses| QuizConst
    DataService -->|uses| WordsConst
    DataService -->|loads| FaceModel
    DataService -->|loads| TinyModel
    DataService -->|calls| Bridge
    QuizService -->|calls| Bridge
    StateService -->|calls| Bridge
    UpdateService -->|calls| Bridge

    Bridge -->|plugin API| WebViewHost
    WebViewHost --> MainActivity
    MainActivity --> AndroidManifest
    MainActivity --> ActivityLayout

    Netlify -->|hosts| AppComponent
    ServiceWorker -->|caches| FaceModel
    ServiceWorker -->|configured by| ServiceWorker

    click AppComponent "https://github.com/flamilani/libras-virtual/blob/master/src/app/app.component.ts"
    click AppRoute "https://github.com/flamilani/libras-virtual/blob/master/src/app/app.route.ts"
    click CardUI "https://github.com/flamilani/libras-virtual/blob/master/src/app/components/UI/card-ui/card-ui.component.ts"
    click ContentUI "https://github.com/flamilani/libras-virtual/blob/master/src/app/components/UI/content-ui/content-ui.component.ts"
    click HomeModule "https://github.com/flamilani/libras-virtual/blob/master/src/app/pages/home/home.module.ts"
    click HomeComponent "https://github.com/flamilani/libras-virtual/blob/master/src/app/pages/home/home.component.ts"
    click QuizComponent "https://github.com/flamilani/libras-virtual/blob/master/src/app/pages/home/quiz/quiz.component.ts"
    click FacialComponent "https://github.com/flamilani/libras-virtual/blob/master/src/app/pages/home/facial-expression/facial-expression.component.ts"
    click DataService "https://github.com/flamilani/libras-virtual/blob/master/src/app/shared/services/datas.service.ts"
    click QuizService "https://github.com/flamilani/libras-virtual/blob/master/src/app/shared/services/quiz.service.ts"
    click StateService "https://github.com/flamilani/libras-virtual/blob/master/src/app/shared/states/state.service.ts"
    click UpdateService "https://github.com/flamilani/libras-virtual/blob/master/src/app/shared/services/update.service.ts"
    click QuizConst "https://github.com/flamilani/libras-virtual/blob/master/src/app/shared/constants/quiz.constant.ts"
    click WordsConst "https://github.com/flamilani/libras-virtual/blob/master/src/app/shared/constants/words.constant.ts"
    click RouteHelper "https://github.com/flamilani/libras-virtual/blob/master/src/app/shared/helpers/custom-route.ts"
    click SharedModule "https://github.com/flamilani/libras-virtual/blob/master/src/app/shared/shared.module.ts"
    click DialogService "https://github.com/flamilani/libras-virtual/blob/master/src/app/shared/cdk/dialog/dialog.service.ts"
    click BottomSheet "https://github.com/flamilani/libras-virtual/blob/master/src/app/shared/components/bottom-sheet/bottom-sheet.component.ts"
    click FaceModel "https://github.com/flamilani/libras-virtual/blob/master/src/assets/models/face_expression_model-weights_manifest.json"
    click TinyModel "https://github.com/flamilani/libras-virtual/blob/master/src/assets/models/tiny_face_detector_model-weights_manifest.json"
    click Bridge "https://github.com/flamilani/libras-virtual/blob/master/capacitor.config.ts"
    click MainActivity "https://github.com/flamilani/libras-virtual/blob/master/android/app/src/main/java/com/librasvirtual/app/MainActivity.java"
    click AndroidManifest "https://github.com/flamilani/libras-virtual/blob/master/android/app/src/main/AndroidManifest.xml"
    click ActivityLayout "https://github.com/flamilani/libras-virtual/blob/master/android/app/src/main/res/layout/activity_main.xml"
    click Netlify "https://github.com/flamilani/libras-virtual/blob/master/netlify.toml"
    click ServiceWorker "https://github.com/flamilani/libras-virtual/blob/master/ngsw-config.json"

    classDef frontend fill:#D0E6FF,stroke:#0066CC
    classDef bridge fill:#DFF2D8,stroke:#339933
    classDef native fill:#FFE5CC,stroke:#CC6600
    classDef assets fill:#EEEEEE,stroke:#999999
    classDef deployment fill:#F2F2F2,stroke:#666666
```
