# fna-xna/fna architecture

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

- Interactive diagram: https://gitdiagram.com/fna-xna/fna
- Repository: https://github.com/fna-xna/fna

## Overview

##### Project type and purpose
- FNA is an open-source reimplementation of Microsoft XNA4 strictly for desktop environments. It provides a runtime library that game developers use in lieu of XNA to build and run 2D/3D games on Windows, Linux, and macOS.
- The README confirms it is a framework library (not an app or service) focusing on faithfully reproducing XNA’s runtime behavior.

##### File structure
- Top level:
- FNA.sln plus multiple .csproj files (Core, NetFramework, NetStandard) indicate it is a multi-targeted .NET library.
- Makefile and Directory.Build.props handle cross-platform build settings.
- .gitmodules and lib/ contain bundled external native or managed dependencies.
- lib/ submodule directories:
- FAudio (audio backend), FNA3D (graphics backend), SDL2-CS & SDL3-CS (P/Invoke wrappers for SDL), Theorafile (media container).
- src/ hierarchy:
- By namespace: Audio, Graphics (with Effect sub-folders), Content (with readers), Input, Media, Storage, Utilities, FNAPlatform, Design, etc.
- This reflects a layered architecture: core runtime API → subsystem implementations → platform abstraction → native backends.
- abi/ holds “API binding” C# projects duplicating Microsoft.Xna.Framework namespace—used for compatibility testing or reference builds.

