API Documentation Generator
Run ID: 69ccb1cc3e7fb09ff16a43e62026-04-01Development
PantheraHive BOS
BOS Dashboard

API Documentation Generator: Architecture Plan

This document outlines the proposed architecture for the "API Documentation Generator," a system designed to automate the creation of professional, detailed API documentation. The goal is to produce comprehensive documentation including endpoint descriptions, request/response examples, authentication guides, and SDK usage examples from various API definition formats.

1. High-Level Architecture Overview

The API Documentation Generator will operate as a modular system, ingesting API definitions, processing and enriching the data, and then rendering it into various output formats. It can be deployed as a standalone application, a microservice, or integrated into a CI/CD pipeline.

Core Flow:

  1. API Definition Input: Users provide API specifications (e.g., OpenAPI, RAML, Postman Collection).
  2. Parsing & Normalization: The system parses the input and converts it into a unified, internal data model.
  3. Data Enrichment: The normalized data is enhanced with generated examples, refined descriptions, and linked resources.
  4. Documentation Generation: A templating engine, using selected themes, generates documentation content.
  5. Rendering & Output: The content is rendered into final formats (HTML, Markdown, PDF) and can be hosted or exported.
mermaid • 592 chars
graph TD
    A[API Definition Input] --> B{API Definition Ingestor};
    B --> C[Internal API Data Model];
    C --> D{Data Enrichment Engine};
    D --> E[Templating Engine];
    E --> F{Documentation Renderer};
    F --> G[Output Formats];
    G --> H[Documentation Hosting/Storage];

    subgraph Core Services
        B
        D
        E
        F
    end

    subgraph Data Stores
        C
        H
    end

    subgraph Optional Components
        I[Admin/Configuration UI] --> B;
        J[AI/ML for Content Refinement] --> D;
        K[Version Control Integration] --> A;
    end
Sandboxed live preview

2. Core Components

The system will consist of several interconnected modules, each responsible for a specific part of the documentation generation process.

  • 2.1. API Definition Ingestor

* Purpose: To receive, parse, and validate various API definition formats.

* Key Features:

* Format Parsers: Support for OpenAPI/Swagger (YAML/JSON), RAML, API Blueprint, Postman Collections.

* Schema Validation: Ensures input definitions conform to their respective standards.

* Normalization: Converts diverse input formats into a consistent, internal API data model.

* Reference Resolution: Resolves $ref pointers and external references within the API definitions.

  • 2.2. Internal API Data Model

* Purpose: A unified, language-agnostic representation of the API, serving as the single source of truth for documentation generation.

* Key Features:

* Comprehensive representation of endpoints, operations, parameters, request/response bodies, schemas, authentication methods, tags, and security schemes.

* Designed for extensibility to accommodate future API definition formats or custom metadata.

  • 2.3. Data Enrichment Engine

* Purpose: To enhance the raw API data with additional context, examples, and clarity.

*

gemini Output

This step focuses on generating the core API documentation content in a structured, machine-readable format. We will output an OpenAPI Specification (OAS) in YAML format, which is the industry standard for describing RESTful APIs. This specification comprehensively covers endpoint descriptions, request/response examples, authentication methods, and data models. This "code" serves as the single source of truth for your API, enabling automated documentation rendering, client SDK generation, and API testing.


Generated Output: OpenAPI Specification (YAML)

Below is the generated OpenAPI 3.0 specification for a hypothetical "Product Management API". This YAML file defines the API's structure, endpoints, data models, and security schemes in detail.


# This OpenAPI Specification defines the Product Management API.
# It can be used to generate interactive documentation, client SDKs, and server stubs.

openapi: 3.0.0
info:
  title: Product Management API
  description: |
    This API provides a comprehensive set of endpoints for managing products, including creation, retrieval, updates, and deletion.
    It supports authentication and provides detailed product information.
  version: 1.0.0
servers:
  - url: https://api.example.com/v1
    description: Production server
  - url: https://dev.api.example.com/v1
    description: Development server
tags:
  - name: Products
    description: Operations related to product resources
  - name: Authentication
    description: User authentication and authorization
