# smkdopai/pypharmide architecture

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

- Interactive diagram: https://gitdiagram.com/smkdopai/pypharmide
- Repository: https://github.com/smkdopai/pypharmide

## Overview

PyPharm is a cross-platform Python learning editor for pharmacy students. The main workflow is editing a program, sending it to a background Pyodide worker, and viewing its output, errors, plots, variables, or debugger trace; the Files panel also supports program inputs and created files. The graph preserves documented editor, completion, examples, package, and offline capabilities. Some UI-to-worker setup and several feature implementations are in omitted portions of src/app.js, so those links are based on README documentation rather than inspected calls.

Main entry points: [`src/worker.js`](https://github.com/smkdopai/pypharmide/blob/main/src/worker.js) (Python worker), [`src/app.js`](https://github.com/smkdopai/pypharmide/blob/main/src/app.js) (Code editor), [`electron/main.js`](https://github.com/smkdopai/pypharmide/blob/main/electron/main.js) (Desktop shell), [`src/examples.js`](https://github.com/smkdopai/pypharmide/blob/main/src/examples.js) (Example programs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Editor and interface"]
  node_editor["Code editor<br/>[app.js]"]
  node_settings["Editor settings<br/>[app.js]"]
  node_file_panel["Files panel<br/>[app.js]"]
  node_output["Output and plots<br/>[app.js]"]
  node_variables["Variable viewer<br/>[app.js]"]
  node_debugger["Step debugger<br/>[app.js]"]
  node_completion["Code assistance<br/>[app.js]"]
end

subgraph group_execution["Python execution"]
  node_worker["Python worker<br/>[worker.js]"]
  node_pyodide["Pyodide runtime"]
  node_packages["Python packages"]
end

subgraph group_learning["Learning features"]
  node_examples["Example programs<br/>[examples.js]"]
end

subgraph group_platform["Offline platform"]
  node_browser_storage[("Browser storage")]
  node_service_worker["Offline caching<br/>[sw.js]"]
  node_desktop_shell["Desktop shell<br/>[main.js]"]
end

node_student(("Student"))
node_browser(("Browser or app"))

node_student -->|"writes code"| node_editor
node_editor -->|"runs code"| node_worker
node_worker -->|"executes Python"| node_pyodide
node_worker -->|"sends results"| node_output
node_worker -->|"returns variables"| node_variables
node_worker -->|"returns trace"| node_debugger
node_editor -->|"requests assistance"| node_completion
node_completion -->|"checks and completes"| node_worker
node_worker -->|"loads packages"| node_packages
node_file_panel -->|"provides program files"| node_worker
node_worker -->|"returns created files"| node_file_panel
node_editor -->|"shows examples"| node_examples
node_settings -->|"persists settings"| node_browser_storage
node_file_panel -.->|"persists files"| node_browser_storage
node_browser -->|"caches app"| node_service_worker
node_browser -->|"opens app"| node_editor
node_desktop_shell -->|"serves app"| node_browser

click node_editor "https://github.com/smkdopai/pypharmide/blob/main/src/app.js"
click node_settings "https://github.com/smkdopai/pypharmide/blob/main/src/app.js"
click node_file_panel "https://github.com/smkdopai/pypharmide/blob/main/src/app.js"
click node_output "https://github.com/smkdopai/pypharmide/blob/main/src/app.js"
click node_variables "https://github.com/smkdopai/pypharmide/blob/main/src/app.js"
click node_debugger "https://github.com/smkdopai/pypharmide/blob/main/src/app.js"
click node_completion "https://github.com/smkdopai/pypharmide/blob/main/src/app.js"
click node_examples "https://github.com/smkdopai/pypharmide/blob/main/src/examples.js"
click node_worker "https://github.com/smkdopai/pypharmide/blob/main/src/worker.js"
click node_service_worker "https://github.com/smkdopai/pypharmide/blob/main/assets/sw.js"
click node_desktop_shell "https://github.com/smkdopai/pypharmide/blob/main/electron/main.js"

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_editor,node_settings,node_file_panel,node_output,node_variables,node_debugger,node_completion,node_browser toneBlue
class node_worker,node_pyodide,node_packages toneAmber
class node_examples toneMint
class node_browser_storage,node_service_worker,node_desktop_shell toneRose
class node_student toneIndigo
```

## Components

### Editor and interface

- [Code editor](https://github.com/smkdopai/pypharmide/blob/main/src/app.js): `src/app.js`
- [Editor settings](https://github.com/smkdopai/pypharmide/blob/main/src/app.js): `src/app.js`
- [Files panel](https://github.com/smkdopai/pypharmide/blob/main/src/app.js): `src/app.js`
- [Output and plots](https://github.com/smkdopai/pypharmide/blob/main/src/app.js): `src/app.js`
- [Variable viewer](https://github.com/smkdopai/pypharmide/blob/main/src/app.js): `src/app.js`
- [Step debugger](https://github.com/smkdopai/pypharmide/blob/main/src/app.js): `src/app.js`
- [Code assistance](https://github.com/smkdopai/pypharmide/blob/main/src/app.js): `src/app.js`

### Python execution

- [Python worker](https://github.com/smkdopai/pypharmide/blob/main/src/worker.js): `src/worker.js`
- **Pyodide runtime**
- **Python packages**

### Learning features

- [Example programs](https://github.com/smkdopai/pypharmide/blob/main/src/examples.js): `src/examples.js`

### Offline platform

- **Browser storage**
- [Offline caching](https://github.com/smkdopai/pypharmide/blob/main/assets/sw.js): `assets/sw.js`
- [Desktop shell](https://github.com/smkdopai/pypharmide/blob/main/electron/main.js): `electron/main.js`

### Other components

- **Student**
- **Browser or app**

## Connections

- Student → Code editor: writes code (evidence: `README.md`)
- Code editor → Python worker: runs code (evidence: `README.md`)
- Python worker → Pyodide runtime: executes Python (evidence: `README.md`)
- Python worker → Output and plots: sends results (evidence: `src/worker.js`)
- Python worker → Variable viewer: returns variables (evidence: `src/worker.js`)
- Python worker → Step debugger: returns trace (evidence: `src/worker.js`)
- Code editor → Code assistance: requests assistance (evidence: `README.md`)
- Code assistance → Python worker: checks and completes (evidence: `src/worker.js`)
- Python worker → Python packages: loads packages (evidence: `src/worker.js`)
- Files panel → Python worker: provides program files (evidence: `README.md`)
- Python worker → Files panel: returns created files (evidence: `src/worker.js`)
- Code editor → Example programs: shows examples (evidence: `README.md`)
- Editor settings → Browser storage: persists settings (evidence: `src/app.js`)
- Files panel → Browser storage: persists files
- Browser or app → Offline caching: caches app (evidence: `README.md`)
- Browser or app → Code editor: opens app (evidence: `README.md`)
- Desktop shell → Browser or app: serves app (evidence: `electron/main.js`)
