# agentm/project-m36 architecture

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

- Interactive diagram: https://gitdiagram.com/agentm/project-m36
- Repository: https://github.com/agentm/project-m36

## Overview

Project:M36 is a relational algebra database engine with TutorialD and SQL frontends, usable in-process or remotely. Its principal workflow is a user submitting a query through a frontend, the engine evaluating relational operations, and returning results; stateful updates are represented through transaction graphs and can be persisted. The README also documents remote access, CSV import/export, access control, notifications, merging, and Jupyter/WebSocket integrations. The sampled sources show the browser and Jupyter clients using WebSockets; most Haskell implementation links are not evidenced by excerpts, so those are left unconnected.

Main entry points: [`src/lib/ProjectM36/DatabaseContext.hs`](https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/DatabaseContext.hs) (Database context), [`src/lib/ProjectM36/RelationalExpression.hs`](https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/RelationalExpression.hs) (Relational expressions), [`src/bin/ProjectM36/Server/WebSocket.hs`](https://github.com/agentm/project-m36/blob/master/src/bin/ProjectM36/Server/WebSocket.hs) (WebSocket service), [`src/bin/TutorialD/tutd.hs`](https://github.com/agentm/project-m36/blob/master/src/bin/TutorialD/tutd.hs) (TutorialD CLI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Query Interfaces"]
  node_tutd["TutorialD CLI<br/>[tutd.hs]"]
  node_tutd_interp["TutorialD interpreter<br/>[Interpreter.hs]"]
  node_sql["SQLegacy CLI<br/>[sqlegacy.hs]"]
  node_sql_interp["SQL interpreter<br/>[Interpreter.hs]"]
  node_jupyter["Jupyter kernel"]
  node_csv["CSV exchange<br/>[CSV.hs]"]
end

subgraph group_engine["Relational Engine"]
  node_rel_expr["Relational expressions"]
  node_relation["Relations and tuples<br/>[Relation.hs]"]
  node_context["Database context<br/>[DatabaseContext.hs]"]
  node_functions["Database functions"]
end

subgraph group_state["Database State"]
  node_access["Access control<br/>[AccessControl.hs]"]
  node_notifications["Notifications<br/>[Notifications.hs]"]
  node_transactions["Transaction graph"]
  node_persistence[("Persistence<br/>[Persist.hs]")]
end

subgraph group_remote["Remote Access"]
  node_server["Database server<br/>[Server.hs]"]
  node_websocket["WebSocket service<br/>[WebSocket.hs]"]
  node_browser["Browser client"]
end

node_user(("Database user"))
node_jupyter_user(("Notebook user"))
node_remote_user(("Remote client"))

node_user -->|"uses TutorialD"| node_tutd
node_tutd -.->|"interprets"| node_tutd_interp
node_user -->|"uses SQLegacy"| node_sql
node_sql -.->|"interprets"| node_sql_interp
node_tutd_interp -.->|"evaluates expressions"| node_rel_expr
node_sql_interp -.->|"evaluates expressions"| node_rel_expr
node_rel_expr -.->|"produces relations"| node_relation
node_context -.->|"supports transactions"| node_transactions
node_transactions -.->|"persists state"| node_persistence
node_jupyter_user -->|"submits TutorialD"| node_jupyter
node_jupyter -->|"sends queries"| node_websocket
node_remote_user -->|"uses browser"| node_browser
node_browser -->|"sends requests"| node_websocket
node_websocket -.->|"serves database access"| node_server
node_csv -.->|"imports relations"| node_relation
node_user -->|"imports or exports CSV"| node_csv
node_context -.->|"enforces permissions"| node_access
node_context -.->|"supports notifications"| node_notifications
node_context -.->|"supports database functions"| node_functions

click node_tutd "https://github.com/agentm/project-m36/blob/master/src/bin/TutorialD/tutd.hs"
click node_tutd_interp "https://github.com/agentm/project-m36/blob/master/src/bin/TutorialD/Interpreter.hs"
click node_sql "https://github.com/agentm/project-m36/blob/master/src/bin/SQL/Interpreter/sqlegacy.hs"
click node_sql_interp "https://github.com/agentm/project-m36/blob/master/src/bin/SQL/Interpreter.hs"
click node_jupyter "https://github.com/agentm/project-m36/blob/master/jupyter/itutd/ITutorialDKernel.py"
click node_rel_expr "https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/RelationalExpression.hs"
click node_relation "https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/Relation.hs"
click node_context "https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/DatabaseContext.hs"
click node_functions "https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/DatabaseContextFunction.hs"
click node_access "https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/AccessControl.hs"
click node_notifications "https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/Notifications.hs"
click node_transactions "https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/TransactionGraph.hs"
click node_persistence "https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/Persist.hs"
click node_server "https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/Server.hs"
click node_websocket "https://github.com/agentm/project-m36/blob/master/src/bin/ProjectM36/Server/WebSocket.hs"
click node_browser "https://github.com/agentm/project-m36/blob/master/src/bin/ProjectM36/Server/WebSocket/websocket-client.js"
click node_csv "https://github.com/agentm/project-m36/blob/master/src/bin/TutorialD/Interpreter/Import/CSV.hs"

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_tutd,node_tutd_interp,node_sql,node_sql_interp,node_jupyter,node_csv,node_jupyter_user,node_remote_user toneBlue
class node_rel_expr,node_relation,node_context,node_functions,node_user toneAmber
class node_access,node_notifications,node_transactions,node_persistence toneMint
class node_server,node_websocket,node_browser toneRose
```

## Components

### Query Interfaces

- [TutorialD CLI](https://github.com/agentm/project-m36/blob/master/src/bin/TutorialD/tutd.hs): `src/bin/TutorialD/tutd.hs`
- [TutorialD interpreter](https://github.com/agentm/project-m36/blob/master/src/bin/TutorialD/Interpreter.hs): `src/bin/TutorialD/Interpreter.hs`
- [SQLegacy CLI](https://github.com/agentm/project-m36/blob/master/src/bin/SQL/Interpreter/sqlegacy.hs): `src/bin/SQL/Interpreter/sqlegacy.hs`
- [SQL interpreter](https://github.com/agentm/project-m36/blob/master/src/bin/SQL/Interpreter.hs): `src/bin/SQL/Interpreter.hs`
- [Jupyter kernel](https://github.com/agentm/project-m36/blob/master/jupyter/itutd/ITutorialDKernel.py): `jupyter/itutd/ITutorialDKernel.py`
- [CSV exchange](https://github.com/agentm/project-m36/blob/master/src/bin/TutorialD/Interpreter/Import/CSV.hs): `src/bin/TutorialD/Interpreter/Import/CSV.hs`

### Relational Engine

- [Relational expressions](https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/RelationalExpression.hs): `src/lib/ProjectM36/RelationalExpression.hs`
- [Relations and tuples](https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/Relation.hs): `src/lib/ProjectM36/Relation.hs`
- [Database context](https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/DatabaseContext.hs): `src/lib/ProjectM36/DatabaseContext.hs`
- [Database functions](https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/DatabaseContextFunction.hs): `src/lib/ProjectM36/DatabaseContextFunction.hs`

### Database State

- [Access control](https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/AccessControl.hs): `src/lib/ProjectM36/AccessControl.hs`
- [Notifications](https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/Notifications.hs): `src/lib/ProjectM36/Notifications.hs`
- [Transaction graph](https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/TransactionGraph.hs): `src/lib/ProjectM36/TransactionGraph.hs`
- [Persistence](https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/Persist.hs): `src/lib/ProjectM36/Persist.hs`

### Remote Access

- [Database server](https://github.com/agentm/project-m36/blob/master/src/lib/ProjectM36/Server.hs): `src/lib/ProjectM36/Server.hs`
- [WebSocket service](https://github.com/agentm/project-m36/blob/master/src/bin/ProjectM36/Server/WebSocket.hs): `src/bin/ProjectM36/Server/WebSocket.hs`
- [Browser client](https://github.com/agentm/project-m36/blob/master/src/bin/ProjectM36/Server/WebSocket/websocket-client.js): `src/bin/ProjectM36/Server/WebSocket/websocket-client.js`

### Other components

- **Database user**
- **Notebook user**
- **Remote client**

## Connections

- Database user → TutorialD CLI: uses TutorialD (evidence: `README.markdown`)
- TutorialD CLI → TutorialD interpreter: interprets
- Database user → SQLegacy CLI: uses SQLegacy (evidence: `README.markdown`)
- SQLegacy CLI → SQL interpreter: interprets
- TutorialD interpreter → Relational expressions: evaluates expressions
- SQL interpreter → Relational expressions: evaluates expressions
- Relational expressions → Relations and tuples: produces relations
- Database context → Transaction graph: supports transactions
- Transaction graph → Persistence: persists state
- Notebook user → Jupyter kernel: submits TutorialD (evidence: `README.markdown`)
- Jupyter kernel → WebSocket service: sends queries (evidence: `jupyter/itutd/ITutorialDKernel.py`)
- Remote client → Browser client: uses browser (evidence: `README.markdown`)
- Browser client → WebSocket service: sends requests
- WebSocket service → Database server: serves database access
- CSV exchange → Relations and tuples: imports relations
- Database user → CSV exchange: imports or exports CSV (evidence: `README.markdown`)
- Database context → Access control: enforces permissions
- Database context → Notifications: supports notifications
- Database context → Database functions: supports database functions
