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

As requested, this deliverable provides comprehensive, detailed, and professional output for the "API Documentation Generator" workflow, specifically focusing on generating the core content and code examples for professional API documentation. This output is designed to be production-ready, clean, well-commented, and directly actionable for the customer.


API Documentation: PantheraHive Analytics API

Welcome to the PantheraHive Analytics API documentation! This guide provides comprehensive information on how to integrate with our platform to access and manage your analytics data programmatically. You'll find details on authentication, available endpoints, request/response formats, error handling, and SDK usage examples to help you get started quickly.

Base URL: https://api.pantherahive.com/v1


1. Introduction

The PantheraHive Analytics API allows developers to programmatically access, manage, and retrieve analytics data for their applications and services. With this API, you can:

Our API is built on RESTful principles, uses JSON for request and response bodies, and standard HTTP response codes to indicate success or failure.


2. Authentication

The PantheraHive Analytics API uses API Key Authentication. To access protected resources, you must include your unique API Key in the Authorization header of every request.

2.1. Obtaining Your API Key

  1. Log in to your PantheraHive dashboard.
  2. Navigate to "Settings" -> "API Keys".
  3. Generate a new API Key if you don't have one, or retrieve an existing one.
  4. Keep your API Key secure and do not share it publicly.

2.2. Authenticating Requests

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

Header Example:

Authorization: Bearer YOUR_API_KEY

Code Example: Authenticated Request (cURL)

text • 950 chars
#### 3.2. Events API

The Events API allows you to retrieve and track custom events.

##### 3.2.1. List Events for a Project

Retrieve a list of recent events for a specific project.

*   **`GET /projects/{project_id}/events`**
*   **Description:** Returns an array of event objects.
*   **Parameters:**
    *   `project_id` (required, string): The unique identifier of the project.
    *   `event_name` (optional, string): Filter events by a specific name.
    *   `user_id` (optional, string): Filter events by a specific user ID.
    *   `start_date` (optional, date-time): ISO 8601 formatted date to filter events from (inclusive).
    *   `end_date` (optional, date-time): ISO 8601 formatted date to filter events until (inclusive).
    *   `limit` (optional, integer): Maximum number of events to return. Default: 100. Max: 1000.
    *   `offset` (optional, integer): Number of events to skip. Default: 0.

*   **Request Example (cURL):**
    
Sandboxed live preview

As part of the "API Documentation Generator" workflow, this deliverable outlines a detailed study plan designed to equip individuals with the knowledge and skills necessary to understand, design, implement, and effectively utilize tools for generating professional API documentation. This plan is tailored for developers, technical writers, and product managers looking to enhance their capabilities in this critical area.


Detailed Study Plan: Mastering API Documentation Generation

1. Introduction & Overall Learning Objective

This study plan provides a structured approach to learning the intricacies of API documentation generation. From understanding core API concepts and documentation principles to mastering industry-standard specifications and leveraging powerful generation tools, this plan aims to build a comprehensive skill set.

Overall Learning Objective: Upon completion of this study plan, the learner will be able to design, implement, and maintain high-quality, automatically generated API documentation that is clear, comprehensive, and user-friendly, covering endpoint descriptions, request/response examples, authentication guides, and SDK usage.

2. Weekly Schedule & Learning Objectives

This 6-week schedule provides a progressive learning path. Each week builds upon the previous one, ensuring a solid foundation.

Week 1: Foundations of APIs & Documentation Principles

  • Learning Objectives:

* Understand core API concepts: REST, GraphQL, SOAP, endpoints, methods (GET, POST, PUT, DELETE), status codes.

* Identify the key components of effective API documentation (overview, endpoints, auth, examples, errors).

* Recognize the value proposition of good API documentation for developers and business.

* Differentiate between human-written and machine-generated documentation.

* Familiarize with common documentation styles and best practices (clarity, consistency, discoverability).

  • Key Activities:

* Read introductory articles on API design and documentation.