paths:
  /auth/login:
    post:
      summary: Authenticate a user and get an access token
      operationId: loginUser
      tags:
        - Authentication
      requestBody:
        description: User credentials for login
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/LoginRequest'
            examples:
              UserLogin:
                value:
                  username: user@example.com
                  password: securePassword123
      responses:
        '200':
          description: Successful authentication, returns an access token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/AuthResponse'
              examples:
                SuccessResponse:
                  value:
                    accessToken: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
                    tokenType: Bearer
                    expiresIn: 3600
        '401':
          description: Invalid credentials
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                InvalidCredentials:
                  value:
                    code: 401
                    message: Invalid username or password
        '400':
          description: Bad Request (e.g., missing fields)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                BadRequest:
                  value:
                    code: 400
                    message: Username and password are required
  /products:
    get:
      summary: Retrieve a list of all products
      operationId: getAllProducts
      tags:
        - Products
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          description: Maximum number of products to return
          required: false
          schema:
            type: integer
            format: int32
            minimum: 1
            default: 10
        - name: offset
          in: query
          description: Number of products to skip for pagination
          required: false
          schema:
            type: integer
            format: int32
            minimum: 0
            default: 0
        - name: category
          in: query
          description: Filter products by category
          required: false
          schema:
            type: string
            enum: [Electronics, Books, Clothing, Home]
      responses:
        '200':
          description: A list of products
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Product'
              examples:
                ProductList:
                  value:
                    - id: "prod_001"
                      name: "Wireless Headphones"
                      description: "High-fidelity wireless over-ear headphones."
                      price: 199.99
                      category: "Electronics"
                      stock: 150
                      createdAt: "2023-01-15T10:00:00Z"
                      updatedAt: "2023-01-15T10:00:00Z"
                    - id: "prod_002"
                      name: "The Great Novel"
                      description: "A compelling story of adventure and discovery."
                      price: 15.00
                      category: "Books"
                      stock: 300
                      createdAt: "2023-02-01T11:30:00Z"
                      updatedAt: "2023-02-01T11:30:00Z"
        '401':
          description: Unauthorized - authentication required
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                Unauthorized:
                  value:
                    code: 401
                    message: Authentication token missing or invalid
        '500':
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
    post:
      summary: Create a new product
      operationId: createProduct
      tags:
        - Products
      security:
        - BearerAuth: []
      requestBody:
        description: Product object to be created
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductCreate'
            examples:
              NewProduct:
                value:
                  name: "Smart Watch X"
                  description: "Next-gen smart watch with health tracking."
                  price: 249.99
                  category: "Electronics"
                  stock: 100
      responses:
        '201':
          description: Product created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Product'
              examples:
                CreatedProduct:
                  value:
                    id: "prod_003"
                    name: "Smart Watch X"
                    description: "Next-gen smart watch with health tracking."
                    price: 249.99
                    category: "Electronics"
                    stock: 100
                    createdAt: "2023-03-01T14:00:00Z"
                    updatedAt: "2023-03-01T14:00:00Z"
        '400':
          description: Invalid product data provided
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                InvalidData:
                  value:
                    code: 400
                    message: "Invalid input: 'name' is required"
        '401':
          description: Unauthorized - authentication required
        '500':
          description: Internal server error
  /products/{productId}:
    get:
      summary: Retrieve a product by its ID
      operationId: getProductById
      tags:
        - Products
      security:
        - BearerAuth: []
      parameters:
        - name: productId
          in: path
          description: The ID of the product to retrieve
          required: true
          schema:
            type: string
            format: uuid # Assuming UUID format for product IDs
          examples:
            id1:
              value: "prod_001"
            id2:
              value: "prod_002"
      responses:
        '200':
          description: Product details
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Product'
              examples:
                ProductDetails:
                  value:
                    id: "prod_001"
                    name: "Wireless Headphones"
                    description: "High-fidelity wireless over-ear headphones."
                    price: 199.99
                    category: "Electronics"
                    stock: 150
                    createdAt: "2023-01-15T10:00:00Z"
                    updatedAt: "2023-01-15T10:00:00Z"
        '404':
          description: Product not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                NotFound:
                  value:
                    code: 404
                    message: Product with ID 'prod_999' not found
        '401':
          description: Unauthorized - authentication required
        '500':
          description: Internal server error
    put:
      summary: Update an existing product
      operationId: updateProduct
      tags:
        - Products
      security:
        - BearerAuth: []
      parameters:
        - name: productId
          in: path
          description: The ID of the product to update
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        description: Product object with updated fields
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ProductUpdate'
            examples:
              UpdateProduct:
                value:
                  price: 189.99
                  stock: 130
      responses:
        '200':
          description: Product updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Product'
              examples:
                UpdatedProduct:
                  value:
                    id: "prod_001"
                    name: "Wireless Headphones"
                    description: "High-fidelity wireless over-ear headphones."
                    price: 189.99
                    category: "Electronics"
                    stock: 130
                    createdAt: "2023-01-15T10:00:00Z"
                    updatedAt: "2023-03-02T15:30:00Z"
        '400':
          description: Invalid product data provided
        '404':
          description: Product not found
        '401':
          description: Unauthorized - authentication required
        '500':
          description: Internal server error
    delete:
      summary: Delete a product by its ID
      operationId: deleteProduct
      tags:
        - Products
      security:
        - BearerAuth: []
      parameters:
        - name: productId
          in: path
          description: The ID of the product to delete
          required: true
          schema:
            type: string
            format: uuid
      responses:
        '204':
          description: Product deleted successfully (No Content)
        '404':
          description: Product not found
        '401':
          description: Unauthorized - authentication required
        '500':
          description: Internal server error
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: |
        JWT (JSON Web Token) based authentication.
        Provide the token in the `Authorization` header as `Bearer <token>`.
  schemas:
    LoginRequest:
      type: object
      required:
        - username
        - password
      properties:
        username:
          type: string
          format: email
          description: User's email address
          example: user@example.com
        password:
          type: string
          format: password
          description: User's password
          minLength: 8
          maxLength: 64
          example: securePassword123
    AuthResponse:
      type: object
      required:
        - accessToken
        - tokenType
        - expiresIn
      properties:
        accessToken:
          type: string
          description: The JWT access token
          example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
        tokenType:
          type: string
          description: Type of the token (e.g., Bearer)
          example: Bearer
        expiresIn:
          type: integer
          description: Time in seconds until the token expires
          example: 3600
    Product:
      type: object
      required:
        - id
        - name
        - description
        - price
        - category
        - stock
        - createdAt
        - updatedAt
      properties:
        id:
          type: string
          format: uuid
          description: Unique identifier for the product
          readOnly: true
          example: "prod_001"
        name:
          type: string
          description: Name of the product
          example: "Wireless Headphones"
        description:
          type: string
          description: Detailed description of the product
          example: "High-fidelity wireless over-ear headphones with noise cancellation."
        price:
          type: number
          format: float
          description: Price of the product
          minimum: 0
          example: 199.99
        category:
          type: string
          description: Category the product belongs to
