Disaster Recovery Plan
Run ID: 69cb310861b1021a29a86c542026-03-31Infrastructure
PantheraHive BOS
BOS Dashboard

Generate a comprehensive disaster recovery plan with RTO/RPO targets, backup strategies, failover procedures, communication plans, and testing schedules.

This document outlines a comprehensive Disaster Recovery Plan (DRP), designed to ensure business continuity and rapid recovery of critical IT systems and data in the event of a disaster. This plan focuses on minimizing downtime and data loss, adhering to defined recovery objectives, and providing clear, actionable steps for all involved personnel.


Disaster Recovery Plan

1. Introduction and Purpose

The purpose of this Disaster Recovery Plan (DRP) is to provide a structured and actionable framework for responding to and recovering from significant disruptions to critical IT infrastructure and business operations. This plan aims to:

  • Minimize the impact of disasters on business operations.
  • Ensure the timely recovery of critical systems and data.
  • Protect the organization's assets, reputation, and customer trust.
  • Provide clear roles, responsibilities, and procedures during a disaster event.
  • Comply with regulatory and industry best practice requirements.

2. Scope

This DRP covers all critical IT systems, applications, data, and associated infrastructure essential for the continued operation of the organization. This includes, but is not limited to:

  • Core business applications (e.g., ERP, CRM, financial systems).
  • Database servers and data stores.
  • Network infrastructure (firewalls, routers, switches).
  • Virtualization platforms and host servers.
  • Critical end-user services (e.g., email, file shares).
  • Cloud-based services and integrations.

Non-critical systems and data, while important, will be prioritized for recovery after critical systems are restored.

3. Disaster Recovery Team Roles and Responsibilities

A dedicated Disaster Recovery Team (DRT) will be activated in the event of a disaster. Each member has specific roles and responsibilities to ensure an organized and efficient recovery process.

  • DR Coordinator (Incident Manager):

* Declares a disaster and initiates the DRP.

* Oversees all recovery efforts, communications, and decision-making.

* Primary liaison with senior management and external stakeholders.

  • Technical Lead (Infrastructure/Systems):

* Directs recovery of servers, virtualization, and core infrastructure.

* Manages hardware procurement and setup at recovery site.

* Coordinates with network and application teams.

  • Network Lead:

* Restores network connectivity, VPNs, and security configurations.

* Manages DNS and IP address reconfigurations.

* Ensures secure access to recovered systems.

  • Application Lead:

* Manages the installation, configuration, and testing of critical applications.

* Coordinates with application owners and vendors.

* Ensures application data integrity post-recovery.

  • Data Lead (Database/Storage):

* Oversees data restoration from backups.

* Ensures database integrity and consistency.

* Manages storage systems at the recovery site.

  • Communications Lead:

* Executes internal and external communication plans.

* Maintains contact lists and communication channels.

* Provides regular updates to stakeholders.

  • Business Continuity Lead (Optional, if separate from DR):

* Focuses on non-IT operational recovery (e.g., facilities, personnel relocation).

* Coordinates with IT DR team to ensure alignment of IT and business recovery.

4. Recovery Time Objective (RTO) and Recovery Point Objective (RPO) Targets

RTO and RPO define the acceptable parameters for downtime and data loss for critical systems. These targets are critical for guiding backup strategies, recovery procedures, and technology investments.

| System/Application Category | Description | RTO Target | RPO Target | Justification |

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

| Tier 1: Mission-Critical | Core ERP, Financial Systems, Primary Databases | 2 - 4 Hours | 0 - 15 Minutes | Direct impact on revenue, legal compliance, customer operations. |

| Tier 2: Business-Critical | CRM, Email, File Servers, Key Business Apps | 4 - 8 Hours | 1 - 4 Hours | Significant impact on productivity, customer service, internal ops. |

| Tier 3: Business-Support | Development Environments, Intranet, HR Systems | 12 - 24 Hours | 4 - 24 Hours | Moderate impact, operations can continue with workarounds. |

