API Documentation Generator
Run ID: 69cc5d69b4d97b7651475bc02026-03-31Development
PantheraHive BOS
BOS Dashboard

Product Catalog API Documentation

Welcome to the comprehensive documentation for the Product Catalog API. This guide provides detailed information on how to interact with our API, manage product data, handle authentication, and integrate using various SDKs.


1. Introduction

The Product Catalog API allows developers to programmatically manage products, including retrieving, creating, updating, and deleting product information within your catalog. This API is designed for ease of integration and provides a robust set of features for catalog management.


2. Authentication

Access to the Product Catalog API requires authentication using an API Key. This key must be included in the Authorization header of every request.

2.1 Obtaining Your API Key

  1. Log in to your developer portal at https://developer.yourcompany.com.
  2. Navigate to the "API Keys" section.
  3. Generate a new API Key if you don't have one, or use an existing one.
  4. Keep your API Key secure and do not share it publicly.

2.2 Using Your API Key

Include your API Key in the Authorization header with the Bearer scheme for all requests.

Example Request Header:

text • 2,764 chars
**Example Response (204 No Content):**

*(No response body for 204 status)*

---

### 4. Error Handling

The API uses standard HTTP status codes to indicate the success or failure of an API request. In case of an error, the response body will contain a JSON object with further details.

**Common Error Responses:**

| HTTP Status Code | Description                                   | Error Response Example                                   |
| :--------------- | :-------------------------------------------- | :------------------------------------------------------- |
| `400 Bad Request`  | The request was malformed or invalid.         | `{"error": "Invalid input data", "details": "Price must be a positive number."}` |
| `401 Unauthorized` | Authentication failed or missing API Key.     | `{"error": "Authentication required", "details": "Missing or invalid Authorization header."}` |
| `403 Forbidden`    | The authenticated user does not have permission to perform this action. | `{"error": "Permission denied", "details": "User does not have write access to products."}` |
| `404 Not Found`    | The requested resource could not be found.    | `{"error": "Resource not found", "details": "Product with ID 'prod_999' not found."}` |
| `409 Conflict`     | The request could not be completed due to a conflict with the current state of the resource. | `{"error": "Conflict", "details": "Product with SKU 'MK-RGB-001' already exists."}` |
| `429 Too Many Requests` | You have exceeded the API rate limit.       | `{"error": "Too Many Requests", "details": "Rate limit exceeded. Try again in 60 seconds."}` |
| `500 Internal Server Error` | An unexpected error occurred on the server. | `{"error": "Internal Server Error", "details": "An unexpected error occurred. Please try again later."}` |

---

### 5. Rate Limiting

To ensure fair usage and system stability, the Product Catalog API enforces rate limits.

*   **Limit**: 100 requests per minute per API Key.
*   **Exceeding the Limit**: If you exceed the rate limit, you will receive a `429 Too Many Requests` HTTP status code. The response headers will also include:
    *   `X-RateLimit-Limit`: The total number of requests allowed in the current window.
    *   `X-RateLimit-Remaining`: The number of requests remaining in the current window.
    *   `X-RateLimit-Reset`: The UTC epoch seconds when the current rate limit window resets.

We recommend implementing a retry mechanism with exponential backoff for requests that return a `429` status.

---

### 6. SDK Usage Examples

Our API is designed to be easily integrated into various programming languages. Below are examples using hypothetical Python and Node.js SDKs.

#### 6.1 Python SDK Example

First, install the SDK (hypothetically):

Sandboxed live preview

API Documentation Generator - Architectural Plan

Workflow Step: gemini → plan_architecture

Deliverable: Comprehensive Architecture Plan for the API Documentation Generator

This document outlines the high-level architecture for a professional API Documentation Generator. The goal is to create a robust, extensible, and user-friendly system capable of generating detailed API documentation including endpoint descriptions, request/response examples, authentication guides, and SDK usage examples from various input sources.


1. Introduction & Core Architectural Principles

The API Documentation Generator will be designed as a modular system, emphasizing flexibility in input sources, processing logic, and output formats.

Core Architectural Principles:

  • Modularity: Decoupled components for input parsing, data processing, templating, and output generation. This allows for independent development, testing, and maintenance.
  • Extensibility: Easy to add support for new input formats (e.g., different API description languages), new output templates, and new SDK languages.
  • Configurability: Users should be able to configure generation parameters, output styles, and content inclusion without modifying core code.
  • Maintainability: Clear code structure, consistent patterns, and comprehensive testing to ensure long-term viability.
  • Performance: Efficient processing of large API specifications to generate documentation quickly.
  • Scalability: Ability to handle complex API specifications with many endpoints and detailed schemas.
  • User-Centric Output: Focus on generating human-readable, navigable, and technically accurate documentation.

2. System Components and Layers

The generator will be structured into distinct layers, each responsible for a specific part of the documentation generation process.

2.1. Input Layer

