# enrymarch10/ds-lab-snippets architecture

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

- Interactive diagram: https://gitdiagram.com/enrymarch10/ds-lab-snippets
- Repository: https://github.com/enrymarch10/ds-lab-snippets

## Overview

This repository is a set of runnable Distributed Systems course examples, selected by lab and example through a small command-line launcher. Its distinct learning areas are game-loop design, UDP communication, TCP communication, and user-database RPC. Lab 4 shows the end-to-end RPC path from CLI through a client stub and presentation encoding to a TCP server and in-memory user service, alongside authentication and token concepts. The graph preserves documented labs even where implementation excerpts are limited; their internal wiring is not inferred.

Main entry points: [`snippets/lab3/__init__.py`](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab3/__init__.py) (TCP transport), [`snippets/__init__.py`](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/__init__.py) (Example discovery), [`snippets/lab4/example3_rpc_client.py`](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/example3_rpc_client.py) (RPC client stub), [`snippets/lab2/__init__.py`](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab2/__init__.py) (UDP utilities)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_launcher["Example launcher"]
  node_launcher["Lab selector<br/>[__main__.py]"]
  node_discovery["Example discovery<br/>[__init__.py]"]
end

subgraph group_games["Game loop"]
  node_game_loop["Game-loop examples"]
  node_game_object["Game object"]
  node_game_controller["Input controller"]
  node_game_view["Game view<br/>[example4_view.py]"]
  node_clean_game["Clean game loop"]
end

subgraph group_udp["UDP examples"]
  node_udp_helpers["UDP utilities<br/>[__init__.py]"]
  node_udp_chat["UDP chat examples"]
  node_udp_stream["UDP streamer"]
  node_udp_graceful["Graceful UDP chat"]
end

subgraph group_tcp["TCP examples"]
  node_tcp_transport["TCP transport<br/>[__init__.py]"]
  node_tcp_echo["TCP echo examples"]
  node_tcp_chat["TCP chat"]
  node_tcp_group["Group chat exercise"]
end

subgraph group_rpc["RPC and users"]
  node_user_models["User data models<br/>[__init__.py]"]
  node_user_database[("In-memory user store<br/>[impl.py]")]
  node_user_example["User service example<br/>[example0_users.py]"]
  node_presentation["RPC presentation"]
  node_rpc_server["RPC server"]
  node_rpc_stub["RPC client stub"]
  node_rpc_cli["RPC command line"]
end

node_user(("Course user"))

node_user -->|"selects example"| node_launcher
node_launcher -->|"finds examples"| node_discovery
node_discovery -.->|"discovers"| node_game_loop
node_discovery -.->|"discovers"| node_udp_chat
node_discovery -.->|"discovers"| node_tcp_echo
node_discovery -.->|"discovers"| node_rpc_cli
node_clean_game -->|"uses"| node_game_object
node_clean_game -->|"uses"| node_game_controller
node_clean_game -->|"uses"| node_game_view
node_udp_chat -->|"imports"| node_udp_helpers
node_udp_stream -->|"imports"| node_udp_helpers
node_udp_graceful -->|"imports"| node_udp_helpers
node_tcp_transport -->|"reuses"| node_udp_helpers
node_tcp_echo -->|"uses"| node_tcp_transport
node_tcp_chat -->|"uses"| node_tcp_transport
node_tcp_group -->|"uses"| node_tcp_transport
node_user_example -->|"creates"| node_user_database
node_user_database -->|"implements"| node_user_models
node_user_example -->|"uses"| node_user_models
node_rpc_stub -->|"serializes requests"| node_presentation
node_rpc_stub -->|"sends RPC"| node_tcp_transport
node_rpc_stub -->|"implements interface"| node_user_models
node_rpc_cli -->|"calls methods"| node_rpc_stub
node_rpc_server -->|"uses"| node_tcp_transport
node_rpc_server -->|"uses"| node_presentation
node_rpc_server -->|"uses"| node_user_database