| Tier 4: Non-Critical | Test Environments, Archival Data | 24 - 48+ Hours | 24 - 48+ Hours | Minimal operational impact, can be recovered at lower priority. |

Definitions:

  • RTO (Recovery Time Objective): The maximum tolerable duration of time that a system, application, or service can be down after a disaster before unacceptable consequences occur.
  • RPO (Recovery Point Objective): The maximum tolerable amount of data loss, measured in time, that can be accepted after a disaster event.

5. Incident Response and Activation Procedures

Upon detection of a potential disaster, the following steps will be taken:

  1. Incident Detection & Assessment:

* Monitoring systems (NOC, SIEM) alert on critical failures.

* Initial assessment by IT Operations to determine scope and impact.

* Confirm if the incident meets disaster criteria (e.g., prolonged outage, data loss, facility loss).

  1. Disaster Declaration:

* The DR Coordinator (or designated alternate) declares a disaster based on assessment.

* Notification sent to the DR Team and key stakeholders.

  1. DR Team Activation:

* DR Team members are notified via primary (e.g., phone call, dedicated DR chat) and secondary (e.g., email, SMS) channels.

* Team convenes at the designated command center (physical or virtual).

  1. Initial Communication:

* Internal stakeholders (senior management, department heads) are informed.

* External communication plan initiated if required (e.g., customers, media).

  1. Plan Execution:

* DR Coordinator assigns tasks based on the DRP sections (backup, failover, recovery).

* Teams begin executing recovery procedures.

6. Backup and Data Recovery Strategies

A multi-layered backup strategy ensures data availability and integrity, meeting defined RPO targets.

6.1. Backup Types and Frequencies:

  • Full Backups: Complete copy of all selected data.

* Frequency: Weekly (e.g., Sunday night).

* Retention: 4 weeks on-site, 12 months off-site.

  • Incremental Backups: Only data changed since the last full or incremental backup.

* Frequency: Daily (e.g., Monday-Saturday nights).

* Retention: 4 weeks on-site.

  • Differential Backups: All data changed since the last full backup.

* Frequency: Daily (alternative to incremental, depending on system).

* Retention: 4 weeks on-site.

  • Database Transaction Logs: For Tier 1 databases, continuous archiving or replication.

* Frequency: Every 5-15 minutes (or continuous).

* Retention: Aligned with RPO, typically 24-48 hours of logs for point-in-time recovery.

  • Cloud Snapshots/Replication: For critical cloud-native services or VMs.

* Frequency: Automated snapshots every 1-4 hours, continuous replication for critical databases.

* Retention: Configured per cloud provider policy and RPO.

6.2. Backup Storage Locations:

  • On-site Storage:

* Dedicated NAS/SAN for immediate recovery.

* Used for daily and weekly backups.

* Ensures fast recovery for minor incidents.

  • Off-site Storage (Primary):

* Secure, geographically separated data center or cloud storage.

* Used for weekly full backups and monthly archives.

* Protects against site-wide disasters.

* Encryption: All data at rest and in transit is encrypted (AES-256).

  • Off-site Storage (Secondary/Archival):

* Long-term archival storage (e.g., Glacier, tape library).

* Used for regulatory compliance and historical data.

* Retention periods defined by data governance policies.

6.3. Data Recovery Procedures:

  1. Identify Required Restore Point: Based on RPO and incident details.
  2. Locate Backup Media/Image: Retrieve from appropriate storage location.
  3. Restore Data to Recovery Environment:

* For file servers: Mount backup and copy data.

* For databases: Restore full backup, then apply transaction logs to desired point-in-time.

* For virtual machines: Restore VM image to hypervisor.

  1. Verify Data Integrity: Perform checksums, run integrity checks, and validate against known good data.
  2. Application Data Consistency: Work with Application Lead to ensure restored data is consistent with application requirements.

7. Failover and System Recovery Procedures

These procedures detail the steps to restore critical systems and applications at the designated recovery site.

