# muratdemirkiran33/curl2code architecture

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

- Interactive diagram: https://gitdiagram.com/muratdemirkiran33/curl2code
- Repository: https://github.com/muratdemirkiran33/curl2code

## Overview

##### Project Type and Purpose
- Project Type: Static, single-page web application/tool
- Purpose: Convert a user-supplied cURL command into equivalent code snippets in supported languages (PHP, JavaScript)

##### Main Components
a. Web UI (index.html + any CSS/markup)
b. Conversion Engine (src/js/curlToCode.js)
c. Language Template Modules (within curlToCode.js: PHP generator, JS generator)
d. Hosting/Deployment (GitHub Pages serving static files)

##### Relationships & Data Flow
1. **User Interaction**: User pastes cURL command in Web UI
2. **Controller**: UI JavaScript code captures input and calls the Conversion Engine
3. **Conversion Engine**: Parses the cURL string, builds an internal representation (headers, URL, method, body)
4. **Template Modules**: Engine invokes specific language module (PHP or JS) to produce code snippet
5. **Render Output**: Generated snippet is displayed in the UI
6. **External Hosting**: Entire bundle is served over HTTPS via GitHub Pages

##### Architectural Patterns & Design Principles
- Client-side MVC (lightweight):
- Model: Internal representation of parsed cURL request
- View: HTML/CSS interface, code output area
- Controller: glue code handling user events, invoking conversion engine
- Single Responsibility: curlToCode.js focuses solely on parsing and code generation
- Extensibility: New language modules can be added by implementing a generator function and registering it with the engine

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["User Browser"]:::external
    Browser -->|"1 HTTP GET"| GitHub["GitHub Pages"]:::hosting
    GitHub -->|"Serves index.html + curlToCode.js"| WebUI["Web UI"]:::ui
    WebUI -->|"2 User inputs cURL"| Engine["Conversion Engine"]:::core
    Engine -->|"4a dispatch to"| JSGen["JavaScript Generator Module"]:::core
    Engine -->|"4b dispatch to"| PHPGen["PHP Generator Module"]:::core
    Engine -->|"Extensibility"| NewLang["+ New Language Module"]:::core
    JSGen -->|"5 returns snippet"| WebUI
    PHPGen -->|"5 returns snippet"| WebUI

    click WebUI "https://github.com/muratdemirkiran33/curl2code/blob/main/index.html"
    click Engine "https://github.com/muratdemirkiran33/curl2code/blob/main/src/js/curlToCode.js"
    click JSGen "https://github.com/muratdemirkiran33/curl2code/blob/main/src/js/curlToCode.js"
    click PHPGen "https://github.com/muratdemirkiran33/curl2code/blob/main/src/js/curlToCode.js"
    click GitHub "https://github.com/muratdemirkiran33/curl2code/blob/main/."

    classDef ui fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef core fill:#90EE90,stroke:#333,stroke-width:1px
    classDef hosting fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef external fill:#F5F5F5,stroke:#333,stroke-width:1px
```
