# syildizz/pymaker architecture

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

- Interactive diagram: https://gitdiagram.com/syildizz/pymaker
- Repository: https://github.com/syildizz/pymaker

## Overview

##### Project type and purpose
- PyMaker is a full-stack web application for generating Python code using AI.
- The frontend is a static HTML/JS single-page served by FastAPI.
- The backend is a FastAPI server (written in Python) that orchestrates requests to an Ollama code-generation engine.
- It can be deployed via Docker Compose on a single host or via Kubernetes using Helm charts for production/horizontal scale.

##### File structure
├─ .gitignore, LICENSE, README.md  (global metadata)
├─ github_asset/ (screenshots)
├─ pymaker-web/ (webserver code & Dockerfile)
│   ├─ Dockerfile, .dockerignore
│   ├─ requirements.txt
│   └─ src/
│       ├─ index.html, static/js/*.js (UI)
│       ├─ main.py (FastAPI app entrypoint)
│       ├─ config.py, model.py, ollama.py (backend logic and Ollama integration)
└─ pymaker-deploy/ (deployment artifacts)
├─ compose.yaml (Docker Compose)
├─ helm/
│   ├─ pymaker/ (umbrella chart with two subcharts: ollama, pymaker-web)
│   └─ pinger/ (test-pod chart for network/health checks)
└─ config/ (shared config files and prompt_prefix)

##### README for additional insights
- Confirms FastAPI + Ollama llama3.2 model.
- Notes two deployment modes: Docker Compose vs Kubernetes (Helm).
- No external database is used; state is ephemeral.

a. Main components
- Client Browser (HTML + JS)
- FastAPI Backend (pymaker-web/main.py)
- Ollama Service (llama3.2 model container)
- Deployment Infrastructure (Docker Compose or Kubernetes Cluster)
- Config & CI (compose.yaml, Helm charts, config maps)
- (Optional) Pinger test-pod for network/health checks

b. Relationships & interactions
1. User in browser → HTTP(S) request to FastAPI server
2. FastAPI processes UI request → calls ollama.py → forwards prompt to Ollama engine (gRPC/CLI)
3. Ollama generates code → returns response to FastAPI
4. FastAPI → HTTP response carrying generated code → Browser UI
5. Deployment assets (compose vs Helm) spin up containers/pods for FastAPI and Ollama
6. In Kubernetes: Ingress → Service → Deployment pods (FastAPI + Ollama)
7. pinger jobs test network reachability to FastAPI service

c. Architectural patterns & principles
- Separation of concerns: UI (static) vs API vs AI engine
- Container-first design for portability (Docker + Helm)
- Configuration-as-code: YAML/JSON config + prompt_prefix templates
- Helm umbrella chart with subcharts for modular micro-services

d. Relevant technologies
- Frontend: HTML, JavaScript
- Backend: Python, FastAPI
- AI Engine: Ollama (llama3.2)
- Containerization: Docker, Docker Compose
- Orchestration: Kubernetes, Helm charts
- Testing: Helm test-pod (pinger)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    subgraph "User Layer"
        direction TB
        subgraph "Browser UI" 
            direction TB
            Index["index.html"]:::ui
            SubmitJS["submitPromptForm.js"]:::ui
            SwitchJS["switchThemeButton.js"]:::ui
        end
    end

    %% Application Layer
    subgraph "Application Layer"
        direction TB
        subgraph "FastAPI Backend" 
            direction TB
            Main["main.py"]:::api
            ConfigPY["config.py"]:::api
            ModelPY["model.py"]:::api
            OllamaPY["ollama.py"]:::api
            ReqTxt["requirements.txt"]:::api
            Dockerfile["Dockerfile"]:::api
            Dockerignore[".dockerignore"]:::api
        end

        Ollama["Ollama Model (llama3.2)"]:::model
    end

    %% Infra Layer
    subgraph "Deployment Infrastructure" 
        direction TB
        subgraph "Docker Compose" 
            direction TB
            ComposeYAML["compose.yaml"]:::infra
            ConfigFiles["prompt_prefix.txt / pymaker_config.json"]:::infra
            Scripts["scripts.sh"]:::infra
        end
        subgraph "Kubernetes (Helm)" 
            direction TB
            subgraph "Umbrella Chart" 
                ChartYAML["Chart.yaml"]:::infra
                ValuesYAML["values.yaml"]:::infra
                DenyNS["deny-from-other-namespaces.yaml"]:::infra
            end
            subgraph "pymaker-web Subchart"
                CWChart["Chart.yaml"]:::infra
                CWValues["values.yaml"]:::infra
                CMap["configmap.yaml"]:::infra
                CDeploy["deployment.yaml"]:::infra
                CService["service.yaml"]:::infra
            end
            subgraph "pinger Test Pod" 
                PingerChart["Chart.yaml"]:::test
                PingerValues["values.yaml"]:::test
                TestPing["test-ping.yaml"]:::test
                PingScript["ping_not_tester.sh"]:::test
            end
        end
    end

    %% Connections
    Index -->|HTTP Request| Main
    SubmitJS -->|calls API| Main
    SwitchJS --> Main
    Main -->|gRPC/CLI Prompt| Ollama
    Ollama -->|Response| Main
    Main -->|HTTP Response| Index

    %% Deployment flows
    Main -->|Deploy via Compose| ComposeYAML
    ConfigPY -->|mounts| ConfigFiles
    ComposeYAML --> ConfigFiles

    Main -->|Deploy via Helm| ChartYAML
    ChartYAML --> CWChart
    CWChart --> CMap
    CWChart --> CDeploy
    CWChart --> CService
    ChartYAML --> OllamaPY
    ChartYAML --> DenyNS

    %% Pinger optional
    PingerChart -.->|Helm test| CWService["service.yaml"]:::infra
    PingerChart -.->|runs script| PingScript

    %% Click Events
    click Index "https://github.com/syildizz/pymaker/blob/master/pymaker-web/src/index.html"
    click SubmitJS "https://github.com/syildizz/pymaker/blob/master/pymaker-web/src/static/js/submitPromptForm.js"
    click SwitchJS "https://github.com/syildizz/pymaker/blob/master/pymaker-web/src/static/js/switchThemeButton.js"
    click Main "https://github.com/syildizz/pymaker/blob/master/pymaker-web/src/main.py"
    click ConfigPY "https://github.com/syildizz/pymaker/blob/master/pymaker-web/src/config.py"
    click ModelPY "https://github.com/syildizz/pymaker/blob/master/pymaker-web/src/model.py"
    click OllamaPY "https://github.com/syildizz/pymaker/blob/master/pymaker-web/src/ollama.py"
    click ReqTxt "https://github.com/syildizz/pymaker/blob/master/pymaker-web/requirements.txt"
    click Dockerfile "https://github.com/syildizz/pymaker/tree/master/pymaker-web/Dockerfile"
    click Dockerignore "https://github.com/syildizz/pymaker/blob/master/pymaker-web/.dockerignore"
    click Ollama "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pymaker/charts/ollama-1.16.0.tgz"
    click ComposeYAML "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/compose.yaml"
    click ConfigFiles "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/config/prompt_prefix.txt"
    click ConfigFiles "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/config/pymaker_config.json"
    click Scripts "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/scripts.sh"
    click ChartYAML "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pymaker/Chart.yaml"
    click ValuesYAML "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pymaker/values.yaml"
    click DenyNS "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pymaker/templates/deny-from-other-namespaces.yaml"
    click CWChart "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pymaker/charts/pymaker-web/Chart.yaml"
    click CWValues "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pymaker/charts/pymaker-web/values.yaml"
    click CMap "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pymaker/charts/pymaker-web/templates/configmap.yaml"
    click CDeploy "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pymaker/charts/pymaker-web/templates/deployment.yaml"
    click CService "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pymaker/charts/pymaker-web/templates/service.yaml"
    click PingerChart "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pinger/Chart.yaml"
    click PingerValues "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pinger/values.yaml"
    click TestPing "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pinger/templates/tests/test-ping.yaml"
    click PingScript "https://github.com/syildizz/pymaker/blob/master/pymaker-deploy/helm/pinger/ping_not_tester.sh"

    %% Styles
    classDef ui fill:#C3DDF9,stroke:#0366d6,color:#0366d6;
    classDef api fill:#DFF5E1,stroke:#28A745,color:#28A745;
    classDef model fill:#FFE4B5,stroke:#E69500,color:#E69500;
    classDef infra fill:#E2E2E2,stroke:#6A737D,color:#6A737D;
    classDef test fill:#F0F0F0,stroke:#999999,color:#999999,dasharray: 5 5;
```