7.1. Recovery Site Strategy:

  • Primary Recovery Site: (e.g., AWS Region B, Azure Region East 2)

* Type: Hot/Warm Standby (depending on Tier).

* Details: Pre-provisioned infrastructure, network, and security services. Critical applications have standby instances or regularly updated images ready for activation.

* Connectivity: VPN tunnels, direct connect, or secure internet access.

  • Secondary Recovery Site (Optional): (e.g., AWS Region C, Azure Region West 2)

* Type: Cold/Warm Standby.

* Details: Minimal infrastructure, used if primary recovery site is also affected. Longer RTO.

7.2. General System Recovery Steps:

  1. Establish Network Connectivity:

* Activate recovery site network infrastructure (routers, firewalls, switches).

* Reconfigure DNS to point to recovery site IPs.

* Establish secure VPN access for DR Team and remote users.

  1. Restore Core Infrastructure:

* Bring up directory services (e.g., Active Directory, LDAP).

* Restore monitoring and management tools.

* Provision new virtual machines or instances as required.

  1. Database Recovery (Tier 1 & 2):

* Activate replicated database instances or restore from latest backup.

* Apply transaction logs to achieve RPO.

* Perform database consistency checks and integrity tests.

  1. Application Recovery (Tier 1 & 2):

* Install/configure critical applications on recovered servers/instances.

* Restore application-specific configurations and data.

* Connect applications to recovered databases.

* Perform functional testing of applications.

  1. User Access Restoration:

* Verify user authentication and authorization.

* Provide instructions for accessing recovered systems (e.g., new URLs, VPN details).

7.3. Specific Failover Procedures (Example - ERP System):

  1. Confirm Primary System Outage: Validate total loss of primary ERP instance.
  2. Activate Recovery Site ERP Environment:

* Spin up pre-provisioned ERP application servers (e.g., VM templates).

* Ensure network connectivity and security group rules are correct.

  1. Database Failover/Recovery:

* If using database replication (e.g., AlwaysOn Availability Groups, RDS Multi-AZ), perform failover to the secondary replica.

* If using backups, restore the latest full backup and apply transaction logs to the designated RPO.

* Verify database integrity and synchronization.

  1. Application Configuration:

* Update ERP application configuration to point to the recovered database instance.

* Configure any necessary integrations or middleware.

  1. Functional Testing:

* Log in with test accounts.

* Perform critical transactions (e.g., order entry, financial posting).

* Verify data accuracy and system responsiveness.

  1. User Communication:

* Inform users of the successful failover and new access details (if any).

* Provide status updates on non-critical functionalities.

8. Communication Plan

Effective communication is paramount during a disaster. This plan outlines who communicates what, when, and through which channels.

8.1. Internal Communication:

  • Initial Notification (DR Team):

* Who: DR Coordinator.

* To: All DR Team members, Senior Management.

* When: Immediately upon disaster declaration.

* How: Dedicated DR Call Tree (primary phone), SMS, dedicated secure chat channel.

  • Status Updates (DR Team to Management):

* Who: DR Coordinator.

* To: Senior Management, Department Heads.

* When: Every 2 hours during active recovery, or as significant milestones are reached.

* How: Email, virtual meeting (e.g., Zoom/Teams), dedicated status page.

  • Employee Updates:

* Who: Communications Lead.

* To: All Employees.

* When: As soon as initial assessment is complete, then every 4-6 hours.

* How: Company-wide email (using an external email service if internal is down), company website banner, dedicated status portal, internal messaging system (e.g., Slack/Teams if available).

  • Department-Specific Information:

* Who: Department Heads (informed by DR Coordinator).

* To: Their respective teams.

* When: As needed, providing specific instructions relevant to their operations.

* How: Team meetings, internal emails.

8.2. External Communication:

  • Customer Communication:

* Who: Communications Lead (approved by DR Coordinator/CEO).

* To: All Customers.

* When: Within 1-2 hours of disaster declaration, then as needed.

* How: Public website banner, dedicated status page, email blast (using external marketing platform), social media (if appropriate).

