# gracioni/geranes architecture

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

- Interactive diagram: https://gitdiagram.com/gracioni/geranes
- Repository: https://github.com/gracioni/geranes

## Overview

GeraNES is a cross-platform, cycle-accurate NES/Famicom emulator with desktop, Android, web, and libretro entry points, plus room-based netplay. The principal workflow is to load a game, emulate it and its peripherals, then present audio/video and persist or enhance play with features such as save states, rewind, patches, and visual mods. The graph preserves documented capabilities, but many app-to-core and netplay runtime links are only indicated as unverified because their implementation was not sampled.

Main entry points: [`src/GeraNES/GeraNESEmu.h`](https://github.com/gracioni/geranes/blob/master/src/GeraNES/GeraNESEmu.h) (Console Emulator), [`src/GeraNESApp/GeraNESApp.cpp`](https://github.com/gracioni/geranes/blob/master/src/GeraNESApp/GeraNESApp.cpp) (Emulator UI), [`src/main.cpp`](https://github.com/gracioni/geranes/blob/master/src/main.cpp) (App Entry), [`src/libretro/GeraNESLibretro.cpp`](https://github.com/gracioni/geranes/blob/master/src/libretro/GeraNESLibretro.cpp) (Libretro Core)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App and Frontends"]
  node_app_entry["App Entry<br/>[main.cpp]"]
  node_app_ui["Emulator UI<br/>[GeraNESApp.cpp]"]
  node_input["Input Handling<br/>[InputManager.cpp]"]
  node_libretro["Libretro Core"]
end

subgraph group_emulation["Emulation Core"]
  node_emulator["Console Emulator<br/>[GeraNESEmu.h]"]
  node_cpu["CPU<br/>[CPU2A03.h]"]
  node_ppu["PPU<br/>[PPU.h]"]
  node_apu["Audio Unit<br/>[APU.h]"]
  node_cartridge["Cartridge and Mappers<br/>[Cartridge.h]"]
  node_peripherals["Controllers and Peripherals"]
end

subgraph group_content["Content and Enhancements"]
  node_rom["ROM and Patch Loading<br/>[RomFile.h]"]
  node_database[("Game Database<br/>[GameDatabase.h]")]
  node_mods["Visual Mods<br/>[ModManager.cpp]"]
end

subgraph group_playback["Playback Features"]
  node_state["State Serialization<br/>[Serialization.h]"]
  node_rewind["Save States and Rewind<br/>[Rewind.h]"]
  node_replay["Replay<br/>[ReplaySession.cpp]"]
end

subgraph group_netplay["Room Netplay"]
  node_net_ui["Netplay Room UI"]
  node_net_runtime["Netplay Runtime"]
  node_net_coordinator["Session Coordination"]
  node_signaling["WebRTC Signaling"]
end

node_user(("Player"))
node_peer(("Other Players"))
node_signaling_service["Signaling Service"]

node_user -->|"starts"| node_app_entry
node_app_entry -->|"creates and runs"| node_app_ui
node_user -.->|"loads core"| node_libretro
node_app_ui -.->|"collects controls"| node_input
node_app_ui -.->|"drives emulation"| node_emulator
node_libretro -->|"runs emulation"| node_emulator
node_emulator -->|"uses"| node_cpu
node_emulator -->|"uses"| node_ppu
node_emulator -->|"uses"| node_apu
node_emulator -->|"uses"| node_cartridge
node_emulator -->|"uses"| node_peripherals
node_emulator -.->|"serializes state"| node_state
node_user -.->|"opens game"| node_rom
node_rom -.->|"loads content"| node_emulator
node_emulator -.->|"consults metadata"| node_database
node_user -->|"loads visual mods"| node_mods
node_mods -.->|"enhances rendering"| node_ppu
node_user -->|"saves or rewinds"| node_rewind
node_user -.->|"plays replay"| node_replay
node_user -->|"joins room"| node_net_ui
node_net_ui -.->|"controls session"| node_net_runtime
node_net_runtime -.->|"coordinates play"| node_net_coordinator
node_net_coordinator -.->|"signals peers"| node_signaling
node_signaling -.->|"exchanges signaling"| node_signaling_service
node_signaling_service -.->|"connects players"| node_peer

click node_app_entry "https://github.com/gracioni/geranes/blob/master/src/main.cpp"
click node_app_ui "https://github.com/gracioni/geranes/blob/master/src/GeraNESApp/GeraNESApp.cpp"
click node_input "https://github.com/gracioni/geranes/blob/master/src/GeraNESApp/InputManager.cpp"
click node_libretro "https://github.com/gracioni/geranes/blob/master/src/libretro/GeraNESLibretro.cpp"
click node_emulator "https://github.com/gracioni/geranes/blob/master/src/GeraNES/GeraNESEmu.h"
click node_cpu "https://github.com/gracioni/geranes/blob/master/src/GeraNES/CPU2A03.h"
click node_ppu "https://github.com/gracioni/geranes/blob/master/src/GeraNES/PPU.h"
click node_apu "https://github.com/gracioni/geranes/blob/master/src/GeraNES/APU/APU.h"
click node_cartridge "https://github.com/gracioni/geranes/blob/master/src/GeraNES/Cartridge.h"
click node_peripherals "https://github.com/gracioni/geranes/blob/master/src/GeraNES/IControllerPortDevice.h"
click node_state "https://github.com/gracioni/geranes/blob/master/src/GeraNES/Serialization.h"
click node_rom "https://github.com/gracioni/geranes/blob/master/src/GeraNES/RomFile.h"
click node_database "https://github.com/gracioni/geranes/blob/master/src/GeraNES/GameDatabase.h"
click node_mods "https://github.com/gracioni/geranes/blob/master/src/GeraNESApp/ModManager.cpp"
click node_rewind "https://github.com/gracioni/geranes/blob/master/src/GeraNES/Rewind.h"
click node_replay "https://github.com/gracioni/geranes/blob/master/src/GeraNESApp/ReplaySession.cpp"
click node_net_ui "https://github.com/gracioni/geranes/blob/master/src/GeraNESNetplay/NetplayWindowUI.cpp"
click node_net_runtime "https://github.com/gracioni/geranes/blob/master/src/GeraNESNetplay/GeraNESNetplayRuntimeDriver.cpp"
click node_net_coordinator "https://github.com/gracioni/geranes/blob/master/src/ConsoleNetplay/NetplayCoordinator.cpp"
click node_signaling "https://github.com/gracioni/geranes/blob/master/src/ConsoleNetplay/WebRtcSignalingClient.cpp"

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_app_entry,node_app_ui,node_input,node_libretro toneBlue
class node_emulator,node_cpu,node_ppu,node_apu,node_cartridge,node_peripherals toneAmber
class node_rom,node_database,node_mods toneMint
class node_state,node_rewind,node_replay toneRose
class node_net_ui,node_net_runtime,node_net_coordinator,node_signaling,node_user,node_peer,node_signaling_service toneIndigo
```

## Components

### App and Frontends

- [App Entry](https://github.com/gracioni/geranes/blob/master/src/main.cpp): `src/main.cpp`
- [Emulator UI](https://github.com/gracioni/geranes/blob/master/src/GeraNESApp/GeraNESApp.cpp): `src/GeraNESApp/GeraNESApp.cpp`
- [Input Handling](https://github.com/gracioni/geranes/blob/master/src/GeraNESApp/InputManager.cpp): `src/GeraNESApp/InputManager.cpp`
- [Libretro Core](https://github.com/gracioni/geranes/blob/master/src/libretro/GeraNESLibretro.cpp): `src/libretro/GeraNESLibretro.cpp`

### Emulation Core

- [Console Emulator](https://github.com/gracioni/geranes/blob/master/src/GeraNES/GeraNESEmu.h): `src/GeraNES/GeraNESEmu.h`
- [CPU](https://github.com/gracioni/geranes/blob/master/src/GeraNES/CPU2A03.h): `src/GeraNES/CPU2A03.h`
- [PPU](https://github.com/gracioni/geranes/blob/master/src/GeraNES/PPU.h): `src/GeraNES/PPU.h`
- [Audio Unit](https://github.com/gracioni/geranes/blob/master/src/GeraNES/APU/APU.h): `src/GeraNES/APU/APU.h`
- [Cartridge and Mappers](https://github.com/gracioni/geranes/blob/master/src/GeraNES/Cartridge.h): `src/GeraNES/Cartridge.h`
- [Controllers and Peripherals](https://github.com/gracioni/geranes/blob/master/src/GeraNES/IControllerPortDevice.h): `src/GeraNES/IControllerPortDevice.h`

### Content and Enhancements

- [ROM and Patch Loading](https://github.com/gracioni/geranes/blob/master/src/GeraNES/RomFile.h): `src/GeraNES/RomFile.h`
- [Game Database](https://github.com/gracioni/geranes/blob/master/src/GeraNES/GameDatabase.h): `src/GeraNES/GameDatabase.h`
- [Visual Mods](https://github.com/gracioni/geranes/blob/master/src/GeraNESApp/ModManager.cpp): `src/GeraNESApp/ModManager.cpp`

### Playback Features

- [State Serialization](https://github.com/gracioni/geranes/blob/master/src/GeraNES/Serialization.h): `src/GeraNES/Serialization.h`
- [Save States and Rewind](https://github.com/gracioni/geranes/blob/master/src/GeraNES/Rewind.h): `src/GeraNES/Rewind.h`
- [Replay](https://github.com/gracioni/geranes/blob/master/src/GeraNESApp/ReplaySession.cpp): `src/GeraNESApp/ReplaySession.cpp`

### Room Netplay

- [Netplay Room UI](https://github.com/gracioni/geranes/blob/master/src/GeraNESNetplay/NetplayWindowUI.cpp): `src/GeraNESNetplay/NetplayWindowUI.cpp`
- [Netplay Runtime](https://github.com/gracioni/geranes/blob/master/src/GeraNESNetplay/GeraNESNetplayRuntimeDriver.cpp): `src/GeraNESNetplay/GeraNESNetplayRuntimeDriver.cpp`
- [Session Coordination](https://github.com/gracioni/geranes/blob/master/src/ConsoleNetplay/NetplayCoordinator.cpp): `src/ConsoleNetplay/NetplayCoordinator.cpp`
- [WebRTC Signaling](https://github.com/gracioni/geranes/blob/master/src/ConsoleNetplay/WebRtcSignalingClient.cpp): `src/ConsoleNetplay/WebRtcSignalingClient.cpp`

### Other components

- **Player**
- **Other Players**
- **Signaling Service**

## Connections

- Player → App Entry: starts (evidence: `src/main.cpp`)
- App Entry → Emulator UI: creates and runs (evidence: `src/main.cpp`)
- Player → Libretro Core: loads core
- Emulator UI → Input Handling: collects controls
- Emulator UI → Console Emulator: drives emulation
- Libretro Core → Console Emulator: runs emulation (evidence: `src/libretro/GeraNESLibretro.cpp`)
- Console Emulator → CPU: uses (evidence: `src/GeraNES/GeraNESEmu.h`)
- Console Emulator → PPU: uses (evidence: `src/GeraNES/GeraNESEmu.h`)
- Console Emulator → Audio Unit: uses (evidence: `src/GeraNES/GeraNESEmu.h`)
- Console Emulator → Cartridge and Mappers: uses (evidence: `src/GeraNES/GeraNESEmu.h`)
- Console Emulator → Controllers and Peripherals: uses (evidence: `src/GeraNES/GeraNESEmu.h`)
- Console Emulator → State Serialization: serializes state (evidence: `src/GeraNES/GeraNESEmu.h`)
- Player → ROM and Patch Loading: opens game
- ROM and Patch Loading → Console Emulator: loads content
- Console Emulator → Game Database: consults metadata
- Player → Visual Mods: loads visual mods
- Visual Mods → PPU: enhances rendering
- Player → Save States and Rewind: saves or rewinds
- Player → Replay: plays replay
- Player → Netplay Room UI: joins room
- Netplay Room UI → Netplay Runtime: controls session
- Netplay Runtime → Session Coordination: coordinates play
- Session Coordination → WebRTC Signaling: signals peers
- WebRTC Signaling → Signaling Service: exchanges signaling
- Signaling Service → Other Players: connects players
