# ctrdecomp/librarymessagestudio architecture

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

- Interactive diagram: https://gitdiagram.com/ctrdecomp/librarymessagestudio
- Repository: https://github.com/ctrdecomp/librarymessagestudio

## Overview

LibMessageStudio is a small C library for parsing Nintendo MessageStudio binary formats and retrieving message text and project metadata. The main workflow is to provide binary data, initialize a message or project view, then query its blocks and contents; callers configure the memory callbacks used for allocations. The README also identifies MSBF message-flow binaries, but the sampled source does not show a flow-file API, so that capability is not mapped. Edges reflect sampled calls; project features are summarized at their implementation path.

Main entry points: [`src/msgfile.c`](https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/msgfile.c) (Message API), [`src/commonbin.c`](https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/commonbin.c) (Binary analyzer), [`src/projfile.c`](https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/projfile.c) (Project API), [`src/libms.c`](https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/libms.c) (Memory callbacks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_binary["Binary parsing"]
  node_binary_common["Binary structures<br/>[commonbin.h]"]
  node_binary_parser["Binary analyzer<br/>[commonbin.c]"]
  node_label_hash["Label hashing<br/>[commonbin.c]"]
  node_types["Shared types<br/>[types.h]"]
end

subgraph group_message["Message access"]
  node_message_api["Message API<br/>[msgfile.c]"]
  node_message_struct["Message view<br/>[msgfile.h]"]
end

subgraph group_project["Project metadata"]
  node_project_api["Project API<br/>[projfile.c]"]
  node_project_struct["Project view<br/>[projfile.h]"]
end

subgraph group_memory["Memory utilities"]
  node_memory_api["Memory callbacks<br/>[libms.c]"]
  node_memory_header["Memory interface<br/>[libms.h]"]
end

node_caller(("Library caller"))
node_binary_data["Binary data"]

node_caller -->|"initializes"| node_message_api
node_caller -->|"initializes"| node_project_api
node_caller -->|"provides"| node_binary_data
node_caller -->|"sets callbacks"| node_memory_api
node_message_api -->|"reads"| node_binary_data
node_project_api -->|"reads"| node_binary_data
node_message_api -->|"analyzes binary"| node_binary_parser
node_project_api -->|"analyzes binary"| node_binary_parser
node_message_api -->|"searches blocks"| node_binary_parser
node_project_api -->|"searches blocks"| node_binary_parser
node_binary_parser -->|"allocates blocks"| node_memory_api
node_binary_parser -->|"compares names"| node_memory_api
node_message_api -->|"hashes labels"| node_label_hash
node_message_api -->|"compares labels"| node_binary_parser
node_message_api -->|"allocates and frees"| node_memory_api
node_project_api -->|"allocates and frees"| node_memory_api
node_message_api -->|"uses view"| node_message_struct
node_project_api -->|"uses view"| node_project_struct
node_binary_parser -->|"populates structures"| node_binary_common
node_message_api -->|"reads blocks"| node_binary_common
node_project_api -->|"reads blocks"| node_binary_common
node_memory_api -->|"implements"| node_memory_header
node_binary_common -->|"uses types"| node_types

click node_message_api "https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/msgfile.c"
click node_message_struct "https://github.com/ctrdecomp/librarymessagestudio/blob/main/include/LMS/msgfile.h"
click node_project_api "https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/projfile.c"
click node_project_struct "https://github.com/ctrdecomp/librarymessagestudio/blob/main/include/LMS/projfile.h"
click node_binary_common "https://github.com/ctrdecomp/librarymessagestudio/blob/main/include/LMS/commonbin.h"
click node_binary_parser "https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/commonbin.c"
click node_label_hash "https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/commonbin.c"
click node_memory_api "https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/libms.c"
click node_memory_header "https://github.com/ctrdecomp/librarymessagestudio/blob/main/include/LMS/libms.h"
click node_types "https://github.com/ctrdecomp/librarymessagestudio/blob/main/include/LMS/types.h"

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_binary_common,node_binary_parser,node_label_hash,node_types toneBlue
class node_message_api,node_message_struct toneAmber
class node_project_api,node_project_struct toneMint
class node_memory_api,node_memory_header toneRose
class node_caller,node_binary_data toneIndigo
```

## Components

### Binary parsing

- [Binary structures](https://github.com/ctrdecomp/librarymessagestudio/blob/main/include/LMS/commonbin.h): `include/LMS/commonbin.h`
- [Binary analyzer](https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/commonbin.c): `src/commonbin.c`
- [Label hashing](https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/commonbin.c): `src/commonbin.c`
- [Shared types](https://github.com/ctrdecomp/librarymessagestudio/blob/main/include/LMS/types.h): `include/LMS/types.h`

### Message access

- [Message API](https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/msgfile.c): `src/msgfile.c`
- [Message view](https://github.com/ctrdecomp/librarymessagestudio/blob/main/include/LMS/msgfile.h): `include/LMS/msgfile.h`

### Project metadata

- [Project API](https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/projfile.c): `src/projfile.c`
- [Project view](https://github.com/ctrdecomp/librarymessagestudio/blob/main/include/LMS/projfile.h): `include/LMS/projfile.h`

### Memory utilities

- [Memory callbacks](https://github.com/ctrdecomp/librarymessagestudio/blob/main/src/libms.c): `src/libms.c`
- [Memory interface](https://github.com/ctrdecomp/librarymessagestudio/blob/main/include/LMS/libms.h): `include/LMS/libms.h`

### Other components

- **Library caller**
- **Binary data**

## Connections

- Library caller → Message API: initializes
- Library caller → Project API: initializes
- Library caller → Binary data: provides
- Library caller → Memory callbacks: sets callbacks
- Message API → Binary data: reads
- Project API → Binary data: reads
- Message API → Binary analyzer: analyzes binary
- Project API → Binary analyzer: analyzes binary
- Message API → Binary analyzer: searches blocks
- Project API → Binary analyzer: searches blocks
- Binary analyzer → Memory callbacks: allocates blocks
- Binary analyzer → Memory callbacks: compares names
- Message API → Label hashing: hashes labels
- Message API → Binary analyzer: compares labels
- Message API → Memory callbacks: allocates and frees
- Project API → Memory callbacks: allocates and frees
- Message API → Message view: uses view
- Project API → Project view: uses view
- Binary analyzer → Binary structures: populates structures
- Message API → Binary structures: reads blocks
- Project API → Binary structures: reads blocks
- Memory callbacks → Memory interface: implements
- Binary structures → Shared types: uses types