##### README for additional insights
- Documentation lives on a wiki, implying users consult docs for deeper architecture.

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Consumer
    GameApp["Game Application"]:::external

    %% FNA API Layer
    subgraph "FNA Runtime Library (Managed Assemblies)"
        direction TB
        CoreProj["FNA.Core.dll"]:::managed
        NetStdProj["FNA.NetStandard.dll"]:::managed
        NetFwProj["FNA.NetFramework.dll"]:::managed
        subgraph "Core Runtime API & Services"
            direction TB
            GameBase["Game, GameComponent, GameServiceContainer, GameTime"]:::managed
            FrameworkDispatcher["FrameworkDispatcher"]:::managed
            TitleLaunch["TitleContainer, LaunchParameters"]:::managed
        end
        subgraph "Subsystems"
            direction TB
            Graphics["FNA.Graphics\n(GraphicsDeviceManager, SpriteBatch, Model)"]:::managed
            Audio["FNA.Audio\n(AudioEngine, SoundEffect, WaveBank)"]:::managed
            Input["FNA.Input\n(Keyboard, Mouse, GamePad, Touch)"]:::managed
            Content["FNA.Content\n(ContentManager, Readers)"]:::managed
            Media["FNA.Media\n(MediaPlayer, VideoPlayer)"]:::managed
            Storage["FNA.Storage\n(StorageDevice/Container)"]:::managed
            Utilities["FNA.Utilities\n(FileHelpers, AssemblyHelper)"]:::managed
            FNAPlatform["FNAPlatform\n(Window, EventLoop)"]:::abstraction
            Design["Design Converters"]:::managed
        end
    end

    %% ABI Compatibility Shim
    subgraph "ABI Layer (XNA Shim)"
        direction TB
        ABI["abi/ (XNA API Shim)"]:::shim
    end

    %% Native Backends
    subgraph "Native Libraries"
        direction TB
        FNA3D["FNA3D (Graphics Core)"]:::native
        FAudio["FAudio (Audio Mixer/Decoder)"]:::native
        SDL2CS["SDL2-CS Wrapper"]:::wrapper
        SDL3CS["SDL3-CS Wrapper"]:::wrapper
        Theora["Theorafile (Media Container)"]:::native
    end

    %% Build Configurations
    subgraph "Build & Solution"
        direction TB
        Solution["FNA.sln"]:::build
        CoreCsproj["FNA.Core.csproj"]:::build
        NetStdCsproj["FNA.NetStandard.csproj"]:::build
        NetFwCsproj["FNA.NetFramework.csproj"]:::build
        Props["Directory.Build.props"]:::build
        Makefile["Makefile"]:::build
    end

    %% Relationships
    GameApp -->|"calls API"| CoreProj
    GameApp -->|uses| NetStdProj
    GameApp -->|uses| NetFwProj

    CoreProj --> GameBase
    CoreProj --> FrameworkDispatcher
    CoreProj --> TitleLaunch

    CoreProj --> Graphics
    CoreProj --> Audio
    CoreProj --> Input
    CoreProj --> Content
    CoreProj --> Media
    CoreProj --> Storage
    CoreProj --> Utilities
    CoreProj --> FNAPlatform
    CoreProj --> Design

    Graphics -->|P/Invoke| FNA3D
    Audio -->|P/Invoke| FAudio
    Graphics -->|Uses| SDL2CS
    Audio -->|Uses| SDL2CS
    FNAPlatform -->|P/Invoke| SDL2CS
    FNAPlatform -->|P/Invoke| SDL3CS
    Content -->|Decoding| Theora

    ABI -->|mirrors API| CoreProj

    Solution --> CoreCsproj
    Solution --> NetStdCsproj
    Solution --> NetFwCsproj
    Solution --> Props
    Solution --> Makefile

    %% Click Events
    click Solution "https://github.com/fna-xna/fna/blob/master/FNA.sln"
    click CoreCsproj "https://github.com/fna-xna/fna/blob/master/FNA.Core.csproj"
    click NetStdCsproj "https://github.com/fna-xna/fna/blob/master/FNA.NetStandard.csproj"
    click NetFwCsproj "https://github.com/fna-xna/fna/blob/master/FNA.NetFramework.csproj"
    click Props "https://github.com/fna-xna/fna/blob/master/Directory.Build.props"
    click Makefile "https://github.com/fna-xna/fna/tree/master/Makefile"
    click ABI "https://github.com/fna-xna/fna/tree/master/abi/"
    click FNA3D "https://github.com/fna-xna/fna/tree/master/lib/FNA3D"
    click FAudio "https://github.com/fna-xna/fna/tree/master/lib/FAudio"
    click SDL2CS "https://github.com/fna-xna/fna/tree/master/lib/SDL2-CS"
    click SDL3CS "https://github.com/fna-xna/fna/tree/master/lib/SDL3-CS"
    click Theora "https://github.com/fna-xna/fna/tree/master/lib/Theorafile"
    click Audio "https://github.com/fna-xna/fna/tree/master/src/Audio/"
    click Graphics "https://github.com/fna-xna/fna/tree/master/src/Graphics/"
    click Input "https://github.com/fna-xna/fna/tree/master/src/Input/"
    click Content "https://github.com/fna-xna/fna/tree/master/src/Content/"
    click Media "https://github.com/fna-xna/fna/tree/master/src/Media/"
    click Storage "https://github.com/fna-xna/fna/tree/master/src/Storage/"
    click FNAPlatform "https://github.com/fna-xna/fna/tree/master/src/FNAPlatform/"
    click Utilities "https://github.com/fna-xna/fna/tree/master/src/Utilities/"
    click Design "https://github.com/fna-xna/fna/tree/master/src/Design/"
    click GameBase "https://github.com/fna-xna/fna/blob/master/src/Game.cs"
    click FrameworkDispatcher "https://github.com/fna-xna/fna/blob/master/src/FrameworkDispatcher.cs"
    click TitleLaunch "https://github.com/fna-xna/fna/blob/master/src/TitleContainer.cs"

    %% Styles
    classDef external fill:#eeeeee,stroke:#666,stroke-width:1px
    classDef managed fill:#cce5ff,stroke:#003399,stroke-width:1px
    classDef native fill:#ccffcc,stroke:#009900,stroke-width:1px
    classDef wrapper fill:#ffe5b4,stroke:#cc8400,stroke-width:1px
    classDef abstraction fill:#ffebcc,stroke:#cc7a00,stroke-width:1px
    classDef shim fill:#f2ccff,stroke:#9900cc,stroke-width:1px
    classDef build fill:#e2e2f0,stroke:#6666a3,stroke-width:1px
```
