# 4sval/fmodel architecture

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

- Interactive diagram: https://gitdiagram.com/4sval/fmodel
- Repository: https://github.com/4sval/fmodel

## Overview

##### Project Type and Purpose
- Type: Single‐process desktop application built in C# with WPF (XAML + code‐behind).
- Purpose: Provide a graphical interface (Explorer) to browse, preview, convert, and “snoop” into Unreal Engine game archives, leveraging the CUE4Parse parsing engine.

##### File Structure
- Presentation Layer (“FModel/Views” + “FModel/ViewModels”):
– Views: XAML files define UI controls, custom controls, and the 3D “Snooper” viewport.
– ViewModels: MVVM classes mediate data binding, commands, and user interactions.
- Application Services (“FModel/Services”):
– ApplicationService: central application lifecycle manager.
– DiscordService, other external API providers.
- Core/Domain Logic:
– Creator (packages, “Base…” classes) for exporting or customizing parsed assets.
– Extensions: helper methods for CUE4Parse, collections, clipboard, etc.
– Framework: command pattern, async queue, navigation, JSON serialization (JsonNetSerializer), logging (SerilogEnricher), ImGuiController for OpenGL.
- Settings and Persistence (“FModel/Settings”):
– User directory, endpoints, versioning, custom directory settings.
– Stored in local files/config.
- External Dependencies:
– CUE4Parse (submodule) for archive parsing.
– Newtonsoft.Json for JSON.
– Serilog for logging.
– OpenGL shaders and resources under “FModel/Resources.”

##### README for Additional Insights
- Core parsing library: CUE4Parse (external).
- Target platforms: UE4 & UE5 archives.
- Features: Asset preview, conversion, structural exploration, 3D model inspection.

##### Components
a. Presentation Layer
- WPF Views (XAML) ←→ ViewModel components
- Custom Controls (TreeView, AvalonEditor, 3D viewport)
b. Application Layer
- ViewModels dispatch Commands → Framework/Services
- Command Bus (ViewModelCommand → AsyncQueue)
c. Domain/Parsing Layer
- CUE4Parse Core Library
- Creator Package: Base classes for various game data (FN, BB, MV, SB)
d. Infrastructure Layer
- JSON Serializer (JsonNetSerializer)
- Logging (SerilogEnricher)
- ImGuiController + OpenGL Renderer (Shaders, Buffers) for 3D snooping
e. Persistence Layer
- Settings Manager (EndpointSettings, DirectorySettings) → Local files
f. External APIs
- Fortnite API, Epic API, GitHub API, FModel API, Valorant API (DynamicApiEndpoint classes)
- Discord integration

##### Interactions & Data Flow
- User clicks UI Control → Bound Command in ViewModel → passes through Framework to Service or CUE4Parse → Domain produces asset metadata or binary → returned to ViewModel → UI updates.
- 3D Model View (“Snooper”) → ViewModel triggers RenderLoop in ImGuiController → OpenGL buffers & shaders render UModel assets.
- Settings changes in UI → SettingsViewModel → SettingsManager writes to disk.
- API calls (GitHub, Fortnite) → FRestRequest → JSON deserialized via JsonNetSerializer → ViewModel displays results.

