# cortofanchic/useevtubing architecture

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

- Interactive diagram: https://gitdiagram.com/cortofanchic/useevtubing
- Repository: https://github.com/cortofanchic/useevtubing

## Overview

1. **What this repo is**
   - An Android VTubing app for real-time avatar animation from the device camera.
   - It is a **mixed Kotlin + NDK/C++** project: Kotlin owns the app/UI flow, while native C++ handles 3D model/VRM processing and rendering-related work.

2. **Top-level app shape**
   - The app is centered in `app/` and runs on **Android API 26+**.
   - The entry point is `MainActivity.kt`, with a single app shell hosting multiple screens rather than a server/client split.
   - `activity_main.xml` exists, so the UI is likely hosted through the Android activity layer with screen navigation inside the app.

3. **Primary user-flow screens**
   - `screens/WelcomeScreen.kt` introduces the app.
   - `screens/CharacterScreen.kt` is the model setup boundary where the user loads a `.vrm` avatar.
   - `screens/CameraScreen.kt` is the runtime animation screen where the camera feed drives the avatar.
   - `screens/GalleryScreen.kt` likely manages browsing/selecting saved avatars or captured media.

4. **Core runtime data flow**
   - User selects a VRM avatar in the character flow.
   - The app converts/loads that model into a renderable format.
   - The camera screen captures live video, extracts motion/face signals, and forwards those signals to the avatar renderer.
   - The renderer updates the 3D model frame-by-frame and displays the animated VTuber avatar back to the user.

5. **Camera + tracking subsystem**
   - The README states the app uses **ML Kit** for **pose tracking (33 landmarks)** and face tracking.
   - This implies a real-time pipeline: camera frames → ML inference → pose/face state → avatar rig/animation input.
   - The app supports **front and back cameras** and **mirroring**, so camera orientation is part of the runtime state.

6. **3D model / rendering subsystem**
   - `ModelRenderer.kt` is the Kotlin-side rendering bridge.
   - `app/src/main/cpp/native-lib.cpp` plus `CMakeLists.txt` indicate a native shared library is built for model handling and rendering support.
   - Native dependencies under `app/src/main/cpp/libs/` include `VRM.h`, `fx-gltf`, and `json`, which strongly suggests VRM/glTF parsing and conversion happen in native code.
   - The README specifically mentions **VRM support with automatic GLB conversion**, so model ingestion is a dedicated boundary, not just a UI concern.

7. **Persistence and media handling**
   - The README says loaded avatars are **saved between launches**, so there is some app-level persistence for the chosen model.
   - The app also supports **photo capture and video recording** from the camera screen, so media output is part of the runtime path and likely tied to Android storage/media permissions.
   - Required permissions are `CAMERA` plus external storage access, indicating direct device I/O rather than cloud storage.

8. **Android framework boundaries**
   - This project depends on Android platform services for:
     - camera access,
     - storage/media access,
     - app lifecycle and activity hosting,
     - resource/theme management.
   - There is no sign of a backend service or network API in the tree, so the architecture appears fully local/on-device.

9. **UI organization and shared app state**
   - `ui/theme/` contains color, typography, and theme definitions, suggesting the screens share a consistent styled shell.
   - `utils/BottomNavItemModel.kt` and `utils/Constants.kt` indicate shared navigation and configuration state, probably used to wire the main screen navigation and app-level settings.

10. **Repository layout and build boundaries**
   - `app/build.gradle.kts` and `gradle/libs.versions.toml` define the Android build and dependency versions.
   - The NDK build is isolated under `app/src/main/cpp/`, which is the main boundary between Kotlin app logic and native 3D/model processing.
   - Tests are split into standard Android instrumentation tests and local unit tests, but they are peripheral to the runtime architecture.

11. **What to draw in an architecture diagram**
   - A good diagram should show:
     - **User/UI layer**: welcome, character, gallery, camera screens
     - **Camera + ML layer**: Android camera input and ML Kit pose/face tracking
     - **Avatar/model layer**: VRM loading, conversion, persistence
     - **Native rendering layer**: C++/NDK, fx-gltf/json/VRM support
     - **Output layer**: on-screen animated avatar plus photo/video capture
   - The key flow is **camera input and model input converge into the renderer**, with Kotlin coordinating the app experience and C++ doing the heavy 3D work.