click node_launcher "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/__main__.py"
click node_discovery "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/__init__.py"
click node_game_loop "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab1/example1_game_loop.py"
click node_game_object "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab1/example2_game_object.py"
click node_game_controller "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab1/example3_controller.py"
click node_game_view "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab1/example4_view.py"
click node_clean_game "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab1/example5_game_loop_cleancode.py"
click node_udp_helpers "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab2/__init__.py"
click node_udp_chat "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab2/example2_udp_chat.py"
click node_udp_stream "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab2/example3_udp_streamer.py"
click node_udp_graceful "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab2/example4_udp_chat_graceful.py"
click node_tcp_transport "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab3/__init__.py"
click node_tcp_echo "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab3/example2_tcp_echo.py"
click node_tcp_chat "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab3/example3_tcp_chat.py"
click node_tcp_group "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab3/exercise_tcp_group_chat.py"
click node_user_models "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/users/__init__.py"
click node_user_database "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/users/impl.py"
click node_user_example "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/example0_users.py"
click node_presentation "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/example1_presentation.py"
click node_rpc_server "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/example2_rpc_server.py"
click node_rpc_stub "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/example3_rpc_client.py"
click node_rpc_cli "https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/example4_rpc_client_cli.py"

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_launcher,node_discovery,node_user toneBlue
class node_game_loop,node_game_object,node_game_controller,node_game_view,node_clean_game toneAmber
class node_udp_helpers,node_udp_chat,node_udp_stream,node_udp_graceful toneMint
class node_tcp_transport,node_tcp_echo,node_tcp_chat,node_tcp_group toneRose
class node_user_models,node_user_database,node_user_example,node_presentation,node_rpc_server,node_rpc_stub,node_rpc_cli toneIndigo
```

## Components

### Example launcher

- [Lab selector](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/__main__.py): `snippets/__main__.py`
- [Example discovery](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/__init__.py): `snippets/__init__.py`

### Game loop

- [Game-loop examples](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab1/example1_game_loop.py): `snippets/lab1/example1_game_loop.py`
- [Game object](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab1/example2_game_object.py): `snippets/lab1/example2_game_object.py`
- [Input controller](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab1/example3_controller.py): `snippets/lab1/example3_controller.py`
- [Game view](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab1/example4_view.py): `snippets/lab1/example4_view.py`
- [Clean game loop](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab1/example5_game_loop_cleancode.py): `snippets/lab1/example5_game_loop_cleancode.py`

### UDP examples

- [UDP utilities](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab2/__init__.py): `snippets/lab2/__init__.py`
- [UDP chat examples](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab2/example2_udp_chat.py): `snippets/lab2/example2_udp_chat.py`
- [UDP streamer](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab2/example3_udp_streamer.py): `snippets/lab2/example3_udp_streamer.py`
- [Graceful UDP chat](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab2/example4_udp_chat_graceful.py): `snippets/lab2/example4_udp_chat_graceful.py`

### TCP examples

- [TCP transport](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab3/__init__.py): `snippets/lab3/__init__.py`
- [TCP echo examples](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab3/example2_tcp_echo.py): `snippets/lab3/example2_tcp_echo.py`
- [TCP chat](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab3/example3_tcp_chat.py): `snippets/lab3/example3_tcp_chat.py`
- [Group chat exercise](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab3/exercise_tcp_group_chat.py): `snippets/lab3/exercise_tcp_group_chat.py`

### RPC and users

- [User data models](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/users/__init__.py): `snippets/lab4/users/__init__.py`
- [In-memory user store](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/users/impl.py): `snippets/lab4/users/impl.py`
- [User service example](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/example0_users.py): `snippets/lab4/example0_users.py`
- [RPC presentation](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/example1_presentation.py): `snippets/lab4/example1_presentation.py`
- [RPC server](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/example2_rpc_server.py): `snippets/lab4/example2_rpc_server.py`
- [RPC client stub](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/example3_rpc_client.py): `snippets/lab4/example3_rpc_client.py`
- [RPC command line](https://github.com/enrymarch10/ds-lab-snippets/blob/master/snippets/lab4/example4_rpc_client_cli.py): `snippets/lab4/example4_rpc_client_cli.py`

### Other components

- **Course user**

## Connections

- Course user → Lab selector: selects example (evidence: `README.md`)
- Lab selector → Example discovery: finds examples (evidence: `snippets/__main__.py`)
- Example discovery → Game-loop examples: discovers
- Example discovery → UDP chat examples: discovers
- Example discovery → TCP echo examples: discovers
- Example discovery → RPC command line: discovers
- Clean game loop → Game object: uses (evidence: `snippets/lab1/example5_game_loop_cleancode.py`)
- Clean game loop → Input controller: uses (evidence: `snippets/lab1/example5_game_loop_cleancode.py`)
- Clean game loop → Game view: uses (evidence: `snippets/lab1/example5_game_loop_cleancode.py`)
- UDP chat examples → UDP utilities: imports (evidence: `snippets/lab2/example2_udp_chat.py`)
- UDP streamer → UDP utilities: imports (evidence: `snippets/lab2/example3_udp_streamer.py`)
- Graceful UDP chat → UDP utilities: imports (evidence: `snippets/lab2/example4_udp_chat_graceful.py`)
- TCP transport → UDP utilities: reuses (evidence: `snippets/lab3/__init__.py`)
- TCP echo examples → TCP transport: uses (evidence: `snippets/lab3/example2_tcp_echo.py`)
- TCP chat → TCP transport: uses (evidence: `snippets/lab3/example3_tcp_chat.py`)
- Group chat exercise → TCP transport: uses (evidence: `snippets/lab3/exercise_tcp_group_chat.py`)
- User service example → In-memory user store: creates (evidence: `snippets/lab4/example0_users.py`)
- In-memory user store → User data models: implements (evidence: `snippets/lab4/users/impl.py`)
- User service example → User data models: uses (evidence: `snippets/lab4/example0_users.py`)
- RPC client stub → RPC presentation: serializes requests (evidence: `snippets/lab4/example3_rpc_client.py`)
- RPC client stub → TCP transport: sends RPC (evidence: `snippets/lab4/example3_rpc_client.py`)
- RPC client stub → User data models: implements interface (evidence: `snippets/lab4/example3_rpc_client.py`)
- RPC command line → RPC client stub: calls methods (evidence: `snippets/lab4/example4_rpc_client_cli.py`)
- RPC server → TCP transport: uses (evidence: `snippets/lab4/example2_rpc_server.py`)
- RPC server → RPC presentation: uses (evidence: `snippets/lab4/example2_rpc_server.py`)
- RPC server → In-memory user store: uses (evidence: `snippets/lab4/example2_rpc_server.py`)