This layer is responsible for ingesting API specifications from various sources and formats.

  • Supported Input Formats:

* OpenAPI/Swagger (YAML/JSON): Primary standard for API description.

* RAML: RESTful API Modeling Language.

* API Blueprint: Markdown-based API description language.

* Code Annotations (Future/Advanced): Extracting API information directly from source code (e.g., JSDoc, PHPDoc, Python docstrings with decorators).

  • Input Sources:

* Local files or directories.

* Remote URLs (e.g., API Gateway endpoints, GitHub repositories).

* Direct string input (e.g., via CLI or web UI).

  • Validation: Initial structural validation of the input against its respective schema (e.g., OpenAPI schema validation).

2.2. Parsing & Internal Data Model Layer

This layer takes the raw input and transforms it into a standardized, language-agnostic internal data model.

  • Schema Parsing: Converts the specific input format (OpenAPI, RAML, etc.) into an Abstract Syntax Tree (AST) or a structured object graph.
  • Internal Data Model: A unified, normalized representation of the API specification. This model will abstract away the differences between various input formats, providing a consistent interface for the subsequent layers. Key entities in this model will include:

* API: General information (title, version, description, servers).

* Endpoint: Path, HTTP method, summary, description, tags.

* Parameter: Name, location (query, header, path, body), type, required, description, example.

* Request Body: Content types, schemas, examples.

* Response: Status codes, descriptions, content types, schemas, examples.

* Schema: Data types, properties, examples, constraints.

* Security Scheme: Type (API Key, OAuth2, JWT, HTTP Basic), description.

* Tag: Grouping of endpoints.

  • Data Enrichment & Normalization:

* Resolving references ($ref).

* Inferring types or descriptions where missing.

* Linking related components (e.g., schemas used in requests/responses).

* Generating unique IDs for components if not present.

2.3. Content Generation & Templating Layer

This is the core logic for rendering the internal data model into human-readable documentation. It focuses on flexibility and rich content.

  • Templating Engine: A powerful templating engine (e.g., Jinja2 for Python, Handlebars for Node.js) will be used to allow for highly customizable output.
  • Core Documentation Sections:

* Introduction/Overview: API title, version, general description, base URLs.

* Authentication & Authorization: Detailed guides for each security scheme (API Key, OAuth2 flows, JWT, HTTP Basic). Includes example requests demonstrating how to authenticate.

* Endpoints Listing: Organized by tags or paths, with summaries.

* Detailed Endpoint View:

* Description: Comprehensive explanation of the endpoint's purpose.

* Path & Method: Clear indication.

* Parameters: Tables listing name, type, location, required status, description, and example values.

* Request Examples: Auto-generated or provided examples for various content types (JSON, XML, form data) with syntax highlighting.

* Response Examples: Auto-generated or provided examples for successful and error responses, with detailed schema descriptions.

* Error Handling: Common error codes and their meanings.

* Data Models/Schemas: Reference section detailing all reusable schemas.

* SDK Usage Examples:

* Code Snippet Generation: For each endpoint, generate example code snippets in multiple languages (ee.g., Python, JavaScript, Ruby, cURL) demonstrating how to make requests, handle responses, and authenticate.

* Language-Specific Integration: Utilize OpenAPI Generator's core logic or custom generators for high-quality, idiomatic SDK examples.

  • Customization: Users can select themes, include/exclude sections, and provide custom content (e.g., "Getting Started" guides, "Rate Limiting" policies) that can be merged with generated content.

2.4. Output & Deployment Layer

This layer is responsible for formatting the generated content into desired output formats and facilitating deployment.

  • Output Formats:

* Static HTML/CSS/JS: Primary output for web-based documentation. Will include features like search, navigation, and responsive design.

* PDF: For printable documentation.

* Markdown: For integration into existing documentation systems or static site generators.

* JSON/YAML (Raw): For machine-readable output or further processing.

  • Theming & Styling: Support for multiple themes and custom CSS to match branding.
  • Deployment Options:

* Local Files: Output to a specified directory.

* CI/CD Integration: Designed to be easily integrated into automated build pipelines.

* Publishing Connectors (Future): Direct deployment to platforms like GitHub Pages, Netlify, S3, or custom web servers.

2.5. User Interface / Control Layer

This layer provides mechanisms for users to interact with the generator.

  • Command-Line Interface (CLI): For automated workflows and power users.

* Specify input files/URLs.

* Select output format and directory.

* Choose templates/themes.

* Configuration options.

  • Web User Interface (Optional, Future): For easier configuration, preview, and management for non-technical users.

* Upload API specifications.

* Live preview of generated documentation.

* Configuration of themes, sections, and SDK languages.

* Download generated documentation.

  • API (Optional, Future): Programmatic access to the generator for integration into other systems.