Main entry points: [`app/src/main/java/com/example/useevtubingapp/MainActivity.kt`](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/MainActivity.kt) (Main Activity), [`app/src/main/java/com/example/useevtubingapp/screens/CameraScreen.kt`](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/screens/CameraScreen.kt) (Camera), [`app/src/main/java/com/example/useevtubingapp/screens/CharacterScreen.kt`](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/screens/CharacterScreen.kt) (Character), [`app/src/main/cpp/native-lib.cpp`](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/cpp/native-lib.cpp) (native-lib)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_app["Android app"]
  node_node_main_activity["Main Activity<br/>Android entry<br/>[MainActivity.kt]"]
  node_node_welcome_screen["Welcome<br/>Intro screen<br/>[WelcomScreen.kt]"]
  node_node_character_screen["Character<br/>Avatar setup<br/>[CharacterScreen.kt]"]
  node_node_camera_screen["Camera<br/>Runtime screen<br/>[CameraScreen.kt]"]
  node_node_gallery_screen["Gallery<br/>Media browser<br/>[GalleryScreen.kt]"]
  node_node_model_renderer["Model Renderer<br/>Render bridge<br/>[ModelRenderer.kt]"]
  node_node_camera_tracking(("Tracking<br/>ML Kit pipeline"))
  node_node_media_capture["Capture<br/>Photo/video I/O"]
  node_node_avatar_state[("Avatar state<br/>Persistence<br/>[Constants.kt]")]
  node_node_nav_state["Nav state<br/>Shared config"]
  node_node_theme["Theme<br/>[Theme.kt]"]
end

subgraph group_group_native["Native 3D"]
  node_node_native_lib["native-lib<br/>C++ bridge<br/>[native-lib.cpp]"]
  node_node_vrm_lib["VRM libs<br/>3D parsing<br/>[VRM.h]"]
  node_node_cmake["CMake<br/>Native build<br/>[CMakeLists.txt]"]
end

subgraph group_group_android["Platform"]
  node_node_activity_layout["Activity layout<br/>Android layout<br/>[activity_main.xml]"]
  node_node_manifest["Manifest<br/>Android config"]
end

node_node_manifest -->|"launches"| node_node_main_activity
node_node_main_activity -->|"hosts"| node_node_activity_layout
node_node_main_activity -->|"navigates to"| node_node_welcome_screen
node_node_main_activity -->|"navigates to"| node_node_character_screen
node_node_main_activity -->|"navigates to"| node_node_camera_screen
node_node_main_activity -->|"navigates to"| node_node_gallery_screen
node_node_camera_screen -->|"feeds frames"| node_node_camera_tracking
node_node_camera_tracking -->|"drives avatar"| node_node_model_renderer
node_node_character_screen -->|"stores model"| node_node_avatar_state
node_node_avatar_state -->|"restores model"| node_node_camera_screen
node_node_character_screen -->|"loads VRM"| node_node_model_renderer
node_node_model_renderer -->|"JNI bridge"| node_node_native_lib
node_node_native_lib -->|"parses models"| node_node_vrm_lib
node_node_native_lib -->|"built by"| node_node_cmake
node_node_camera_screen -->|"captures media"| node_node_media_capture
node_node_gallery_screen -->|"browses output"| node_node_media_capture
node_node_main_activity -->|"uses"| node_node_nav_state
node_node_main_activity -->|"applies"| node_node_theme

