# scnova/pico_chat architecture

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

- Interactive diagram: https://gitdiagram.com/scnova/pico_chat
- Repository: https://github.com/scnova/pico_chat

## Overview

pico_chat is a small MicroPython serial-chat program. The main loop reads user input and sends messages over UART; a background worker reads incoming messages, prints them, and sends a timestamped keepalive after 10 seconds without a send. Both send paths use a lock to serialize UART writes. The single source file shows the runtime behavior; no other product subsystems are documented.

Main entry points: [`Lab4.py`](https://github.com/scnova/pico_chat/blob/main/Lab4.py) (Receive worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_user(("User"))
node_main_loop["Chat loop<br/>[Lab4.py]"]
node_sender["Message sender<br/>[Lab4.py]"]
node_worker["Receive worker<br/>[Lab4.py]"]
node_uart["UART link<br/>[Lab4.py]"]
node_remote_pico(("Other Pico"))
node_console(("Console"))

node_user -->|"enters input"| node_main_loop
node_main_loop -->|"calls"| node_sender
node_main_loop -->|"starts thread"| node_worker
node_sender -->|"writes message"| node_uart
node_remote_pico -.->|"sends data"| node_uart
node_uart -->|"provides received data"| node_worker
node_worker -->|"calls keepalive send"| node_sender
node_worker -->|"prints messages"| node_console

click node_main_loop "https://github.com/scnova/pico_chat/blob/main/Lab4.py"
click node_sender "https://github.com/scnova/pico_chat/blob/main/Lab4.py"
click node_worker "https://github.com/scnova/pico_chat/blob/main/Lab4.py"
click node_uart "https://github.com/scnova/pico_chat/blob/main/Lab4.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_user toneBlue
class node_main_loop,node_sender,node_uart toneTeal
class node_worker toneRose
class node_remote_pico,node_console toneIndigo
```

## Components

### Other components

- **User**
- [Chat loop](https://github.com/scnova/pico_chat/blob/main/Lab4.py): `Lab4.py`
- [Message sender](https://github.com/scnova/pico_chat/blob/main/Lab4.py): `Lab4.py`
- [Receive worker](https://github.com/scnova/pico_chat/blob/main/Lab4.py): `Lab4.py`
- [UART link](https://github.com/scnova/pico_chat/blob/main/Lab4.py): `Lab4.py`
- **Other Pico**
- **Console**

## Connections

- User → Chat loop: enters input (evidence: `Lab4.py`)
- Chat loop → Message sender: calls (evidence: `Lab4.py`)
- Chat loop → Receive worker: starts thread (evidence: `Lab4.py`)
- Message sender → UART link: writes message (evidence: `Lab4.py`)
- Other Pico → UART link: sends data
- UART link → Receive worker: provides received data (evidence: `Lab4.py`)
- Receive worker → Message sender: calls keepalive send (evidence: `Lab4.py`)
- Receive worker → Console: prints messages (evidence: `Lab4.py`)