3. High-Level Data Flow

  1. Input Acquisition: User provides API specification (file path, URL, or direct content) via CLI or Web UI.
  2. Input Validation: The raw input is validated against its respective schema (e.g., OpenAPI schema).
  3. Parsing: The validated input is parsed into an intermediate Abstract Syntax Tree (AST).
  4. Internal Model Generation: The AST is transformed and normalized into the generator's internal, language-agnostic data model.
  5. Content Generation: The internal data model is passed to the templating engine.

* Templates are selected based on user configuration.

* Dynamic content (examples, SDK snippets) is generated based on the model.

  1. Output Formatting: The rendered content is formatted into the desired output format (HTML, PDF, Markdown).
  2. Output Delivery: The generated documentation is saved to a specified location or published.

4. Proposed Technology Stack (Examples)

The following are example technologies that could be used for each layer, demonstrating a possible implementation path. The final choice may depend on the primary development language (e.g., Python, Node.js, Go).

  • Core Language: Python (for its rich ecosystem of text processing, web, and CLI libraries) or Node.js (for its strong ecosystem around OpenAPI and web technologies).
  • Input Parsing:

* OpenAPI: pyyaml, jsonschema (Python); swagger-parser, @stoplight/json (Node.js).

* RAML/API Blueprint: Specific parsers or community libraries.

  • Internal Data Model: Custom Python classes with dataclasses or Pydantic for schema definition; TypeScript interfaces/classes (Node.js).
  • Templating Engine:

* Python: Jinja2 or Mako.

* Node.js: Handlebars.js or Nunjucks.

  • Output Generation:

* HTML/CSS/JS: Bootstrap or Tailwind CSS for styling; custom JavaScript for interactivity (search, navigation).

* PDF: WeasyPrint (Python, for HTML to PDF); Puppeteer (Node.js, headless Chrome).

* Markdown: CommonMark parsers/renderers.

  • SDK Usage Examples:

* Leverage OpenAPI Generator CLI for initial code generation, then customize or integrate its core logic.

* Custom code generation logic using string templating based on the internal data model.

  • CLI:

* Python: Click or Argparse.

* Node.js: Commander.js or Yargs.

  • Web UI (if implemented):

* Frontend: React, Vue.js, or Angular.

* Backend (for API): FastAPI (Python), Express.js (Node.js).


5. Key Deliverables of this Architecture Plan

This architectural plan serves as the foundational document for the "API Documentation Generator" project, providing:

  • A clear understanding of the system's components and their responsibilities.
  • Guidance on core design principles (modularity, extensibility).
  • A conceptual data flow illustrating how information moves through the system.
  • Initial recommendations for a technology stack.
  • A basis for detailed design, sprint planning, and implementation phases.

6. Next Steps for the Workflow

Following the approval of this architectural plan, the subsequent steps in the "API Documentation Generator" workflow would typically involve:

  1. Detailed Design: Elaborating on each component, defining APIs between layers, specifying data structures, and creating UI/UX wireframes (if a web UI is planned).
  2. Technology Prototyping/Spiking: Validating chosen technologies and frameworks with small proof-of-concept implementations.
  3. Implementation & Development: Building out the components based on the detailed design.
  4. Testing & Quality Assurance: Comprehensive unit, integration, and end-to-end testing.
  5. Deployment & Documentation: Releasing the generator and documenting its usage.

Note on "Study Plan" Request: The initial prompt included a request for a "detailed study plan with: weekly schedule, learning objectives, recommended resources, milestones, and assessment strategies." This deliverable focuses solely on the architecture of the API Documentation Generator system as per the plan_architecture step. If a study plan for learning how to build such a system or for training users on the generated documentation is required, please submit it as a separate request.

gemini Output

This deliverable provides a comprehensive Python script designed to generate detailed, professional API documentation. This script fulfills the core requirements of the "API Documentation Generator" workflow by programmatically creating documentation that includes endpoint descriptions, request/response examples, authentication guides, and SDK usage examples.

The generated code is clean, well-commented, and structured for clarity and maintainability. It leverages a structured Python dictionary to define your API, making it easy to update and extend.


API Documentation Generator: Code Output

This section presents the Python script api_doc_generator.py, which is capable of generating detailed API documentation in Markdown format.

1. Overview of the Solution

The provided Python script api_doc_generator.py is a simple yet powerful tool for generating API documentation. It works by:

  1. Defining API Structure: You provide your API's details (endpoints, parameters, responses, authentication, models) in a structured Python dictionary. This allows for clear, programmatic definition of your API.
  2. Markdown Generation: The script processes this dictionary and formats the information into a human-readable Markdown file.
  3. Comprehensive Content: It covers all aspects requested: endpoint details, request/response examples, authentication methods, and conceptual SDK usage examples.

This approach offers flexibility, version control for your documentation source (the Python dictionary), and easy integration into automated workflows.

2. api_doc_generator.py - The Documentation Generation Script

The following Python script, api_doc_generator.py, contains the logic to parse a predefined API specification (as a Python dictionary) and output a comprehensive Markdown file.