* Content: Acknowledge the issue, state steps being taken, provide expected recovery times (if known), and direct to status page for updates. Avoid technical jargon.

  • Vendor/Partner Communication:

* Who: DR Coordinator or designated Technical Lead.

* To: Critical vendors (e.g., cloud providers, ISPs, hardware suppliers).

* When: As soon as their services are impacted or required for recovery.

* How: Direct phone call, vendor support portals.

  • Regulatory/Legal (if applicable):

* Who: Legal Counsel (with DR Coordinator/CEO).

* To: Relevant regulatory bodies.

* When: As required by law or contract.

* How: Prescribed channels (e.g., official notifications, secure portals).

  • Media Inquiries:

* Who: Designated Spokesperson (e.g., CEO, Head of PR).

* To: Media.

* When: Only if absolutely necessary and pre-approved.

* How: Official press release, controlled statements. All other employees are strictly forbidden from speaking to the media.

8.3. Communication Tools and Channels:

  • Primary: Dedicated conference bridge, secure chat application (e.g., Slack/Teams), mobile phones.
  • Secondary: Email (external provider), SMS, public status page.
  • Emergency Contact List: Maintained in both digital (cloud-based) and physical (printed, off-site) formats.
gemini Output

Disaster Recovery Plan

Document Version: 1.0

Date: October 26, 2023

Prepared For: [Customer Name/Organization]

Prepared By: PantheraHive


1. Executive Summary

This Disaster Recovery Plan (DRP) outlines the strategies, procedures, and responsibilities for restoring critical business operations and IT infrastructure in the event of a disruptive incident. The primary goal of this DRP is to minimize downtime, prevent data loss, and ensure business continuity by defining clear Recovery Time Objectives (RTOs) and Recovery Point Objectives (RPOs). This plan covers essential systems, data backup strategies, failover and failback procedures, communication protocols, and a robust testing schedule to ensure readiness and effectiveness.

2. Introduction

2.1. Purpose

The purpose of this Disaster Recovery Plan is to provide a comprehensive, actionable framework to guide the organization's response to and recovery from major disruptions, including natural disasters, cyberattacks, significant hardware failures, or other unforeseen events. This plan aims to:

  • Minimize the impact of disasters on critical business functions.
  • Ensure the rapid and orderly recovery of essential IT systems and data.
  • Protect the organization's reputation and financial stability.
  • Comply with regulatory requirements and industry best practices.

2.2. Scope

This DRP applies to all critical IT infrastructure, applications, data, and personnel involved in their operation and recovery. It covers:

  • On-premise servers, network devices, and storage.
  • Cloud-based services and applications critical to business operations.
  • Key business data, including databases, file shares, and applications data.
  • Personnel responsible for incident response, recovery, and communication.

2.3. Assumptions

This plan is developed based on the following assumptions:

  • Key personnel are adequately trained and available during a disaster.
  • Off-site backup data is secure, accessible, and recoverable.
  • Necessary vendor support and service level agreements (SLAs) are in place.
  • Hardware and software licenses for recovery environments are available.
  • Communication infrastructure (e.g., cell networks, satellite phones) may be partially or fully disrupted in a widespread disaster.

3. Objectives

The primary objectives of this Disaster Recovery Plan are to:

  • Achieve defined RTOs and RPOs: Restore critical systems and data within pre-defined timeframes and with minimal data loss.
  • Ensure data integrity: Recover data in a consistent and uncorrupted state.
  • Maintain business continuity: Enable the organization to continue essential operations, even in a degraded state, during a disaster.
  • Provide clear guidance: Offer step-by-step procedures for disaster declaration, response, recovery, and failback.
  • Facilitate effective communication: Establish clear communication channels and protocols for internal and external stakeholders.
  • Validate effectiveness: Regularly test and update the plan to ensure its continued relevance and efficacy.

4. Key Personnel and Responsibilities

A dedicated Disaster Recovery Team (DRT) is established to manage and execute the DRP.