gemini Output

API Documentation: PantheraConnect v1

Welcome to the PantheraConnect API documentation! This guide provides comprehensive information on how to integrate with the PantheraConnect platform, enabling you to programmatically manage your data, automate workflows, and extend the functionality of your applications.

This documentation covers:

  • Authentication: Securely access the API.
  • Base URL: The foundation for all API requests.
  • Endpoints: Detailed descriptions of available resources and operations.
  • Request & Response Examples: Practical examples for each endpoint.
  • Error Handling: Understand and manage API errors.
  • SDK Usage: Code examples for popular programming languages.
  • Rate Limiting: Information on API usage limits.

1. Introduction

The PantheraConnect API is a RESTful interface designed to help developers interact with their PantheraConnect resources efficiently. Whether you're building custom dashboards, integrating with third-party services, or automating internal processes, this API provides the tools you need.

Key Features:

  • Manage Users and their profiles.
  • Administer Products and their catalogs.
  • Retrieve analytics and reporting data.
  • Secure access via API keys and OAuth2.

Audience:

This documentation is intended for developers, system administrators, and technical users looking to integrate their applications with the PantheraConnect platform. A basic understanding of RESTful APIs, HTTP protocols, and JSON data format is recommended.


2. Getting Started

2.1. Base URL

All API requests should be made to the following base URL:

https://api.pantheraconnect.com/v1

2.2. Authentication

The PantheraConnect API uses API Keys for authentication, providing a simple yet secure way to access your resources. For more advanced scenarios and third-party integrations, OAuth2 is also supported.

2.2.1. API Key Authentication

To authenticate your requests, you must include your API Key in the Authorization header of every request.

How to obtain your API Key:

  1. Log in to your PantheraConnect dashboard.
  2. Navigate to "Settings" -> "API Keys".
  3. Generate a new API Key if you don't have one, or use an existing one.
  4. Keep your API Key secure and never expose it in client-side code.

Example Header:


Authorization: Bearer YOUR_API_KEY

Replace YOUR_API_KEY with the actual API key obtained from your dashboard.

2.2.2. OAuth2 (Advanced)

For applications requiring delegated access or user consent, PantheraConnect supports the OAuth2 authorization framework. This allows users to grant your application limited access to their resources without sharing their credentials.

OAuth2 Flow Types Supported:

  • Authorization Code Grant (for web applications)
  • Client Credentials Grant (for machine-to-machine communication)

Please refer to our dedicated [OAuth2 Guide](https://api.pantheraconnect.com/oauth2-guide) for detailed instructions on implementing OAuth2.

2.3. Making Your First Request

Let's make a simple request to retrieve a list of users to ensure your authentication is set up correctly.

Example (using curl):


curl -X GET \
  'https://api.pantheraconnect.com/v1/users' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY'

If successful, you should receive a JSON array of user objects.


3. API Endpoints

This section details all available API endpoints, including their methods, paths, descriptions, parameters, and examples.

3.1. Users

Manage user accounts within your PantheraConnect organization.

3.1.1. List All Users

Retrieves a paginated list of all users in your organization.

  • Method: GET
  • Path: /users

Query Parameters:

| Parameter | Type | Description | Required | Default |

| :-------- | :----- | :---------------------------------------------------- | :------- | :------ |

| page | integer | The page number to retrieve. | No | 1 |

| limit | integer | The number of items per page (max 100). | No | 20 |

| status | string | Filter users by status (active, inactive, pending). | No | |

Request Example:


curl -X GET \
  'https://api.pantheraconnect.com/v1/users?page=1&limit=10&status=active' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Response Example (200 OK):


{
  "data": [
    {
      "id": "usr_abc123",
      "email": "john.doe@example.com",
      "first_name": "John",
      "last_name": "Doe",
      "status": "active",
      "created_at": "2023-01-15T10:00:00Z",
      "updated_at": "2023-01-15T10:00:00Z"
    },
    {
      "id": "usr_def456",
      "email": "jane.smith@example.com",
      "first_name": "Jane",
      "last_name": "Smith",
      "status": "active",
      "created_at": "2023-01-16T11:30:00Z",
      "updated_at": "2023-01-16T11:30:00Z"
    }
  ],
  "meta": {
    "total": 50,
    "page": 1,
    "limit": 10,
    "total_pages": 5
  }
}

3.1.2. Get a Specific User

Retrieves details for a single user by their ID.

  • Method: GET
  • Path: /users/{id}

Path Parameters:

| Parameter | Type | Description | Required |

| :-------- | :----- | :------------------------ | :------- |

| id | string | The unique ID of the user. | Yes |

Request Example:


curl -X GET \
  'https://api.pantheraconnect.com/v1/users/usr_abc123' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Response Example (200 OK):


{
  "id": "usr_abc123",
  "email": "john.doe@example.com",
  "first_name": "John",
  "last_name": "Doe",
  "status": "active",
  "role": "admin",
  "last_login_at": "2023-10-26T08:45:00Z",
  "created_at": "2023-01-15T10:00:00Z",
  "updated_at": "2023-10-26T09:00:00Z"
}

Response Example (404 Not Found):


{
  "error": {
    "code": "resource_not_found",
    "message": "User with ID 'usr_nonexistent' not found."
  }
}

3.1.3. Create a New User

Creates a new user account in your organization.

  • Method: POST
  • Path: /users

Request Body Parameters:

| Parameter | Type | Description | Required |

| :----------- | :------- | :----------------------------------------- | :------- |

| email | string | The user's email address (must be unique). | Yes |

| first_name | string | The user's first name. | Yes |

| last_name | string | The user's last name. | Yes |

| password | string | The user's initial password. | Yes |

| role | string | The user's role (user, admin, etc.). | No |

Request Example:


curl -X POST \
  'https://api.pantheraconnect.com/v1/users' \
  -H 'Content-Type: application/json' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -d '{
    "email": "alice.wonderland@example.com",
    "first_name": "Alice",
    "last_name": "Wonderland",
    "password": "SecurePassword123!",
    "role": "user"
  }'