* Review examples of excellent API documentation (e.g., Stripe, Twilio).

* Outline the essential sections for a hypothetical API's documentation.

Week 2: OpenAPI/Swagger Specification

  • Learning Objectives:

* Understand the purpose and structure of the OpenAPI Specification (OAS).

* Learn to read and interpret OpenAPI (YAML/JSON) files.

* Be able to manually define simple API endpoints, parameters, and responses using OAS syntax.

* Understand schema definitions for request and response bodies.

* Explore tools for creating and validating OpenAPI definitions (Swagger Editor).

  • Key Activities:

* Complete a tutorial on OpenAPI Specification basics.

* Use Swagger Editor to define a simple REST API (e.g., a "To-Do List" API with GET/POST tasks).

* Validate the generated OpenAPI definition.

Week 3: API Documentation Generation Tools & Workflows

  • Learning Objectives:

* Explore popular API documentation generators (e.g., Swagger UI, Redoc, Postman, Stoplight Studio, Docusaurus with OpenAPI plugins).

* Understand how these tools consume OpenAPI specifications to render interactive documentation.

* Learn basic configuration and customization options for chosen generators.

* Identify common workflows for integrating documentation generation into CI/CD pipelines.

* Understand the role of API gateways (e.g., AWS API Gateway, Kong) in documentation.

  • Key Activities:

* Set up a local environment with Swagger UI and Redoc, and generate documentation from the Week 2 OpenAPI file.

* Experiment with Postman's documentation features for a collection.

* Research CI/CD integration patterns for documentation.

Week 4: Advanced Documentation Concepts & Examples

  • Learning Objectives:

* Implement robust authentication/authorization schemes within OpenAPI (API Keys, OAuth2, JWT).

* Learn to define detailed request and response examples (including multiple examples, error responses).

* Understand how to document SDK usage and provide code snippets for various languages.

* Explore techniques for documenting webhooks and asynchronous APIs.

* Learn to incorporate rich media (diagrams, flowcharts) into documentation.

  • Key Activities:

* Enhance the Week 2 API definition to include OAuth2 authentication.

* Add comprehensive request/response examples for all endpoints, including error cases.

* Write sample SDK usage examples (e.g., Python requests library, JavaScript fetch).

Week 5: Customization, Theming & Deployment

  • Learning Objectives:

* Understand how to apply custom themes and branding to generated documentation.

* Learn to extend generators with custom templates or plugins (if applicable to chosen tools).

* Explore deployment strategies for API documentation (static hosting, embedded within applications, dedicated portals).

* Understand versioning strategies for API documentation.

* Learn about search engine optimization (SEO) considerations for documentation.

  • Key Activities:

* Customize the theme/styling of the documentation generated in Week 3/4.

* Deploy the generated documentation to a static hosting service (e.g., Netlify, GitHub Pages).

* Implement a simple versioning scheme for the API and its documentation.

Week 6: Best Practices, Automation & Future Trends

  • Learning Objectives:

* Consolidate best practices for maintainable and scalable API documentation.

* Understand the role of API governance and style guides in documentation.

* Explore advanced automation techniques (e.g., generating OpenAPI from code, linting OpenAPI definitions).

* Research emerging trends in API documentation (e.g., AI-driven generation, interactive tutorials, developer experience platforms).

* Understand how to gather feedback and iterate on documentation.

  • Key Activities:

* Review and refine the entire documentation project based on best practices.

* Investigate tools for linting OpenAPI definitions (e.g., Spectral).

* Research one emerging trend and summarize its potential impact.

* Develop a strategy for collecting user feedback on documentation.

3. Recommended Resources

  • Books:

* "Designing Web APIs" by Arnaud Lauret

* "The API Design Guide" (online resource, various authors)

* "API Documentation Best Practices" by various authors (online articles)

  • Online Courses & Tutorials:

* Swagger/OpenAPI Official Documentation: [swagger.io/docs/](https://swagger.io/docs/)

* Redoc Official Documentation: [redocly.com/docs/redoc/](https://redocly.com/docs/redoc/)

* Postman Learning Center: [learning.postman.com/](https://learning.postman.com/)

* Stoplight Academy: [stoplight.io/academy/](https://stoplight.io/academy/)

* Udemy/Coursera courses: Search for "API Design", "OpenAPI", "Technical Writing for APIs".

  • Tools:

* OpenAPI Editors: Swagger Editor, Stoplight Studio, VS Code extensions.

* Documentation Generators: Swagger UI, Redoc, Docusaurus (with OpenAPI plugin), Slate.

* API Clients: Postman, Insomnia.

* Linting: Spectral.

  • Blogs & Communities:

* Nordic APIs Blog

* APIs You Won't Hate

* Write the Docs Community & Slack Channel

4. Milestones

  • End of Week 2: Successfully create a valid OpenAPI 3.x definition for a simple API.
  • End of Week 3: Generate interactive documentation for the simple API using at least two different tools (e.g., Swagger UI, Redoc).
  • End of Week 4: Enhance the API definition and generated documentation with authentication, comprehensive examples, and SDK usage snippets.
  • End of Week 5: Deploy a customized, themed version of the API documentation to a public static hosting service.
  • End of Week 6: Complete a self-assessment and present a refined documentation project, including a plan for ongoing maintenance and improvement.

5. Assessment Strategies

  • Practical Projects (Weekly/Bi-weekly): Each week concludes with a hands-on task (e.g., defining an API, generating docs, customizing a theme). These projects serve as direct application of learned concepts.
  • Self-Assessment Checklists: Provide detailed checklists for each weekly objective to allow learners to track their progress and identify areas needing further attention.
  • Peer Review (Optional but Recommended): Exchange documentation projects with a peer for constructive feedback on clarity, completeness, and user experience.
  • Final Documentation Project: A comprehensive project at the end of the 6 weeks, where the learner applies all acquired knowledge to generate professional documentation for a more complex API scenario. This project will be evaluated based on:

* Adherence to OpenAPI Specification standards.

* Clarity, accuracy, and completeness of endpoint descriptions.

* Quality and relevance of request/response examples.

* Effectiveness of authentication guides.

* Usability and aesthetic appeal of the generated documentation.

* Demonstration of customization and deployment.

  • Concept Quizzes: Short, informal quizzes throughout the plan to reinforce theoretical understanding (e.g., OpenAPI syntax, API design principles).


4. Error Handling

The PantheraHive Analytics 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 an error field detailing the issue.

| HTTP Status Code | Meaning | Description

gemini Output

This document provides comprehensive, detailed, and professional API documentation for the PantheraHive Product Catalog API. It includes an overview, authentication methods, error handling, detailed endpoint descriptions with request/response examples, data models, and SDK usage examples.


PantheraHive Product Catalog API Documentation

Welcome to the PantheraHive Product Catalog API documentation. This API allows developers to programmatically manage products within the PantheraHive ecosystem, including listing, retrieving, creating, updating, and deleting product information.

1. Introduction

The PantheraHive Product Catalog API provides a robust and flexible interface for interacting with product data. Whether you're building an e-commerce platform, integrating with inventory management systems, or developing data analytics tools, this API offers the necessary endpoints to access and manipulate your product catalog efficiently.

2. Base URL

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

https://api.pantherahive.com/v1

3. Authentication

The PantheraHive Product Catalog API uses API Key authentication. To access protected endpoints, you must include your API Key in the Authorization header of your requests.

3.1. Obtaining Your API Key

Your API Key can be generated and managed from your PantheraHive developer dashboard under "API Credentials". Keep your API Key secure and do not share it publicly.

3.2. Including the API Key in Requests

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

Example:


Authorization: Bearer YOUR_API_KEY

cURL Example:


curl -X GET \
  https://api.pantherahive.com/v1/products \
  -H 'Authorization: Bearer YOUR_API_KEY'

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 API will return a JSON object with details about the error.

4.1. Common HTTP Status Codes

| Status Code | Description |

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

| 200 OK | The request was successful. |

| 201 Created | The resource was successfully created. |

| 204 No Content | The request was successful, but no content was returned (e.g., successful deletion). |

| 400 Bad Request | The request was malformed or invalid. |

| 401 Unauthorized | Authentication failed or was not provided. |

| 403 Forbidden | The authenticated user does not have permission to access the resource. |

| 404 Not Found | The requested resource could not be found. |

| 405 Method Not Allowed | The HTTP method used is not supported for this endpoint. |

| 429 Too Many Requests | You have sent too many requests in a given amount of time (rate limiting). |

| 500 Internal Server Error | An unexpected error occurred on the server. |

4.2. Error Response Structure


{
  "code": "string",      // A unique error code
  "message": "string",   // A human-readable error message
  "details": "object"    // Optional: Additional details about the error (e.g., validation errors)
}

Example Error Response:


HTTP/1.1 400 Bad Request
Content-Type: application/json

{
  "code": "INVALID_INPUT",
  "message": "Validation failed for request body.",
  "details": {
    "name": "Product name is required.",
    "price": "Price must be a positive number."
  }
}

5. Rate Limiting

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

  • Limit: 100 requests per minute per API Key.
  • Headers:

* X-RateLimit-Limit: The maximum number of requests you can make 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.

If you exceed the rate limit, you will receive a 429 Too Many Requests HTTP status code.

6. Endpoints

This section details all available endpoints, including their HTTP methods, paths, descriptions, parameters, and request/response examples.


6.1. List All Products

Retrieve a list of all products in the catalog.

  • URL: /products
  • Method: GET
  • Description: Returns a paginated list of product objects.
  • Authentication: Required

##### Parameters

| Name | Type | Description | Required | Location |

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

| page | integer | The page number to retrieve. (Default: 1) | Optional | Query |

| limit | integer | The number of products per page. (Default: 10, Max: 100) | Optional | Query |

| category | string | Filter products by category. | Optional | Query |

##### Request Example


curl -X GET \
  'https://api.pantherahive.com/v1/products?page=1&limit=5&category=electronics' \
  -H 'Authorization: Bearer YOUR_API_KEY'

##### Response Example (200 OK)


HTTP/1.1 200 OK
Content-Type: application/json

{
  "data": [
    {
      "id": "prod_12345",
      "name": "Wireless Bluetooth Headphones",
      "description": "High-fidelity sound with active noise cancellation.",
      "price": 129.99,
      "currency": "USD",
      "category": "electronics",
      "sku": "WH-BT-001",
      "stock": 50,
      "imageUrl": "https://cdn.pantherahive.com/images/prod_12345.jpg",
      "createdAt": "2023-10-26T10:00:00Z",
      "updatedAt": "2023-10-26T10:00:00Z"
    },
    {
      "id": "prod_67890",
      "name": "Ergonomic Office Chair",
      "description": "Adjustable chair for maximum comfort and support.",
      "price": 299.00,
      "currency": "USD",
      "category": "furniture",
      "sku": "OC-ERGO-005",
      "stock": 15,
      "imageUrl": "https://cdn.pantherahive.com/images/prod_67890.jpg",
      "createdAt": "2023-10-25T09:30:00Z",
      "updatedAt": "2023-10-27T11:45:00Z"
    }
  ],
  "pagination": {
    "total": 120,
    "page": 1,
    "limit": 5,
    "totalPages": 24,
    "nextPage": 2,
    "prevPage": null
  }
}

6.2. Get Product by ID

Retrieve details for a single product by its unique ID.

  • URL: /products/{productId}
  • Method: GET
  • Description: Returns a single product object matching the provided ID.
  • Authentication: Required

##### Parameters

| Name | Type | Description | Required | Location |

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

| productId | string | The unique ID of the product. | Required | Path |

##### Request Example


curl -X GET \
  https://api.pantherahive.com/v1/products/prod_12345 \
  -H 'Authorization: Bearer YOUR_API_KEY'

##### Response Example (200 OK)


HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": "prod_12345",
  "name": "Wireless Bluetooth Headphones",
  "description": "High-fidelity sound with active noise cancellation.",
  "price": 129.99,
  "currency": "USD",
  "category": "electronics",
  "sku": "WH-BT-001",
  "stock": 50,
  "imageUrl": "https://cdn.pantherahive.com/images/prod_12345.jpg",
  "createdAt": "2023-10-26T10:00:00Z",
  "updatedAt": "2023-10-26T10:00:00Z"
}

##### Response Example (404 Not Found)


HTTP/1.1 404 Not Found
Content-Type: application/json

{
  "code": "PRODUCT_NOT_FOUND",
  "message": "Product with ID 'prod_99999' not found."
}

6.3. Create a New Product

Add a new product to the catalog.

  • URL: /products
  • Method: POST
  • Description: Creates a new product and returns the newly created product object.
  • Authentication: Required

##### Request Body Parameters

| Name | Type | Description | Required |

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

| name | string | The name of the product. | Required |

| description | string | A detailed description of the product. | Optional |

| price | number | The price of the product. | Required |

| currency | string | The currency of the product price (e.g., USD, EUR). | Required |

| category | string | The product category. | Required |

| sku | string | Stock Keeping Unit (must be unique). | Required |

| stock | integer | The current stock level. (Default: 0) | Optional |

| imageUrl | string | URL of the product image. | Optional |

##### Request Example


curl -X POST \
  https://api.pantherahive.com/v1/products \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -d '{
        "name": "Smart Home Hub",
        "description": "Central control unit for smart home devices.",
        "price": 79.99,
        "currency": "USD",
        "category": "smart_home",
        "sku": "SH-HUB-001",
        "stock": 200,
        "imageUrl": "https://cdn.pantherahive.com/images/smart_hub.jpg"
      }'

##### Response Example (201 Created)


HTTP/1.1 201 Created
Content-Type: application/json

{
  "id": "prod_abcde",
  "name": "Smart Home Hub",
  "description": "Central control unit for smart home devices.",
  "price": 79.99,
  "currency": "USD",
  "category": "smart_home",
  "sku": "SH-HUB-001",
  "stock": 200,
  "imageUrl": "https://cdn.pantherahive.com/images/smart_hub.jpg",
  "createdAt": "2023-10-27T15:30:00Z",
  "updatedAt": "2023-10-27T15:30:00Z"
}

6.4. Update an Existing Product

Modify details for an existing product.

  • URL: /products/{productId}
  • Method: PUT
  • Description: Updates an existing product identified by productId. Returns the updated product object.
  • Authentication: Required

##### Parameters

| Name | Type | Description | Required | Location |

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

| productId | string | The unique ID of the product. | Required | Path |

##### Request Body Parameters

All parameters are optional. Only include the fields you wish to update.

| Name | Type | Description | Required |

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

| name | string | The name of the product. | Optional |

| description | string | A detailed description of the product. | Optional |

| price | number | The price of the product. | Optional |

| currency | string | The currency of the product price (e.g., USD, EUR). | Optional |

| category | string | The product category. | Optional |

| sku | string | Stock Keeping Unit (must be unique). | Optional |

| stock | integer | The current stock level. | Optional |

| imageUrl | string | URL of the product image. | Optional |

##### Request Example


curl -X PUT \
  https://api.pantherahive.com/v1/products/prod_abcde \
  -H 'Content-Type: application/json' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -d '{
        "price": 84.99,
        "stock": 180
      }'

##### Response Example (200 OK)


HTTP/1.1 200 OK
Content-Type: application/json

{
  "id": "prod_abcde",
  "name": "Smart Home Hub",
  "description": "Central control unit for smart home devices.",
  "price":
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);}});}