4.1. Disaster Recovery Team Roles and Responsibilities

| Role | Primary Responsibilities | Backup Contact (if applicable) |

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

| DR Coordinator | Overall plan activation, coordination, decision-making, communication oversight. | [Name/Role] |

| IT Infrastructure Lead | Oversees server, network, and storage recovery; manages technical teams. | [Name/Role] |

| Applications Lead | Manages application-specific recovery, data restoration, and user access. | [Name/Role] |

| Data Recovery Lead | Focuses on database recovery, data integrity checks, and data synchronization. | [Name/Role] |

| Network Lead | Manages network connectivity, firewall configurations, VPNs, and DNS resolution at recovery site. | [Name/Role] |

| Communications Lead | Executes internal and external communication plans, manages PR. | [Name/Role] |

| Business Unit Leads | Provide business context, prioritize application/data recovery for their units, coordinate user testing. | [Name/Role] |

| Security Lead | Ensures security protocols are maintained during recovery, manages incident response for security breaches. | [Name/Role] |

4.2. Emergency Contact Information

A full, up-to-date emergency contact list for all DRT members, critical vendors, and external services (e.g., utility companies, law enforcement) will be maintained in Appendix A and an accessible, off-site location (e.g., secure cloud document, physical binder at DR site).

5. Business Impact Analysis (BIA) Summary & Critical Systems

The following table summarizes critical systems and applications identified through the Business Impact Analysis (BIA), along with their interdependencies and data classifications.

| System/Application ID | System/Application Name | Description of Function | Criticality (High/Med/Low) | Interdependencies | Data Classification (Confidential/Internal/Public) |

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

| APP-001 | ERP System | Core financial, inventory, and order management | High | Database Server, Web Server, Network Infrastructure | Confidential |

| APP-002 | CRM System | Customer relationship management, sales tracking | High | Database Server, Web Server, Email Service | Confidential |

| APP-003 | Email Service | Internal and external communication | High | Active Directory, Network Infrastructure | Internal |

| APP-004 | File Server | Document storage and sharing | Medium | Active Directory, Network Infrastructure | Internal |

| APP-005 | Web Server (Public) | Public-facing website | Medium | Database Server (for dynamic content), Network | Public |

| DB-001 | Primary Database Server | Hosts databases for ERP, CRM, and other applications | High | All dependent applications, Storage Infrastructure | Confidential |

| AD-001 | Active Directory | User authentication, authorization, network services | High | All applications, Network Infrastructure | Internal |

6. Recovery Time Objectives (RTO) and Recovery Point Objectives (RPO)

RTO defines the maximum tolerable duration that a system or application can be down following a disaster. RPO defines the maximum tolerable amount of data that can be lost following a disaster.

| System/Application ID | System/Application Name | Recovery Time Objective (RTO) | Recovery Point Objective (RPO) | Notes

gemini Output

Disaster Recovery Plan (DRP)

Version: 1.0

Date: October 26, 2023

Prepared For: [Customer Name/Organization]


1. Executive Summary

This Disaster Recovery Plan (DRP) outlines the strategies, procedures, and resources necessary to minimize the impact of a disaster on critical business operations and information systems. The primary goal is to ensure the timely and orderly recovery of essential IT services and data, enabling the organization to resume business functions within acceptable timeframes and data loss limits. This document covers key areas including RTO/RPO targets, backup strategies, failover procedures, communication plans, and a robust testing schedule to ensure the plan's effectiveness and currency.

2. Scope

This DRP covers all critical IT infrastructure, applications, and data essential for the continuous operation of [Customer Name/Organization]'s core business functions. This includes, but is not limited to:

  • Core Business Applications: [List specific applications, e.g., ERP, CRM, E-commerce platform, Financial Systems]
  • Data Repositories: Databases, file servers, document management systems.
  • Network Infrastructure: Routers, switches, firewalls, VPNs.
  • Server Infrastructure: Physical and virtual servers, operating systems.
  • Communication Systems: Email, VoIP, collaboration platforms.
  • Critical User Data: User profiles, shared drives.

