# kreitinnsoftware/micewine-application architecture

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

- Interactive diagram: https://gitdiagram.com/kreitinnsoftware/micewine-application
- Repository: https://github.com/kreitinnsoftware/micewine-application

## Overview

##### Main Components

a. Android Application Layer:
- User Interface Components (Activities and Fragments)
- Input Handling System
- Controller Mapping System
- Settings Management
- File Management

b. Native Layer (C/C++):
- X Server Components (based on Termux-X11)
- Graphics Rendering Pipeline
- Input Processing

c. Emulation Layer:
- Wine Integration
- Box64 Runtime
- GPU Drivers (Turnip/Native/Zink)

##### Component Relationships

**[Android UI Layer]**
- ↕
**[Native Bridge Layer (AIDL)]**
- ↕
**[X Server / Graphics Layer]**
- ↕
**[Emulation Layer]**
- ↕
**[Hardware Layer]**

##### Specific Components to Highlight

a. Android UI Layer:
- Main Activity Flow (WelcomeActivity → MainActivity → EmulationActivity)
- Settings Management System
- Controller Mapping Interface
- File Management System

b. Native Bridge:
- AIDL Interface (ICmdEntryInterface)
- Input Event System
- Native Graphics Rendering

c. X Server Components:
- Lorie (X11 Server Implementation)
- Input Processing
- Clipboard Management
- SHM (Shared Memory)

d. Emulation Components:
- Wine Integration
- Box64 Runtime
- GPU Driver Integration

##### Important Architectural Patterns

- AIDL Communication between Java and Native code
- Event-driven Input Processing
- Graphics Pipeline Flow
- File System Integration
- Controller Input Mapping

##### External Dependencies

- Box64 Integration
- Wine Integration
- Mesa/GPU Drivers
- Termux-X11 Base

##### Data Flow Indicators

- User Input Flow
- Graphics Rendering Pipeline
- File System Operations
- Wine/Box64 Communication
- GPU Command Flow

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef android fill:#b3e0ff,stroke:#333,stroke-width:2px
    classDef native fill:#98FB98,stroke:#333,stroke-width:2px
    classDef xserver fill:#FFA07A,stroke:#333,stroke-width:2px
    classDef emulation fill:#DDA0DD,stroke:#333,stroke-width:2px
    classDef hardware fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Android UI Layer
    subgraph AndroidLayer["Android UI Layer"]
        Welcome["Welcome Activity"]:::android
        Main["Main Activity"]:::android
        Emulation["Emulation Activity"]:::android
        Settings["Settings Management"]:::android
        Controller["Controller System"]:::android
        FileManager["File Management"]:::android
    end

    %% Native Bridge Layer
    subgraph NativeBridge["Native Bridge Layer"]
        AIDL["AIDL Interface"]:::native
        InputEvent["Input Event System"]:::native
        NativeGraphics["Native Graphics"]:::native
    end

    %% X Server Layer
    subgraph XServer["X Server Layer"]
        Lorie["Lorie X11 Server"]:::xserver
        InputProc["Input Processing"]:::xserver
        Clipboard["Clipboard Manager"]:::xserver
        SHM["Shared Memory"]:::xserver
    end

    %% Emulation Layer
    subgraph EmulationLayer["Emulation Layer"]
        Wine["Wine"]:::emulation
        Box64["Box64 Runtime"]:::emulation
        GPUDrivers["GPU Drivers"]:::emulation
    end

    %% Hardware Layer
    subgraph HardwareLayer["Hardware Layer"]
        GPU["GPU (Vulkan 1.1/1.3)"]:::hardware
        Input["Input Devices"]:::hardware
        Storage["Storage"]:::hardware
    end

    %% Relationships
    Welcome --> Main
    Main --> Emulation
    Main --> Settings
    Main --> Controller
    Main --> FileManager

    Controller --> InputEvent
    Settings --> AIDL
    FileManager --> Storage

    AIDL --> Lorie
    InputEvent --> InputProc
    NativeGraphics --> Lorie

    Lorie --> Wine
    Lorie --> Box64
    Wine --> GPUDrivers
    Box64 --> GPUDrivers
    GPUDrivers --> GPU

    %% Click Events
    click Welcome "https://github.com/KreitinnSoftware/MiceWine-Application/blob/master/app/src/main/java/com/micewine/emu/activities/WelcomeActivity.kt"
    click Main "https://github.com/KreitinnSoftware/MiceWine-Application/blob/master/app/src/main/java/com/micewine/emu/activities/MainActivity.kt"
    click Emulation "https://github.com/KreitinnSoftware/MiceWine-Application/blob/master/app/src/main/java/com/micewine/emu/activities/EmulationActivity.kt"
    click Controller "https://github.com/KreitinnSoftware/MiceWine-Application/blob/master/app/src/main/java/com/micewine/emu/activities/ControllerMapper.kt"
    click Settings "https://github.com/KreitinnSoftware/MiceWine-Application/blob/master/app/src/main/java/com/micewine/emu/activities/GeneralSettings.kt"
    click AIDL "https://github.com/KreitinnSoftware/MiceWine-Application/blob/master/app/src/main/aidl/com/micewine/emu/ICmdEntryInterface.aidl"
    click InputEvent "https://github.com/KreitinnSoftware/MiceWine-Application/blob/master/app/src/main/java/com/micewine/emu/input/InputEventSender.java"
    click Lorie "https://github.com/KreitinnSoftware/MiceWine-Application/tree/master/app/src/main/cpp/lorie"
    click Wine "https://github.com/KreitinnSoftware/MiceWine-Application/blob/master/app/src/main/java/com/micewine/emu/core/WineWrapper.kt"
    click GPUDrivers "https://github.com/KreitinnSoftware/MiceWine-Application/blob/master/app/src/main/java/com/micewine/emu/activities/DriverManagerActivity.kt"
    click FileManager "https://github.com/KreitinnSoftware/MiceWine-Application/blob/master/app/src/main/java/com/micewine/emu/fragments/FileManagerFragment.kt"

    %% Legend
    subgraph Legend
        AndroidComp["Android Components"]:::android
        NativeComp["Native Components"]:::native
        XServerComp["X Server Components"]:::xserver
        EmulationComp["Emulation Components"]:::emulation
        HardwareComp["Hardware Components"]:::hardware
    end
```
