# josefnemec/playnite architecture

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

- Interactive diagram: https://gitdiagram.com/josefnemec/playnite
- Repository: https://github.com/josefnemec/playnite

## Overview

##### Main Components
- User Interfaces:
- Playnite.DesktopApp (the primary WPF desktop interface).
- Playnite.FullscreenApp (provides a fullscreen gaming experience).
- Core Application Layer:
- Playnite (contains the majority of business logic, data management, controllers, and common utilities).
- Playnite.API and related namespaces (wrap external integrations, add-ons, and internal service APIs).
- Extension & Plugin System:
- PlayniteSDK: Exposes APIs and models for third-party developers to write plugins/extensions.
- -ons / ThirdPartyClients - these support plugins, themes, and scripts.
- Data & Persistence:
- Database modules for local game libraries, settings, collections, and metadata.
- Localization and resource management (Playnite/Localization, Themes, Resources).
- External Integration Components:
- API modules and controllers integrating with third-party libraries (Steam, Epic, etc.).
- Emulation support (modules under Playnite/Emulation support various emulators, each defined by its own YAML configuration).
- Supporting Tools:
- Build scripts, installer tools, and utilities (Tools and Tests directories).

##### Relationships and Interactions
- UI components (Desktop and Fullscreen) interact with their respective ViewModels (following an MVVM pattern) that then invoke underlying business logic in the core Playnite layer.
- The Core Application Layer aggregates game data from a variety of sources (local libraries, API calls, emulator configurations) and passes the appropriate information to the views.
- The Plugin/SDK layer is designed with extensibility in mind. It communicates with the core using defined APIs and events (e.g. notifications, settings changes) and is hosted in a separate SDK project.
- External integrations (API wrappers for services and emulators) are consumed by the core business logic to update game metadata, manage user sessions, and handle library synchronizations.
- Testing modules target almost every layer (UI tests, business logic tests, API behavior tests) ensuring that each designated section remains modular and loosely coupled.

##### Architectural Patterns & Technologies
- MVVM (Model-View-ViewModel) is evident in the separation of UI (XAML-based views) from ViewModels and Controllers.
- Modular and extensible architecture: The separation between the core engine, UI interfaces, and the SDK allows for plugin-based extensions.
- The use of build and deployment scripts (such as PowerShell scripts and build.xml) reflects a CI/CD approach to manage multi-project builds.
- Use of .NET libraries, WPF for UI, and likely dependency injection (or at least loose coupling through abstracted APIs) are critical to the project’s design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interfaces"
        desktopUI["Desktop UI (Playnite.DesktopApp)"]:::ui
        fullscreenUI["Fullscreen UI (Playnite.FullscreenApp)"]:::ui
    end

    subgraph "Core Application Layer"
        coreLayer["Business Logic Core (Playnite)"]:::core
    end

    subgraph "Extensions & Integrations"
        playniteSDK["Plugin/SDK (PlayniteSDK)"]:::plugin
        addOns["Add-ons (Plugins, UI Themes)"]:::plugin
        thirdPartyClients["ThirdParty Clients (PowerShell Scripts)"]:::plugin
        externalAPI["External API Components (Integrations)"]:::external
    end

    subgraph "Data & Persistence"
        database["Database & Local Game Library"]:::data
        localization["Localization & Resources"]:::data
    end

    subgraph "Emulation Support"
        emulation["Emulation Manager (Emulator Configurations)"]:::emulation
    end

    subgraph "Supporting Tools & Testing"
        buildScripts["Build Scripts"]:::tools
        tools["Installer Tools/Utilities"]:::tools
        testingModules["Testing Modules"]:::test
    end

    %% UI to Core interactions (MVVM pattern)
    desktopUI -->|"requests"| coreLayer
    fullscreenUI -->|"requests"| coreLayer
    coreLayer -->|"updates"| desktopUI
    coreLayer -->|"updates"| fullscreenUI

    %% Core interacting with Extensions & Integrations
    coreLayer <-->|"plugin integration"| playniteSDK
    coreLayer <-->|"plugin integration"| addOns
    coreLayer <-->|"plugin integration"| thirdPartyClients
    coreLayer -->|"calls"| externalAPI

    %% Core interacting with Data & Persistence
    coreLayer -->|"saves/reads"| database
    coreLayer -->|"localizes"| localization

    %% Core interacting with Emulation Support
    coreLayer -->|"loads configs"| emulation

    %% Supporting Tools integrations
    buildScripts -->|"CI/CD build"| coreLayer
    tools -->|"deployment"| coreLayer
    testingModules -->|"validate"| coreLayer

    %% Click Events for components
    click desktopUI "https://github.com/josefnemec/playnite/blob/master/source/Playnite.DesktopApp"
    click fullscreenUI "https://github.com/josefnemec/playnite/blob/master/source/Playnite.FullscreenApp"
    click coreLayer "https://github.com/josefnemec/playnite/tree/master/source/Playnite"
    click externalAPI "https://github.com/josefnemec/playnite/tree/master/source/Playnite/API"
    click playniteSDK "https://github.com/josefnemec/playnite/tree/master/source/PlayniteSDK"
    click addOns "https://github.com/josefnemec/playnite/tree/master/source/Playnite/Addons"
    click thirdPartyClients "https://github.com/josefnemec/playnite/tree/master/source/Playnite/ThirdPartyClients"
    click database "https://github.com/josefnemec/playnite/tree/master/source/Playnite/Database"
    click localization "https://github.com/josefnemec/playnite/tree/master/source/Playnite/Localization"
    click emulation "https://github.com/josefnemec/playnite/tree/master/source/Playnite/Emulation"
    click buildScripts "https://github.com/josefnemec/playnite/tree/master/build"
    click tools "https://github.com/josefnemec/playnite/tree/master/source/Tools"
    click testingModules "https://github.com/josefnemec/playnite/tree/master/source/Tests"

    %% Class Definitions for color styling
    classDef ui fill:#add8e6,stroke:#0000ff,stroke-width:2px;
    classDef core fill:#90ee90,stroke:#008000,stroke-width:2px;
    classDef plugin fill:#ffcc99,stroke:#ff8c00,stroke-width:2px;
    classDef external fill:#f0e68c,stroke:#bdb76b,stroke-width:2px;
    classDef data fill:#e0ffff,stroke:#008b8b,stroke-width:2px;
    classDef emulation fill:#da70d6,stroke:#8b008b,stroke-width:2px;
    classDef tools fill:#d3d3d3,stroke:#696969,stroke-width:2px;
    classDef test fill:#d3d3d3,stroke:#696969,stroke-width:2px;
```
