# mmkathurima/rims architecture

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

- Interactive diagram: https://gitdiagram.com/mmkathurima/rims
- Repository: https://github.com/mmkathurima/rims

## Overview

##### Project Type and Purpose
- This is a desktop simulation suite for microcontrollers (the “Riverside-Irvine Microcontroller Simulator”), built on .NET 6.0 using C# and WinForms.
- It consists of three distinct executables under one Visual Studio solution (RIMS.sln):
– RIMS.exe: the core microcontroller simulator (AVR/ARM emulation, I/O peripherals, debugger)
– RIBS.exe: a State-Machine (SM) builder/editor (generates .sm files)
– RITS.exe: a timestamp/trace tool (auxiliary utility)

##### File Structure
- Top-level solution (RIMS.sln), three project folders (RIMS, RIBS, RITS) plus a shared “CSUST.Data” library under RIMS.
- Each project contains:
– Properties (AssemblyInfo, Resources, Settings)
– .resx files (localization, built-in samples)
– Program.cs + UI Forms (.cs and .Designer.cs)
– Domain code (RIMS_V2/*, RIBS_V3/*, RITS/*)
- Shared library (CSUST.Data) provides custom controls (TSmartProgressBar).
- Configuration files (app.config) and multimedia resources (song*.wav, COM dependencies).

##### README for Architectural Clues
- Clearly separates “Building” vs. “Running” dependencies.
- Mentions:
– Core simulation engine (CPU decode, peripheral models)
– GUI (WinForms)
– COM interop with Windows Media Player for audio playback
– File-based project format: .sm, .c, .asm sample files
- No external web services or databases.

##### Main Components & Their Interactions
a. Executable Boundary (three .exe’s)
– RIMS.exe (Simulator UI + Engine)
– RIBS.exe (State-Machine Editor UI + Generator)
– RITS.exe (Timestamp/Trace Utility)
b. Shared Library (CSUST.Data)
– Custom WinForms controls (progress bars, designers)
c. Simulation Core (inside RIMS_V2 namespace)
– CPU emulator (VM.cs, VMInterface.cs)
– Peripheral models (TimerInterface, UARTInterface, Speaker, LEDs, 7-seg display)
– Debug engine (breakpoints, step-through)
d. State-Machine Generator/Core (RIBS_V3 namespace)
– Graph, Node, Edge models
– SMSerializer for reading/writing .sm files
– UI forms for transitions (TransitionIfElseForm, ForLoopForm)
e. File I/O Layer
– Project.cs and Samples.cs for loading/saving projects & sample code
– Resources (.sm, .c, .asm) embedded in .resx
f. External Services
– COM Interop: Windows Media Player Legacy for audio playback in RIMS
– File system for reading/writing projects & samples

##### Architectural Patterns and Design Principles
- Layered Approach:
– Presentation (WinForms UI)
– Application Logic (controllers, event handlers)
– Domain Model (simulation core, SM core)
– Infrastructure (file I/O, COM interop)
- MVC-style separation (UI forms call into engine classes, not vice versa).
- Plugin-ish structure: each tool (RIMS/RIBS/RITS) is a standalone module.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% RIMS Executable
    subgraph "RIMS.exe (Simulator)" 
        direction TB
        RIMS_UI["UI Layer\n(WinForms Forms & Controls)"]:::rimsexec
        RIMS_Core["Simulation Core\n(VM, Peripheral Interfaces)"]:::rimsexec
        RIMS_IO["File I/O Layer\n(Project & Samples)"]:::rimsexec
        RIMS_COM["COM Interop\n(Windows Media Player)"]:::rimsexec
    end
    RIMSExe["RIMS.exe"]:::rimsexec

    %% RIBS Executable
    subgraph "RIBS.exe (State-Machine Editor)"
        direction TB
        RIBS_UI["UI Layer\n(Forms for SM Editor)"]:::ribsexec
        RIBS_Core["SM Core\n(Graph, Node, Edge, Generator)"]:::ribsexec
        RIBS_IO["File I/O Layer\n(Project & Samples)"]:::ribsexec
    end
    RIBSExe["RIBS.exe"]:::ribsexec

    %% RITS Executable
    subgraph "RITS.exe (Timestamp/Trace Utility)"
        direction TB
        RITS_UI["UI Layer\n(Form1)"]:::ritsexec
        RITS_Model["Trace/Time Model\n(Timestamp)"]:::ritsexec
        RITS_Support["Support Code\n(Feedback, Validation)"]:::ritsexec
    end
    RITSExe["RITS.exe"]:::ritsexec

    %% Shared Library
    CSUST["CSUST.Data\n(Custom Controls)"]:::library

    %% External & FS
    FS["File System\n(Project & Samples)"]:::fs
    WMP["Windows Media Player\n(COM Component)"]:::com

    %% Dependencies and Flows
    RIMSExe -->|depends on| CSUST
    RIBSExe -->|depends on| CSUST
    RITSExe -->|depends on| CSUST

    RIMSExe --> RIMS_UI
    RIMS_UI -->|calls| RIMS_Core
    RIMS_Core -->|load/save| RIMS_IO
    RIMS_Core -->|audio playback| RIMS_COM

    RIBSExe --> RIBS_UI
    RIBS_UI -->|calls| RIBS_Core
    RIBS_Core -->|read/write| RIBS_IO

    RITSExe --> RITS_UI
    RITS_UI -->|calls| RITS_Model
    RITS_Model -->|uses| RITS_Support

    RIMS_IO --> FS
    RIBS_IO --> FS
    RITS_Support --> FS

    RIMS_COM --> WMP

    %% Click Events RIMS
    click RIMSExe "https://github.com/mmkathurima/rims/blob/main/RIMS/RIMS.csproj"
    click RIMS_UI "https://github.com/mmkathurima/rims/blob/main/RIMS/RIMS_V2/MainForm.cs"
    click RIMS_Core "https://github.com/mmkathurima/rims/blob/main/RIMS/RIMS_V2/VM.cs"
    click RIMS_IO "https://github.com/mmkathurima/rims/blob/main/RIMS/RIMS_V2/Samples.cs"
    click RIMS_COM "https://github.com/mmkathurima/rims/blob/main/RIMS/app.config"

    %% Click Events RIBS
    click RIBSExe "https://github.com/mmkathurima/rims/blob/main/RIBS/RIBS.csproj"
    click RIBS_UI "https://github.com/mmkathurima/rims/blob/main/RIBS/RIBS_V3/TransitionIfElseForm.cs"
    click RIBS_Core "https://github.com/mmkathurima/rims/blob/main/RIBS/RIBS_V3/Graph.cs"
    click RIBS_IO "https://github.com/mmkathurima/rims/blob/main/RIBS/RIBS_V3/Project.cs"

    %% Click Events RITS
    click RITSExe "https://github.com/mmkathurima/rims/blob/main/RITS/RITS.csproj"
    click RITS_UI "https://github.com/mmkathurima/rims/blob/main/RITS/RITS/Program.cs"
    click RITS_Model "https://github.com/mmkathurima/rims/blob/main/RITS/RITS/Timestamp.cs"
    click RITS_Support "https://github.com/mmkathurima/rims/blob/main/RITS/RITS/Feedback.cs"

    %% Click Event Shared Library
    click CSUST "https://github.com/mmkathurima/rims/blob/main/RIMS/CSUST.Data/TSmartProgressBar.cs"

    %% Styles
    classDef rimsexec fill:#D0E8FF,stroke:#0366d6,color:#000
    classDef ribsexec fill:#E0FFE0,stroke:#28a745,color:#000
    classDef ritsexec fill:#FFF4D0,stroke:#d97706,color:#000
    classDef library fill:#F0F0F0,stroke:#6f42c1,color:#000
    classDef fs fill:#FFF0F0,stroke:#d73a49,color:#000
    classDef com fill:#F0FFF0,stroke:#32a852,color:#000
```
