# jaypatil9/codeleaf architecture

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

- Interactive diagram: https://gitdiagram.com/jaypatil9/codeleaf
- Repository: https://github.com/jaypatil9/codeleaf

## Overview

CodeLeaf is presented as an embeddable C++/Python playground. Its implemented run workflow is the playground page sending code, language, and stdin to Flask, which creates and polls a Paiza runner and returns execution details for display. A separate shared-snippet route reads stored snippets from MongoDB. The homepage’s demo run is a local mock, not connected to execution. The README is minimal; embedding and collaboration are described in frontend copy, but their implementations are not established by the sampled source.

Main entry points: [`backend/server.py`](https://github.com/jaypatil9/codeleaf/blob/main/backend/server.py) (Execution API), [`frontend/app/playground/[code_id]/page.tsx`](https://github.com/jaypatil9/codeleaf/blob/main/frontend/app/playground/%5Bcode_id%5D/page.tsx) (Shared playground), [`frontend/app/page.tsx`](https://github.com/jaypatil9/codeleaf/blob/main/frontend/app/page.tsx) (Landing page), [`frontend/app/playground/page.tsx`](https://github.com/jaypatil9/codeleaf/blob/main/frontend/app/playground/page.tsx) (General playground)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web interface"]
  node_home["Landing page<br/>[page.tsx]"]
  node_demo["Local demo<br/>[page.tsx]"]
  node_playground["General playground<br/>[page.tsx]"]
  node_shared["Shared playground<br/>[page.tsx]"]
end

subgraph group_backend["Execution backend"]
  node_execute["Execution API<br/>[server.py]"]
  node_snippet["Snippet lookup<br/>[server.py]"]
end

subgraph group_services["External services"]
  node_mongo[("MongoDB snippets")]
  node_paiza["Paiza runner API"]
end

node_visitor(("Playground user"))

node_visitor -->|"opens"| node_home
node_home -->|"starts mock"| node_demo
node_visitor -->|"opens"| node_playground
node_visitor -->|"opens link"| node_shared
node_playground -->|"posts code"| node_execute
node_shared -->|"posts code"| node_execute
node_shared -->|"requests snippet"| node_snippet
node_snippet -->|"reads"| node_mongo
node_execute -->|"creates runner"| node_paiza
node_execute -->|"polls status"| node_paiza

click node_home "https://github.com/jaypatil9/codeleaf/blob/main/frontend/app/page.tsx"
click node_demo "https://github.com/jaypatil9/codeleaf/blob/main/frontend/app/page.tsx"
click node_playground "https://github.com/jaypatil9/codeleaf/blob/main/frontend/app/playground/page.tsx"
click node_shared "https://github.com/jaypatil9/codeleaf/blob/main/frontend/app/playground/%5Bcode_id%5D/page.tsx"
click node_execute "https://github.com/jaypatil9/codeleaf/blob/main/backend/server.py"
click node_snippet "https://github.com/jaypatil9/codeleaf/blob/main/backend/server.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_home,node_demo,node_playground,node_shared,node_visitor toneBlue
class node_execute,node_snippet toneAmber
class node_mongo,node_paiza toneMint
```

## Components

### Web interface

- [Landing page](https://github.com/jaypatil9/codeleaf/blob/main/frontend/app/page.tsx): `frontend/app/page.tsx`
- [Local demo](https://github.com/jaypatil9/codeleaf/blob/main/frontend/app/page.tsx): `frontend/app/page.tsx`
- [General playground](https://github.com/jaypatil9/codeleaf/blob/main/frontend/app/playground/page.tsx): `frontend/app/playground/page.tsx`
- [Shared playground](https://github.com/jaypatil9/codeleaf/blob/main/frontend/app/playground/%5Bcode_id%5D/page.tsx): `frontend/app/playground/[code_id]/page.tsx`

### Execution backend

- [Execution API](https://github.com/jaypatil9/codeleaf/blob/main/backend/server.py): `backend/server.py`
- [Snippet lookup](https://github.com/jaypatil9/codeleaf/blob/main/backend/server.py): `backend/server.py`

### External services

- **MongoDB snippets**
- **Paiza runner API**

### Other components

- **Playground user**

## Connections

- Playground user → Landing page: opens
- Landing page → Local demo: starts mock
- Playground user → General playground: opens
- Playground user → Shared playground: opens link
- General playground → Execution API: posts code
- Shared playground → Execution API: posts code
- Shared playground → Snippet lookup: requests snippet
- Snippet lookup → MongoDB snippets: reads
- Execution API → Paiza runner API: creates runner
- Execution API → Paiza runner API: polls status