Exclusions: This plan does not cover personal devices not managed by the organization or non-critical, non-production environments unless explicitly stated.

3. Key Objectives

The objectives of this DRP are to:

  • Minimize downtime and data loss following a disruptive event.
  • Ensure the rapid recovery of critical business functions and IT services.
  • Protect the organization's assets, reputation, and customer trust.
  • Establish clear roles, responsibilities, and communication channels during a disaster.
  • Comply with regulatory requirements and industry best practices.
  • Provide a framework for regular testing, review, and maintenance of recovery capabilities.

4. Roles and Responsibilities

A dedicated Disaster Recovery Team (DRT) will be activated to manage and execute the DRP.

4.1 Disaster Recovery Team (DRT) Structure

| Role | Primary Contact | Alternate Contact | Key Responsibilities

disaster_recovery_plan.md
Download as Markdown
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
\n\n\n"); 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'\nimport ReactDOM from 'react-dom/client'\nimport App from './App'\nimport './index.css'\n\nReactDOM.createRoot(document.getElementById('root')!).render(\n \n \n \n)\n"); 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'\nimport './App.css'\n\nfunction App(){\n return(\n
\n
\n

"+slugTitle(pn)+"

\n

Built with PantheraHive BOS

\n
\n
\n )\n}\nexport default App\n"); zip.file(folder+"src/index.css","*{margin:0;padding:0;box-sizing:border-box}\nbody{font-family:system-ui,-apple-system,sans-serif;background:#f0f2f5;color:#1a1a2e}\n.app{min-height:100vh;display:flex;flex-direction:column}\n.app-header{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:12px;padding:40px}\nh1{font-size:2.5rem;font-weight:700}\n"); 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)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nnpm run dev\n\`\`\`\n\n## Build\n\`\`\`bash\nnpm run build\n\`\`\`\n\n## Open in IDE\nOpen the project folder in VS Code or WebStorm.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n"); } /* --- 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",'{\n "name": "'+pn+'",\n "version": "0.0.0",\n "type": "module",\n "scripts": {\n "dev": "vite",\n "build": "vue-tsc -b && vite build",\n "preview": "vite preview"\n },\n "dependencies": {\n "vue": "^3.5.13",\n "vue-router": "^4.4.5",\n "pinia": "^2.3.0",\n "axios": "^1.7.9"\n },\n "devDependencies": {\n "@vitejs/plugin-vue": "^5.2.1",\n "typescript": "~5.7.3",\n "vite": "^6.0.5",\n "vue-tsc": "^2.2.0"\n }\n}\n'); zip.file(folder+"vite.config.ts","import { defineConfig } from 'vite'\nimport vue from '@vitejs/plugin-vue'\nimport { resolve } from 'path'\n\nexport default defineConfig({\n plugins: [vue()],\n resolve: { alias: { '@': resolve(__dirname,'src') } }\n})\n"); zip.file(folder+"tsconfig.json",'{"files":[],"references":[{"path":"./tsconfig.app.json"},{"path":"./tsconfig.node.json"}]}\n'); zip.file(folder+"tsconfig.app.json",'{\n "compilerOptions":{\n "target":"ES2020","useDefineForClassFields":true,"module":"ESNext","lib":["ES2020","DOM","DOM.Iterable"],\n "skipLibCheck":true,"moduleResolution":"bundler","allowImportingTsExtensions":true,\n "isolatedModules":true,"moduleDetection":"force","noEmit":true,"jsxImportSource":"vue",\n "strict":true,"paths":{"@/*":["./src/*"]}\n },\n "include":["src/**/*.ts","src/**/*.d.ts","src/**/*.tsx","src/**/*.vue"]\n}\n'); zip.file(folder+"env.d.ts","/// \n"); zip.file(folder+"index.html","\n\n\n \n \n "+slugTitle(pn)+"\n\n\n
\n \n\n\n"); 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'\nimport { createPinia } from 'pinia'\nimport App from './App.vue'\nimport './assets/main.css'\n\nconst app = createApp(App)\napp.use(createPinia())\napp.mount('#app')\n"); var hasApp=Object.keys(extracted).some(function(k){return k.indexOf("App.vue")>=0;}); if(!hasApp) zip.file(folder+"src/App.vue","\n\n\n\n\n"); 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}\n"); 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)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nnpm run dev\n\`\`\`\n\n## Build\n\`\`\`bash\nnpm run build\n\`\`\`\n\nOpen in VS Code or WebStorm.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n"); } /* --- 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",'{\n "name": "'+pn+'",\n "version": "0.0.0",\n "scripts": {\n "ng": "ng",\n "start": "ng serve",\n "build": "ng build",\n "test": "ng test"\n },\n "dependencies": {\n "@angular/animations": "^19.0.0",\n "@angular/common": "^19.0.0",\n "@angular/compiler": "^19.0.0",\n "@angular/core": "^19.0.0",\n "@angular/forms": "^19.0.0",\n "@angular/platform-browser": "^19.0.0",\n "@angular/platform-browser-dynamic": "^19.0.0",\n "@angular/router": "^19.0.0",\n "rxjs": "~7.8.0",\n "tslib": "^2.3.0",\n "zone.js": "~0.15.0"\n },\n "devDependencies": {\n "@angular-devkit/build-angular": "^19.0.0",\n "@angular/cli": "^19.0.0",\n "@angular/compiler-cli": "^19.0.0",\n "typescript": "~5.6.0"\n }\n}\n'); zip.file(folder+"angular.json",'{\n "$schema": "./node_modules/@angular/cli/lib/config/schema.json",\n "version": 1,\n "newProjectRoot": "projects",\n "projects": {\n "'+pn+'": {\n "projectType": "application",\n "root": "",\n "sourceRoot": "src",\n "prefix": "app",\n "architect": {\n "build": {\n "builder": "@angular-devkit/build-angular:application",\n "options": {\n "outputPath": "dist/'+pn+'",\n "index": "src/index.html",\n "browser": "src/main.ts",\n "tsConfig": "tsconfig.app.json",\n "styles": ["src/styles.css"],\n "scripts": []\n }\n },\n "serve": {"builder":"@angular-devkit/build-angular:dev-server","configurations":{"production":{"buildTarget":"'+pn+':build:production"},"development":{"buildTarget":"'+pn+':build:development"}},"defaultConfiguration":"development"}\n }\n }\n }\n}\n'); zip.file(folder+"tsconfig.json",'{\n "compileOnSave": false,\n "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"]},\n "references":[{"path":"./tsconfig.app.json"}]\n}\n'); zip.file(folder+"tsconfig.app.json",'{\n "extends":"./tsconfig.json",\n "compilerOptions":{"outDir":"./dist/out-tsc","types":[]},\n "files":["src/main.ts"],\n "include":["src/**/*.d.ts"]\n}\n'); zip.file(folder+"src/index.html","\n\n\n \n "+slugTitle(pn)+"\n \n \n \n\n\n \n\n\n"); zip.file(folder+"src/main.ts","import { bootstrapApplication } from '@angular/platform-browser';\nimport { appConfig } from './app/app.config';\nimport { AppComponent } from './app/app.component';\n\nbootstrapApplication(AppComponent, appConfig)\n .catch(err => console.error(err));\n"); zip.file(folder+"src/styles.css","* { margin: 0; padding: 0; box-sizing: border-box; }\nbody { font-family: system-ui, -apple-system, sans-serif; background: #f9fafb; color: #111827; }\n"); 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';\nimport { RouterOutlet } from '@angular/router';\n\n@Component({\n selector: 'app-root',\n standalone: true,\n imports: [RouterOutlet],\n templateUrl: './app.component.html',\n styleUrl: './app.component.css'\n})\nexport class AppComponent {\n title = '"+pn+"';\n}\n"); zip.file(folder+"src/app/app.component.html","
\n
\n

"+slugTitle(pn)+"

\n

Built with PantheraHive BOS

\n
\n \n
\n"); 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}\n"); } zip.file(folder+"src/app/app.config.ts","import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';\nimport { provideRouter } from '@angular/router';\nimport { routes } from './app.routes';\n\nexport const appConfig: ApplicationConfig = {\n providers: [\n provideZoneChangeDetection({ eventCoalescing: true }),\n provideRouter(routes)\n ]\n};\n"); zip.file(folder+"src/app/app.routes.ts","import { Routes } from '@angular/router';\n\nexport const routes: Routes = [];\n"); 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)+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\nng serve\n# or: npm start\n\`\`\`\n\n## Build\n\`\`\`bash\nng build\n\`\`\`\n\nOpen in VS Code with Angular Language Service extension.\n"); zip.file(folder+".gitignore","node_modules/\ndist/\n.env\n.DS_Store\n*.local\n.angular/\n"); } /* --- Python --- */ function buildPython(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^\`\`\`[\w]*\n?/m,"").replace(/\n?\`\`\`$/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("\n"):"# add dependencies here\n"; zip.file(folder+"main.py",src||"# "+title+"\n# Generated by PantheraHive BOS\n\nprint(title+\" loaded\")\n"); zip.file(folder+"requirements.txt",reqsTxt); zip.file(folder+".env.example","# Environment variables\n"); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\npython3 -m venv .venv\nsource .venv/bin/activate\npip install -r requirements.txt\n\`\`\`\n\n## Run\n\`\`\`bash\npython main.py\n\`\`\`\n"); zip.file(folder+".gitignore",".venv/\n__pycache__/\n*.pyc\n.env\n.DS_Store\n"); } /* --- Node.js --- */ function buildNode(zip,folder,app,code){ var title=slugTitle(app); var pn=pkgName(app); var src=code.replace(/^\`\`\`[\w]*\n?/m,"").replace(/\n?\`\`\`$/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)+"\n"; zip.file(folder+"package.json",pkgJson); var fallback="const express=require(\"express\");\nconst app=express();\napp.use(express.json());\n\napp.get(\"/\",(req,res)=>{\n res.json({message:\""+title+" API\"});\n});\n\nconst PORT=process.env.PORT||3000;\napp.listen(PORT,()=>console.log(\"Server on port \"+PORT));\n"; zip.file(folder+"src/index.js",src||fallback); zip.file(folder+".env.example","PORT=3000\n"); zip.file(folder+".gitignore","node_modules/\n.env\n.DS_Store\n"); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Setup\n\`\`\`bash\nnpm install\n\`\`\`\n\n## Run\n\`\`\`bash\nnpm run dev\n\`\`\`\n"); } /* --- 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:"\n\n\n\n\n"+title+"\n\n\n\n"+code+"\n\n\n\n"; zip.file(folder+"index.html",indexHtml); zip.file(folder+"style.css","/* "+title+" — styles */\n*{margin:0;padding:0;box-sizing:border-box}\nbody{font-family:system-ui,-apple-system,sans-serif;background:#fff;color:#1a1a2e}\n"); zip.file(folder+"script.js","/* "+title+" — scripts */\n"); zip.file(folder+"assets/.gitkeep",""); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\n## Open\nDouble-click \`index.html\` in your browser.\n\nOr serve locally:\n\`\`\`bash\nnpx serve .\n# or\npython3 -m http.server 3000\n\`\`\`\n"); zip.file(folder+".gitignore",".DS_Store\nnode_modules/\n.env\n"); } /* ===== 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(/\n{2,}/g,"

"); h+="

"+hc+"

Generated by PantheraHive BOS
"; zip.file(folder+app+".html",h); zip.file(folder+"README.md","# "+title+"\n\nGenerated by PantheraHive BOS.\n\nFiles:\n- "+app+".md (Markdown)\n- "+app+".html (styled HTML)\n"); } 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);}});}