click node_node_main_activity "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/MainActivity.kt"
click node_node_welcome_screen "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/screens/WelcomScreen.kt"
click node_node_character_screen "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/screens/CharacterScreen.kt"
click node_node_camera_screen "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/screens/CameraScreen.kt"
click node_node_gallery_screen "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/screens/GalleryScreen.kt"
click node_node_model_renderer "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/ModelRenderer.kt"
click node_node_avatar_state "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/utils/Constants.kt"
click node_node_nav_state "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/utils/BottomNavItemModel.kt"
click node_node_theme "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/ui/theme/Theme.kt"
click node_node_activity_layout "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/res/layout/activity_main.xml"
click node_node_manifest "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/AndroidManifest.xml"
click node_node_native_lib "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/cpp/native-lib.cpp"
click node_node_vrm_lib "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/cpp/libs/VRM.h"
click node_node_cmake "https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/cpp/CMakeLists.txt"

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_node_main_activity,node_node_welcome_screen,node_node_character_screen,node_node_camera_screen,node_node_gallery_screen,node_node_model_renderer,node_node_camera_tracking,node_node_media_capture,node_node_avatar_state,node_node_nav_state,node_node_theme toneBlue
class node_node_native_lib,node_node_vrm_lib,node_node_cmake toneAmber
class node_node_activity_layout,node_node_manifest toneMint
```

## Components

### Android app

Kotlin app layer, screens, and shared UI state

- [Main Activity](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/MainActivity.kt): Android entry · Hosts the app shell and screen navigation · `app/src/main/java/com/example/useevtubingapp/MainActivity.kt`
- [Welcome](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/screens/WelcomScreen.kt): Intro screen · Entry screen that introduces the app · `app/src/main/java/com/example/useevtubingapp/screens/WelcomScreen.kt`
- [Character](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/screens/CharacterScreen.kt): Avatar setup · Loads and prepares the user's VRM model · `app/src/main/java/com/example/useevtubingapp/screens/CharacterScreen.kt`
- [Camera](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/screens/CameraScreen.kt): Runtime screen · Live camera-driven avatar animation and capture · `app/src/main/java/com/example/useevtubingapp/screens/CameraScreen.kt`
- [Gallery](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/screens/GalleryScreen.kt): Media browser · Browses saved avatars or captured media · `app/src/main/java/com/example/useevtubingapp/screens/GalleryScreen.kt`
- [Model Renderer](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/ModelRenderer.kt): Render bridge · Kotlin-side bridge into native model rendering · `app/src/main/java/com/example/useevtubingapp/ModelRenderer.kt`
- **Tracking**: ML Kit pipeline · Camera frames are analyzed for pose and face signals
- **Capture**: Photo/video I/O · Takes photos and records video from the camera flow
- [Avatar state](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/utils/Constants.kt): Persistence · Stores the selected avatar between launches · `app/src/main/java/com/example/useevtubingapp/utils/Constants.kt`
- [Nav state](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/utils/BottomNavItemModel.kt): Shared config · Bottom navigation and app-level constants · `app/src/main/java/com/example/useevtubingapp/utils/BottomNavItemModel.kt`
- [Theme](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/java/com/example/useevtubingapp/ui/theme/Theme.kt): UI theme · Shared colors, typography, and theme setup · `app/src/main/java/com/example/useevtubingapp/ui/theme/Theme.kt`

### Native 3D

NDK/C++ model ingestion and rendering support

- [native-lib](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/cpp/native-lib.cpp): C++ bridge · JNI entry point for native model handling · `app/src/main/cpp/native-lib.cpp`
- [VRM libs](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/cpp/libs/VRM.h): 3D parsing · VRM, glTF, and JSON support for model ingestion · `app/src/main/cpp/libs/VRM.h`
- [CMake](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/cpp/CMakeLists.txt): Native build · Builds the shared native library and dependencies · `app/src/main/cpp/CMakeLists.txt`

### Platform

Android manifest, resources, and host shell

- [Activity layout](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/res/layout/activity_main.xml): Android layout · Host layout for the main activity shell · `app/src/main/res/layout/activity_main.xml`
- [Manifest](https://github.com/cortofanchic/useevtubing/blob/main/app/src/main/AndroidManifest.xml): Android config · Declares the app entry, permissions, and platform wiring · `app/src/main/AndroidManifest.xml`

## Connections

- Manifest → Main Activity: launches · Android starts the main activity from the manifest
- Main Activity → Activity layout: hosts · The activity uses the main layout as its shell
- Main Activity → Welcome: navigates to · Initial app flow begins on the welcome screen
- Main Activity → Character: navigates to · User moves into avatar setup
- Main Activity → Camera: navigates to · Main runtime screen for tracking and rendering
- Main Activity → Gallery: navigates to · Provides access to saved media and avatars
- Camera → Tracking: feeds frames · Camera input is analyzed for pose and face state
- Tracking → Model Renderer: drives avatar · Tracking output updates the animated model
- Character → Avatar state: stores model · Selected avatar is persisted for later launches
- Avatar state → Camera: restores model · Runtime screen reuses the saved avatar
- Character → Model Renderer: loads VRM · Model setup hands the chosen avatar to rendering
- Model Renderer → native-lib: JNI bridge · Kotlin rendering calls cross into native code
- native-lib → VRM libs: parses models · Native code uses VRM/glTF/JSON support for ingestion
- native-lib → CMake: built by · CMake builds the native shared library
- Camera → Capture: captures media · The runtime screen supports photos and video recording
- Gallery → Capture: browses output · Gallery presents captured media or saved assets
- Main Activity → Nav state: uses · Shared navigation configuration wires the app shell
- Main Activity → Theme: applies · App-wide styling is provided through the shared theme