##### Architectural Patterns & Design Principles
- MVVM: clear separation of Views, ViewModels, and Models/Services.
- Command Pattern: Framework/Command classes encapsulate user actions.
- Dependency Injection (lightweight, manual): Services injected into ViewModels.
- Modular layering: Presentation → Application → Domain → Infrastructure → External.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers and Components

    subgraph "Presentation Layer" 
        style PresentationLayer fill:#add8e6,stroke:#000
        Views["Views (XAML)"] 
        Snooper3D["Snooper 3D View"] 
        ViewModels["ViewModels"] 
        CustomControls["Custom Controls"] 
        AvalonEditor["AvalonEditor.xaml"]
    end

    subgraph "Application Layer"
        style ApplicationLayer fill:#90ee90,stroke:#000
        ApplicationService["ApplicationService"] 
        DiscordService["DiscordService"] 
        FRestRequest["FRestRequest"]
        Command["Command.cs"] 
        AsyncQueue["AsyncQueue.cs"] 
        ViewModelBase["ViewModel.cs"] 
        ViewModelCommand["ViewModelCommand.cs"]
    end

    subgraph "Domain Layer"
        style DomainLayer fill:#ffa500,stroke:#000
        CUE4Parse["CUE4Parse Submodule"] 
        CreatorPackage["Creator Package"] 
    end

    subgraph "Infrastructure Layer"
        style InfraLayer fill:#d3d3d3,stroke:#000
        JsonNet["JsonNetSerializer.cs"] 
        SerilogEnricher["SerilogEnricher.cs"] 
        ImGuiController["ImGuiController.cs"] 
        Shaders["OpenGL Shaders & Resources"]
    end

    subgraph "Persistence Layer"
        style PersistenceLayer fill:#ffdead,stroke:#000
        UserSettings["UserSettings.cs"] 
        DirectorySettings["DirectorySettings.cs"] 
        EndpointSettings["EndpointSettings.cs"] 
        VersioningSettings["VersioningSettings.cs"]
    end

    subgraph "External APIs"
        style ExternalLayer fill:#f0e68c,stroke:#000
        AbstractApiProvider["AbstractApiProvider.cs"] 
        DynamicApiEndpoint["DynamicApiEndpoint.cs"] 
        APIEndpoints["*ApiEndpoint.cs"]
    end

    %% Connections
    Views -->|"binds to"| ViewModels
    Snooper3D -->|"uses VM"| ViewModels
    CustomControls --> ViewModels
    AvalonEditor --> CustomControls

    ViewModels -->|"InvokeCommand"| Command
    Command --> AsyncQueue
    ViewModels -->|"calls API"| FRestRequest
    ViewModels -->|"injects"| ApplicationService
    ViewModels -->|"calls"| DiscordService
    ViewModels -->|"ParseArchive"| CUE4Parse
    ViewModels -->|"Use Creator"| CreatorPackage
    ViewModels -->|"DeserializeJSON"| JsonNet
    ViewModels -->|"Log Events"| SerilogEnricher
    ViewModels -->|"RenderFrame"| ImGuiController
    ImGuiController --> Shaders
    ViewModels -->|"Read/Write"| UserSettings
    ViewModels -->|"Read/Write"| DirectorySettings
    ViewModels -->|"Read/Write"| EndpointSettings
    ViewModels -->|"Read/Write"| VersioningSettings
    ViewModels --> AbstractApiProvider
    ViewModels --> DynamicApiEndpoint
    ViewModels --> APIEndpoints

    %% Click Events
    click Views "https://github.com/4sval/fmodel/tree/dev/FModel/Views"
    click Snooper3D "https://github.com/4sval/fmodel/tree/dev/FModel/Views/Snooper"
    click ViewModels "https://github.com/4sval/fmodel/tree/dev/FModel/ViewModels"
    click CustomControls "https://github.com/4sval/fmodel/tree/dev/FModel/Views/Resources/Controls"
    click AvalonEditor "https://github.com/4sval/fmodel/blob/dev/FModel/Views/Resources/Controls/AvalonEditor.xaml"
    click ApplicationService "https://github.com/4sval/fmodel/blob/dev/FModel/Services/ApplicationService.cs"
    click DiscordService "https://github.com/4sval/fmodel/blob/dev/FModel/Services/DiscordService.cs"
    click CUE4Parse "https://github.com/4sval/fmodel/tree/dev/CUE4Parse/"
    click CreatorPackage "https://github.com/4sval/fmodel/tree/dev/FModel/Creator"
    click UserSettings "https://github.com/4sval/fmodel/blob/dev/FModel/Settings/UserSettings.cs"
    click DirectorySettings "https://github.com/4sval/fmodel/blob/dev/FModel/Settings/DirectorySettings.cs"
    click EndpointSettings "https://github.com/4sval/fmodel/blob/dev/FModel/Settings/EndpointSettings.cs"
    click VersioningSettings "https://github.com/4sval/fmodel/blob/dev/FModel/Settings/VersioningSettings.cs"
    click Command "https://github.com/4sval/fmodel/blob/dev/FModel/Framework/Command.cs"
    click AsyncQueue "https://github.com/4sval/fmodel/blob/dev/FModel/Framework/AsyncQueue.cs"
    click ViewModelBase "https://github.com/4sval/fmodel/blob/dev/FModel/Framework/ViewModel.cs"
    click ViewModelCommand "https://github.com/4sval/fmodel/blob/dev/FModel/Framework/ViewModelCommand.cs"
    click FRestRequest "https://github.com/4sval/fmodel/blob/dev/FModel/Framework/FRestRequest.cs"
    click JsonNet "https://github.com/4sval/fmodel/blob/dev/FModel/Framework/JsonNetSerializer.cs"
    click SerilogEnricher "https://github.com/4sval/fmodel/blob/dev/FModel/Framework/SerilogEnricher.cs"
    click ImGuiController "https://github.com/4sval/fmodel/blob/dev/FModel/Framework/ImGuiController.cs"
    click Shaders "https://github.com/4sval/fmodel/tree/dev/FModel/Resources/"
    click AbstractApiProvider "https://github.com/4sval/fmodel/blob/dev/FModel/ViewModels/ApiEndpoints/AbstractApiProvider.cs"
    click DynamicApiEndpoint "https://github.com/4sval/fmodel/blob/dev/FModel/ViewModels/ApiEndpoints/DynamicApiEndpoint.cs"
    click APIEndpoints "https://github.com/4sval/fmodel/blob/dev/FModel/ViewModels/ApiEndpoints/*ApiEndpoint.cs"

    %% Styles
    classDef presentation fill:#add8e6,stroke:#000
    classDef application fill:#90ee90,stroke:#000
    classDef domain fill:#ffa500,stroke:#000
    classDef infrastructure fill:#d3d3d3,stroke:#000
    classDef persistence fill:#ffdead,stroke:#000
    classDef external fill:#f0e68c,stroke:#000

    class Views,Snooper3D,ViewModels,CustomControls,AvalonEditor presentation
    class ApplicationService,DiscordService,FRestRequest,Command,AsyncQueue,ViewModelBase,ViewModelCommand application
    class CUE4Parse,CreatorPackage domain
    class JsonNet,SerilogEnricher,ImGuiController,Shaders infrastructure
    class UserSettings,DirectorySettings,EndpointSettings,VersioningSettings persistence
    class AbstractApiProvider,DynamicApiEndpoint,APIEndpoints external
```