import json
import os
from typing import Dict, Any, List

# --- API Specification Data ---
# This dictionary represents your API's structure and details.
# It's designed to be comprehensive and easy to modify.
API_SPEC: Dict[str, Any] = {
    "info": {
        "title": "PantheraHive Workflow API",
        "version": "1.0.0",
        "description": "The official API for interacting with PantheraHive workflows, enabling automation and integration of powerful AI capabilities.",
        "contact": {
            "name": "PantheraHive Support",
            "url": "https://www.pantherahive.com/support",
            "email": "support@pantherahive.com"
        },
        "license": {
            "name": "Apache 2.0",
            "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
        }
    },
    "servers": [
        {"url": "https://api.pantherahive.com/v1", "description": "Production Server"},
        {"url": "https://api.dev.pantherahive.com/v1", "description": "Development Server"}
    ],
    "auth_schemes": {
        "API Key": {
            "type": "apiKey",
            "name": "X-API-Key",
            "in": "header",
            "description": "Authentication is performed using an API key provided in the `X-API-Key` HTTP header. You can generate your API key from your PantheraHive account settings."
        },
        "OAuth2": {
            "type": "oauth2",
            "flows": {
                "clientCredentials": {
                    "tokenUrl": "https://auth.pantherahive.com/oauth2/token",
                    "scopes": {
                        "workflow:read": "Read access to workflows",
                        "workflow:execute": "Execute workflows",
                        "workflow:manage": "Create, update, delete workflows"
                    }
                }
            },
            "description": "OAuth 2.0 Client Credentials flow for application-level authentication. Obtain an access token using your client ID and secret."
        }
    },
    "endpoints": [
        {
            "path": "/workflows",
            "method": "GET",
            "summary": "Retrieve a list of available workflows",
            "description": "Fetches a paginated list of all workflows accessible by the authenticated user, including their current status and metadata.",
            "auth_required": ["API Key", "OAuth2 (workflow:read)"],
            "parameters": [
                {"name": "limit", "in": "query", "type": "integer", "required": False, "description": "Maximum number of workflows to return (default: 10, max: 100).", "example": 20},
                {"name": "offset", "in": "query", "type": "integer", "required": False, "description": "Number of workflows to skip for pagination.", "example": 0},
                {"name": "status", "in": "query", "type": "string", "required": False, "description": "Filter workflows by status (e.g., 'active', 'draft', 'archived').", "example": "active"}
            ],
            "responses": {
                "200": {
                    "description": "A list of workflows was successfully retrieved.",
                    "content": {
                        "application/json": {
                            "schema": {"$ref": "#/components/schemas/WorkflowList"},
                            "example": {
                                "data": [
                                    {"id": "wf_abc123", "name": "Image Classifier", "status": "active", "created_at": "2023-10-26T10:00:00Z"},
                                    {"id": "wf_def456", "name": "Text Summarizer", "status": "active", "created_at": "2023-10-25T15:30:00Z"}
                                ],
                                "total": 2,
                                "limit": 10,
                                "offset": 0
                            }
                        }
                    }
                },
                "401": {
                    "description": "Unauthorized. Authentication credentials are missing or invalid.",
                    "content": {
                        "application/json": {
                            "schema": {"$ref": "#/components/schemas/Error"},
                            "example": {"code": "UNAUTHORIZED", "message": "Authentication required."}
                        }
                    }
                }
            },
            "sdk_examples": [
                {
                    "language": "Python",
                    "code": """
import requests

api_key = "YOUR_API_KEY"
base_url = "https://api.pantherahive.com/v1"

headers = {"X-API-Key": api_key}
params = {"limit": 5, "status": "active"}

response = requests.get(f"{base_url}/workflows", headers=headers, params=params)

if response.status_code == 200:
    print("Workflows:", response.json()['data'])
else:
    print("Error:", response.json())
"""
                },
                {
                    "language": "Node.js (fetch)",
                    "code": """
const apiKey = "YOUR_API_KEY";
const baseUrl = "https://api.pantherahive.com/v1";

fetch(`${baseUrl}/workflows?limit=5&status=active`, {
    method: 'GET',
    headers: {
        'X-API-Key': apiKey,
        'Content-Type': 'application/json'
    }
})
.then(response => response.json())
.then(data => {
    if (response.ok) {
        console.log("Workflows:", data.data);
    } else {
        console.error("Error:", data);
    }
})
.catch(error => console.error('Fetch error:', error));
"""
                }
            ]
        },
        {
            "path": "/workflows/{workflow_id}/execute",
            "method": "POST",
            "summary": "Execute a specific workflow",
            "description": "Triggers the execution of a specified workflow with provided input data. The response includes an execution ID for tracking.",
            "auth_required": ["API Key", "OAuth2 (workflow:execute)"],
            "parameters": [
                {"name": "workflow_id", "in": "path", "type": "string", "required": True, "description": "The unique identifier of the workflow to execute.", "example": "wf_abc123"}
            ],
            "request_body": {
                "required": True,
                "description": "Input data for the workflow execution.",
                "content": {
                    "application/json": {
                        "schema": {"$ref": "#/components/schemas/WorkflowInput"},
                        "example": {
                            "input_data": {
                                "text": "The quick brown fox jumps over the lazy dog.",
                                "language": "en"
                            },
                            "callback_url": "https://your-app.com/workflow-status-update"
                        }
                    }
                }
            },
            "responses": {
                "200": {
                    "description": "Workflow execution successfully initiated.",
                    "content": {
                        "application/json": {
                            "schema": {"$ref": "#/components/schemas/WorkflowExecutionResponse"},
                            "example": {"execution_id": "exec_xyz789", "status": "pending"}
                        }
                    }
                },
                "400": {
                    "description": "Bad Request. Invalid input data or workflow ID.",
                    "content": {
                        "application/json": {
                            "schema": {"$ref": "#/components/schemas/Error"},
                            "example": {"code": "INVALID_INPUT", "message": "Required field 'text' is missing."}
                        }
                    }
                },
                "404": {
                    "description": "Not Found. The specified workflow ID does not exist.",
                    "content": {
                        "application/json": {
                            "schema": {"$ref": "#/components/schemas/Error"},
                            "example": {"code": "NOT_FOUND", "message": "Workflow 'wf_abc123' not found."}
                        }
                    }
                }
            },
            "sdk_examples": [
                {
                    "language": "Python",
                    "code": """
import requests

api_key = "YOUR_API_KEY"
base_url = "https://api.pantherahive.com/v1"
workflow_id = "wf_abc123"

headers = {
    "X-API-Key": api_key,
    "Content-Type": "application/json"
}
payload = {
    "input_data": {
        "text": "Hello, PantheraHive!",
        "language": "en"
    },
    "callback_url": "https://your-app.com/workflow-status"
}

response = requests.post(f"{base_url}/workflows/{workflow_id}/execute", headers=headers, json=payload)

if response.status_code == 200:
    print("Execution initiated:", response.json()['execution_id'])
else:
    print("Error:", response.json())
"""
                }
            ]
        }
    ],
    "components": {
        "schemas": {
            "WorkflowList": {
                "type": "object",
                "properties": {
                    "data": {
                        "type": "array",
                        "items": {"$ref": "#/components/schemas/Workflow"}
                    },
                    "total": {"type": "integer", "description": "Total number of workflows."},
                    "limit": {"type": "integer", "description": "Number of workflows returned in this response."},
                    "offset": {"type": "integer", "description": "Offset from the beginning of the list."}
                }
            },
            "Workflow": {
                "type": "object",
                "properties": {
                    "id": {"type

python

import os

from yourcompany_product_sdk import ProductClient

from yourcompany_product_sdk.models import ProductCreate

Initialize the client with your API Key

api_key = os.environ.get("YOURCOMPANY_API_KEY")

client = ProductClient(api_key=api_key)

try:

#

api_documentation_generator.txt
Download source file
Copy all content
Full output as text
Download ZIP
IDE-ready project ZIP
Copy share link
Permanent URL for this run
Get Embed Code
Embed this result on any website
Print / Save PDF
Use browser print dialog
"); var hasSrcMain=Object.keys(extracted).some(function(k){return k.indexOf("src/main")>=0;}); if(!hasSrcMain) zip.file(folder+"src/main."+ext,"import React from 'react' import ReactDOM from 'react-dom/client' import App from './App' import './index.css' ReactDOM.createRoot(document.getElementById('root')!).render( ) "); var hasSrcApp=Object.keys(extracted).some(function(k){return k==="src/App."+ext||k==="App."+ext;}); if(!hasSrcApp) zip.file(folder+"src/App."+ext,"import React from 'react' import './App.css' function App(){ return(

"+slugTitle(pn)+"

Built with PantheraHive BOS

) } export default App "); zip.file(folder+"src/index.css","*{margin:0;padding:0;box-sizing:border-box} body{font-family:system-ui,-apple-system,sans-serif;background:#f0f2f5;color:#1a1a2e} .app{min-height:100vh;display:flex;flex-direction:column} .app-header{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:40px} h1{font-size:2.5rem;font-weight:700} "); zip.file(folder+"src/App.css",""); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/pages/.gitkeep",""); zip.file(folder+"src/hooks/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+" Generated by PantheraHive BOS. ## Setup ```bash npm install npm run dev ``` ## Build ```bash npm run build ``` ## Open in IDE Open the project folder in VS Code or WebStorm. "); zip.file(folder+".gitignore","node_modules/ dist/ .env .DS_Store *.local "); } /* --- Vue (Vite + Composition API + TypeScript) --- */ function buildVue(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{ "name": "'+pn+'", "version": "0.0.0", "type": "module", "scripts": { "dev": "vite", "build": "vue-tsc -b && vite build", "preview": "vite preview" }, "dependencies": { "vue": "^3.5.13", "vue-router": "^4.4.5", "pinia": "^2.3.0", "axios": "^1.7.9" }, "devDependencies": { "@vitejs/plugin-vue": "^5.2.1", "typescript": "~5.7.3", "vite": "^6.0.5", "vue-tsc": "^2.2.0" } } '); zip.file(folder+"vite.config.ts","import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import { resolve } from 'path' export default defineConfig({ plugins: [vue()], resolve: { alias: { '@': resolve(__dirname,'src') } } }) "); zip.file(folder+"tsconfig.json",'{"files":[],"references":[{"path":"./tsconfig.app.json"},{"path":"./tsconfig.node.json"}]} '); zip.file(folder+"tsconfig.app.json",'{ "compilerOptions":{ "target":"ES2020","useDefineForClassFields":true,"module":"ESNext","lib":["ES2020","DOM","DOM.Iterable"], "skipLibCheck":true,"moduleResolution":"bundler","allowImportingTsExtensions":true, "isolatedModules":true,"moduleDetection":"force","noEmit":true,"jsxImportSource":"vue", "strict":true,"paths":{"@/*":["./src/*"]} }, "include":["src/**/*.ts","src/**/*.d.ts","src/**/*.tsx","src/**/*.vue"] } '); zip.file(folder+"env.d.ts","/// "); zip.file(folder+"index.html"," "+slugTitle(pn)+"
"); var hasMain=Object.keys(extracted).some(function(k){return k==="src/main.ts"||k==="main.ts";}); if(!hasMain) zip.file(folder+"src/main.ts","import { createApp } from 'vue' import { createPinia } from 'pinia' import App from './App.vue' import './assets/main.css' const app = createApp(App) app.use(createPinia()) app.mount('#app') "); var hasApp=Object.keys(extracted).some(function(k){return k.indexOf("App.vue")>=0;}); if(!hasApp) zip.file(folder+"src/App.vue"," "); zip.file(folder+"src/assets/main.css","*{margin:0;padding:0;box-sizing:border-box}body{font-family:system-ui,sans-serif;background:#fff;color:#213547} "); zip.file(folder+"src/components/.gitkeep",""); zip.file(folder+"src/views/.gitkeep",""); zip.file(folder+"src/stores/.gitkeep",""); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+" Generated by PantheraHive BOS. ## Setup ```bash npm install npm run dev ``` ## Build ```bash npm run build ``` Open in VS Code or WebStorm. "); zip.file(folder+".gitignore","node_modules/ dist/ .env .DS_Store *.local "); } /* --- Angular (v19 standalone) --- */ function buildAngular(zip,folder,app,code,panelTxt){ var pn=pkgName(app); var C=cc(pn); var sel=pn.replace(/_/g,"-"); var extracted=extractCode(panelTxt); zip.file(folder+"package.json",'{ "name": "'+pn+'", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test" }, "dependencies": { "@angular/animations": "^19.0.0", "@angular/common": "^19.0.0", "@angular/compiler": "^19.0.0", "@angular/core": "^19.0.0", "@angular/forms": "^19.0.0", "@angular/platform-browser": "^19.0.0", "@angular/platform-browser-dynamic": "^19.0.0", "@angular/router": "^19.0.0", "rxjs": "~7.8.0", "tslib": "^2.3.0", "zone.js": "~0.15.0" }, "devDependencies": { "@angular-devkit/build-angular": "^19.0.0", "@angular/cli": "^19.0.0", "@angular/compiler-cli": "^19.0.0", "typescript": "~5.6.0" } } '); zip.file(folder+"angular.json",'{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "'+pn+'": { "projectType": "application", "root": "", "sourceRoot": "src", "prefix": "app", "architect": { "build": { "builder": "@angular-devkit/build-angular:application", "options": { "outputPath": "dist/'+pn+'", "index": "src/index.html", "browser": "src/main.ts", "tsConfig": "tsconfig.app.json", "styles": ["src/styles.css"], "scripts": [] } }, "serve": {"builder":"@angular-devkit/build-angular:dev-server","configurations":{"production":{"buildTarget":"'+pn+':build:production"},"development":{"buildTarget":"'+pn+':build:development"}},"defaultConfiguration":"development"} } } } } '); zip.file(folder+"tsconfig.json",'{ "compileOnSave": false, "compilerOptions": {"baseUrl":"./","outDir":"./dist/out-tsc","forceConsistentCasingInFileNames":true,"strict":true,"noImplicitOverride":true,"noPropertyAccessFromIndexSignature":true,"noImplicitReturns":true,"noFallthroughCasesInSwitch":true,"paths":{"@/*":["src/*"]},"skipLibCheck":true,"esModuleInterop":true,"sourceMap":true,"declaration":false,"experimentalDecorators":true,"moduleResolution":"bundler","importHelpers":true,"target":"ES2022","module":"ES2022","useDefineForClassFields":false,"lib":["ES2022","dom"]}, "references":[{"path":"./tsconfig.app.json"}] } '); zip.file(folder+"tsconfig.app.json",'{ "extends":"./tsconfig.json", "compilerOptions":{"outDir":"./dist/out-tsc","types":[]}, "files":["src/main.ts"], "include":["src/**/*.d.ts"] } '); zip.file(folder+"src/index.html"," "+slugTitle(pn)+" "); zip.file(folder+"src/main.ts","import { bootstrapApplication } from '@angular/platform-browser'; import { appConfig } from './app/app.config'; import { AppComponent } from './app/app.component'; bootstrapApplication(AppComponent, appConfig) .catch(err => console.error(err)); "); zip.file(folder+"src/styles.css","* { margin: 0; padding: 0; box-sizing: border-box; } body { font-family: system-ui, -apple-system, sans-serif; background: #f9fafb; color: #111827; } "); var hasComp=Object.keys(extracted).some(function(k){return k.indexOf("app.component")>=0;}); if(!hasComp){ zip.file(folder+"src/app/app.component.ts","import { Component } from '@angular/core'; import { RouterOutlet } from '@angular/router'; @Component({ selector: 'app-root', standalone: true, imports: [RouterOutlet], templateUrl: './app.component.html', styleUrl: './app.component.css' }) export class AppComponent { title = '"+pn+"'; } "); zip.file(folder+"src/app/app.component.html","

"+slugTitle(pn)+"

Built with PantheraHive BOS

"); zip.file(folder+"src/app/app.component.css",".app-header{display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:60vh;gap:16px}h1{font-size:2.5rem;font-weight:700;color:#6366f1} "); } zip.file(folder+"src/app/app.config.ts","import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core'; import { provideRouter } from '@angular/router'; import { routes } from './app.routes'; export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes) ] }; "); zip.file(folder+"src/app/app.routes.ts","import { Routes } from '@angular/router'; export const routes: Routes = []; "); Object.keys(extracted).forEach(function(p){ var fp=p.startsWith("src/")?p:"src/"+p; zip.file(folder+fp,extracted[p]); }); zip.file(folder+"README.md","# "+slugTitle(pn)+" Generated by PantheraHive BOS. ## Setup ```bash npm install ng serve # or: npm start ``` ## Build ```bash ng build ``` Open in VS Code with Angular Language Service extension. "); zip.file(folder+".gitignore","node_modules/ dist/ .env .DS_Store *.local .angular/ "); } /* --- Python --- */ function buildPython(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^```[w]* ?/m,"").replace(/ ?```$/m,"").trim(); var reqMap={"numpy":"numpy","pandas":"pandas","sklearn":"scikit-learn","tensorflow":"tensorflow","torch":"torch","flask":"flask","fastapi":"fastapi","uvicorn":"uvicorn","requests":"requests","sqlalchemy":"sqlalchemy","pydantic":"pydantic","dotenv":"python-dotenv","PIL":"Pillow","cv2":"opencv-python","matplotlib":"matplotlib","seaborn":"seaborn","scipy":"scipy"}; var reqs=[]; Object.keys(reqMap).forEach(function(k){if(src.indexOf("import "+k)>=0||src.indexOf("from "+k)>=0)reqs.push(reqMap[k]);}); var reqsTxt=reqs.length?reqs.join(" "):"# add dependencies here "; zip.file(folder+"main.py",src||"# "+title+" # Generated by PantheraHive BOS print(title+" loaded") "); zip.file(folder+"requirements.txt",reqsTxt); zip.file(folder+".env.example","# Environment variables "); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. ## Setup ```bash python3 -m venv .venv source .venv/bin/activate pip install -r requirements.txt ``` ## Run ```bash python main.py ``` "); zip.file(folder+".gitignore",".venv/ __pycache__/ *.pyc .env .DS_Store "); } /* --- Node.js --- */ function buildNode(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^```[w]* ?/m,"").replace(/ ?```$/m,"").trim(); var depMap={"mongoose":"^8.0.0","dotenv":"^16.4.5","axios":"^1.7.9","cors":"^2.8.5","bcryptjs":"^2.4.3","jsonwebtoken":"^9.0.2","socket.io":"^4.7.4","uuid":"^9.0.1","zod":"^3.22.4","express":"^4.18.2"}; var deps={}; Object.keys(depMap).forEach(function(k){if(src.indexOf(k)>=0)deps[k]=depMap[k];}); if(!deps["express"])deps["express"]="^4.18.2"; var pkgJson=JSON.stringify({"name":pn,"version":"1.0.0","main":"src/index.js","scripts":{"start":"node src/index.js","dev":"nodemon src/index.js"},"dependencies":deps,"devDependencies":{"nodemon":"^3.0.3"}},null,2)+" "; zip.file(folder+"package.json",pkgJson); var fallback="const express=require("express"); const app=express(); app.use(express.json()); app.get("/",(req,res)=>{ res.json({message:""+title+" API"}); }); const PORT=process.env.PORT||3000; app.listen(PORT,()=>console.log("Server on port "+PORT)); "; zip.file(folder+"src/index.js",src||fallback); zip.file(folder+".env.example","PORT=3000 "); zip.file(folder+".gitignore","node_modules/ .env .DS_Store "); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. ## Setup ```bash npm install ``` ## Run ```bash npm run dev ``` "); } /* --- Vanilla HTML --- */ function buildVanillaHtml(zip,folder,app,code){ var title=slugTitle(app); var isFullDoc=code.trim().toLowerCase().indexOf("=0||code.trim().toLowerCase().indexOf("=0; var indexHtml=isFullDoc?code:" "+title+" "+code+" "; zip.file(folder+"index.html",indexHtml); zip.file(folder+"style.css","/* "+title+" — styles */ *{margin:0;padding:0;box-sizing:border-box} body{font-family:system-ui,-apple-system,sans-serif;background:#fff;color:#1a1a2e} "); zip.file(folder+"script.js","/* "+title+" — scripts */ "); zip.file(folder+"assets/.gitkeep",""); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. ## Open Double-click `index.html` in your browser. Or serve locally: ```bash npx serve . # or python3 -m http.server 3000 ``` "); zip.file(folder+".gitignore",".DS_Store node_modules/ .env "); } /* ===== MAIN ===== */ var sc=document.createElement("script"); sc.src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.10.1/jszip.min.js"; sc.onerror=function(){ if(lbl)lbl.textContent="Download ZIP"; alert("JSZip load failed — check connection."); }; sc.onload=function(){ var zip=new JSZip(); var base=(_phFname||"output").replace(/.[^.]+$/,""); var app=base.toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")||"my_app"; var folder=app+"/"; var vc=document.getElementById("panel-content"); var panelTxt=vc?(vc.innerText||vc.textContent||""):""; var lang=detectLang(_phCode,panelTxt); if(_phIsHtml){ buildVanillaHtml(zip,folder,app,_phCode); } else if(lang==="flutter"){ buildFlutter(zip,folder,app,_phCode,panelTxt); } else if(lang==="react-native"){ buildReactNative(zip,folder,app,_phCode,panelTxt); } else if(lang==="swift"){ buildSwift(zip,folder,app,_phCode,panelTxt); } else if(lang==="kotlin"){ buildKotlin(zip,folder,app,_phCode,panelTxt); } else if(lang==="react"){ buildReact(zip,folder,app,_phCode,panelTxt); } else if(lang==="vue"){ buildVue(zip,folder,app,_phCode,panelTxt); } else if(lang==="angular"){ buildAngular(zip,folder,app,_phCode,panelTxt); } else if(lang==="python"){ buildPython(zip,folder,app,_phCode); } else if(lang==="node"){ buildNode(zip,folder,app,_phCode); } else { /* Document/content workflow */ var title=app.replace(/_/g," "); var md=_phAll||_phCode||panelTxt||"No content"; zip.file(folder+app+".md",md); var h=""+title+""; h+="

"+title+"

"; var hc=md.replace(/&/g,"&").replace(//g,">"); hc=hc.replace(/^### (.+)$/gm,"

$1

"); hc=hc.replace(/^## (.+)$/gm,"

$1

"); hc=hc.replace(/^# (.+)$/gm,"

$1

"); hc=hc.replace(/**(.+?)**/g,"$1"); hc=hc.replace(/ {2,}/g,"

"); h+="

"+hc+"

Generated by PantheraHive BOS
"; zip.file(folder+app+".html",h); zip.file(folder+"README.md","# "+title+" Generated by PantheraHive BOS. Files: - "+app+".md (Markdown) - "+app+".html (styled HTML) "); } zip.generateAsync({type:"blob"}).then(function(blob){ var a=document.createElement("a"); a.href=URL.createObjectURL(blob); a.download=app+".zip"; a.click(); URL.revokeObjectURL(a.href); if(lbl)lbl.textContent="Download ZIP"; }); }; document.head.appendChild(sc); }function phShare(){navigator.clipboard.writeText(window.location.href).then(function(){var el=document.getElementById("ph-share-lbl");if(el){el.textContent="Link copied!";setTimeout(function(){el.textContent="Copy share link";},2500);}});}function phEmbed(){var runId=window.location.pathname.split("/").pop().replace(".html","");var embedUrl="https://pantherahive.com/embed/"+runId;var code='';navigator.clipboard.writeText(code).then(function(){var el=document.getElementById("ph-embed-lbl");if(el){el.textContent="Embed code copied!";setTimeout(function(){el.textContent="Get Embed Code";},2500);}});}