# d-evil0per/programmer101 architecture

> Architecture diagram of the GitHub repository d-evil0per/programmer101, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/d-evil0per/programmer101
- Repository: https://github.com/d-evil0per/programmer101

## Overview

##### Project type and purpose
- From the file tree and the minimal README, this is a lightweight, single-host educational web app built with Streamlit. It serves as a “snippet library” and code runner for users to save, browse, and execute code examples.
- Key indicators:
- Presence of `.streamlit` folder and `app.py` at root → Streamlit UI
- `controller/codeRunner.py` → backend logic to run code snippets
- `snippets.db` → local SQLite database for persisting code snippets

##### File structure
- Top-level files and folders:
- `.devcontainer` → VS Code DevContainer config for consistent dev environment
- `.gitignore`, `requirements.txt` → standard versioning and dependency management
- `app.py` → Streamlit entry point
- `controller/` → business logic (code execution)
- `pages/` → Streamlit multipage views (`home.py`, `snippet-library.py`)
- `snippets.db` → embedded SQLite DB file
- No separate microservices or external APIs—this is a monolithic Python application.
- MVC-like pattern:
- Views = Streamlit pages
- Controller = codeRunner module
- Model = SQLite persistence

##### README for additional insights
- The README is minimal (“Programmer 101”) but implies an educational focus and a core feature set around code snippets and execution.

##### Main components and interactions
a. Components
- Streamlit UI
– app.py (root multipage router)
– pages/home.py (welcome/dashboard)
– pages/snippet-library.py (list, create, edit snippets)
- Controller
– controller/codeRunner.py (executes code and returns output)
- Database
– snippets.db (SQLite)
- Development Environment (optional)
– .devcontainer (Docker/VSCode dev sandbox)
b. Relationships and data flow
1. User (browser) ↔ HTTP over Streamlit
2. Streamlit UI calls controller functions
3. Controller queries/updates SQLite DB for snippet metadata
4. Controller runs code snippets in an isolated subprocess or sandbox
5. Output returned to Streamlit UI
c. Architectural patterns
– Monolithic MVC-inspired structure
– Local persistence with embedded database
– Single container development environment
d. Key technologies
– Python 3.x
– Streamlit framework
– SQLite for storage
– Docker (via .devcontainer) for dev environment

##### Detailed advice
- SQLite file clearly as the single source of truth for snippet persistence.
- If desired, annotate the DevContainer to show that developers open the code in a consistent Docker-based environment.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Development Environment Boundary
    subgraph "DevContainer" 
        direction TB
        DC["DevContainer"]:::env

        %% Presentation Layer
        subgraph "Presentation Layer (UI)" 
            direction TB
            AP["app.py"]:::frontend
            HS["pages/home.py"]:::frontend
            SL["pages/snippet-library.py"]:::frontend
            ST[".streamlit/config.toml"]:::frontend
        end

        %% Business Logic Layer
        subgraph "Controller (Business Logic)" 
            direction TB
            CR["controller/codeRunner.py"]:::logic
            PC["controller/__pycache__/"]:::logic
        end

        %% Data Layer
        DB["snippets.db"]:::data
    end

    %% External User
    User["User (Browser)"]:::external

    %% Relationships
    User -->|"HTTP (Streamlit UI)"| AP
    AP -->|"navigate()"| HS
    AP -->|"navigate()"| SL
    HS -->|"invoke execute_snippet()"| CR
    SL -->|"invoke CRUD operations"| CR
    CR -->|"SELECT/INSERT"| DB
    CR -->|"return output"| AP

    %% Click Events
    click AP "https://github.com/d-evil0per/programmer101/blob/main/app.py"
    click HS "https://github.com/d-evil0per/programmer101/blob/main/pages/home.py"
    click SL "https://github.com/d-evil0per/programmer101/blob/main/pages/snippet-library.py"
    click ST "https://github.com/d-evil0per/programmer101/blob/main/.streamlit/config.toml"
    click CR "https://github.com/d-evil0per/programmer101/blob/main/controller/codeRunner.py"
    click PC "https://github.com/d-evil0per/programmer101/tree/main/controller/__pycache__/"
    click DB "https://github.com/d-evil0per/programmer101/blob/main/snippets.db"
    click DC "https://github.com/d-evil0per/programmer101/tree/main/.devcontainer/"
    click DC "https://github.com/d-evil0per/programmer101/blob/main/.devcontainer/devcontainer.json"

    %% Styles
    classDef frontend fill:#D0E6FF,stroke:#0366D6,stroke-width:1px;
    classDef logic fill:#E6F4EA,stroke:#22863A,stroke-width:1px;
    classDef data fill:#FFE8D6,stroke:#D15704,stroke-width:1px,stroke-dasharray: 5 5;
    classDef external fill:#F0F0F0,stroke:#888888,stroke-width:1px,stroke-dasharray: 2 2;
    classDef env stroke:#AAAAAA,stroke-dasharray:4 2,fill:none;
```