Response Example (201 Created):


{
  "id": "usr_ghi789",
  "email": "alice.wonderland@example.com",
  "first_name": "Alice",
  "last_name": "Wonderland",
  "status": "pending",
  "role": "user",
  "created_at": "2023-10-26T10:15:00Z",
  "updated_at": "2023-10-26T10:15:00Z"
}

Response Example (400 Bad Request):


{
  "error": {
    "code": "validation_error",
    "message": "Invalid input for user creation.",
    "details": [
      {
        "field": "email",
        "message": "Email 'alice.wonderland@example.com' already exists."
      },
      {
        "field": "password",
        "message": "Password must be at least 8 characters long."
      }
    ]
  }
}

3.2. Products

Manage product catalog and inventory.

3.2.1. List All Products

Retrieves a paginated list of all products.

  • Method: GET
  • Path: /products

Query Parameters:

| Parameter | Type | Description | Required | Default |

| :-------- | :----- | :---------------------------------------------------- | :------- | :------ |

| page | integer | The page number to retrieve. | No | 1 |

| limit | integer | The number of items per page (max 50). | No | 20 |

| category| string | Filter products by category. | No | |

| in_stock| boolean| Filter products that are currently in stock. | No | false |

Request Example:


curl -X GET \
  'https://api.pantheraconnect.com/v1/products?category=electronics&in_stock=true' \
  -H 'Accept: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY'

Response Example (200 OK):


{
  "data": [
    {
      "id": "prod_101",
      "name": "Wireless Headphones",
      "description": "Premium noise-cancelling headphones.",
      "price": 199.99,
      "currency": "USD",
      "category": "electronics",
      "stock_quantity": 50,
      "is_active": true,
      "created_at": "2023-02-01T09:00:00Z"
    },
    {
      "id": "prod_102",
      "name": "Smartwatch X",
      "description": "Feature-rich smartwatch with health tracking.",
      "price": 249.00,
      "currency": "USD",
      "category": "electronics",
      "stock_quantity": 120,
      "is_active": true,
      "created_at": "2023-02-10T14:00:00Z"
    }
  ],
  "meta": {
    "total": 2,
    "page": 1,
    "limit": 20,
    "total_pages": 1
  }
}

4. Data Models

This section describes the structure of common data objects returned by the API.

4.1. User Object

The User object represents a user account in PantheraConnect.

| Field | Type | Description |

| :----------- | :-------- | :--------------------------------------------------------- |

| id | string | Unique identifier for the user (e.g., usr_abc123). |

| email | string | The user's email address. |

| first_name | string | The user's first name. |

| last_name | string | The user's last name. |

| status | string | Current status of the user (active, inactive, pending). |

| role | string | The user's role within the organization (e.g., admin, user). |

| created_at | string | ISO 8601 timestamp of when the user was created. |

| updated_at | string | ISO 8601 timestamp of when the user was last updated. |

4.2. Product Object

The Product object represents an item in your product catalog.

| Field | Type | Description |

| :------------- | :-------- | :--------------------------------------------------------- |

| id | string | Unique identifier for the product

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);}});}