Full Stack App Blueprint
Run ID: 69caf90f26e01bf7c6786f172026-03-30Development
PantheraHive BOS
BOS Dashboard

This document provides a comprehensive blueprint for a full-stack application, complete with a robust technology stack, detailed architectural design, code examples for key components, and essential configurations for deployment and testing. This blueprint is designed to be a ready-to-build foundation for your application.


Full Stack Application Blueprint

1. Project Overview & Goals

This blueprint outlines a scalable and maintainable full-stack application. The primary goal is to provide a solid foundation that enforces best practices in development, security, and deployment, enabling rapid development of features while ensuring long-term stability and performance.

Key Features Addressed:

2. Technology Stack

A carefully selected technology stack provides a balance of performance, developer experience, and community support.

* React: A declarative, component-based JavaScript library for building user interfaces.

* TypeScript: Adds static typing to JavaScript, enhancing code quality, maintainability, and developer tooling.

* Vite: A fast build tool that provides an excellent developer experience.

* Tailwind CSS: A utility-first CSS framework for rapidly building custom designs.

* Node.js (Express.js): A fast, unopinionated, minimalist web framework for Node.js, ideal for building REST APIs.

* TypeScript: Ensures type safety and improves code quality for the backend services.

* Prisma: A next-generation ORM that makes database access easy and type-safe, integrating perfectly with TypeScript.

* JWT (JSON Web Tokens): For secure, stateless authentication.

* bcrypt: For secure password hashing.

* PostgreSQL: A powerful, open-source object-relational database system known for its reliability, feature robustness, and performance.

* Docker: For containerizing both frontend and backend applications, ensuring consistent environments from development to production.

* Docker Compose: For orchestrating multi-container Docker applications (e.g., frontend, backend, database).

* Jest: A delightful JavaScript testing framework used for both frontend (unit/component) and backend (unit/integration) tests.

* React Testing Library: For testing React components in a user-centric way.

3. Application Architecture

The application follows a client-server architecture with a clear separation of concerns, enabling independent development and scaling of frontend and backend services.

text • 1,389 chars
+------------------+             +-------------------+             +------------------+
|    Frontend      |             |     Backend API   |             |     Database     |
| (React/TypeScript)|             | (Node.js/Express) |             |    (PostgreSQL)  |
|------------------|             |-------------------|             |------------------|
| - Components     | <---------> | - Routes          | <---------> | - Tables         |
| - Pages          |   HTTP/REST | - Controllers     |   Prisma    | - Relationships  |
| - State Mgmt     |             | - Services        |             | - Data           |
| - Routing        |             | - Models (Prisma) |             |                  |
| - Authentication |             | - Middleware      |             |                  |
+------------------+             | - Authentication  |             +------------------+
                                 +-------------------+
                                         ^
                                         |
                                         v
                                  +-----------------+
                                  |   External      |
                                  |   Services      |
                                  | (e.g., Email,   |
                                  |   Payment Gate) |
                                  +-----------------+
Sandboxed live preview

This output details the comprehensive application blueprint, outlining the architectural plan for a full-stack application. It covers frontend, backend, database, authentication, deployment, and testing strategies, providing a solid foundation for development.


Full Stack Application Blueprint: PantheraHub - A Collaborative Project & Task Management Platform

1. Application Overview & Vision

PantheraHub is envisioned as a robust, intuitive, and collaborative platform designed to empower teams to manage projects, tasks, and communications effectively. It aims to streamline workflows, enhance team collaboration, and provide clear visibility into project progress.

Key Features:

  • Project Management: Create, organize, and manage multiple projects.
  • Task Management: Assign tasks, set deadlines, track progress, and define priorities.
  • User & Team Management: Invite team members, define roles (e.g., Admin, Project Manager, Member).
  • Real-time Updates: Instant notifications for task assignments, status changes, and comments.
  • Commenting & Discussion: Facilitate communication directly on tasks and projects.
  • File Attachment: Attach relevant documents, images, or files to tasks/projects.
  • Dashboard & Reporting: Overview of project statuses, personal tasks, and team workload.
  • Search & Filtering: Easily find projects, tasks, and users.

Target Audience: Small to medium-sized businesses, agile development teams, marketing agencies, and remote teams requiring a centralized platform for project coordination.

2. Architectural Style

We will adopt a Modular Monolith architecture for the backend API, leveraging a well-structured codebase that can be logically separated into domains (e.g., Users, Projects, Tasks). This approach offers the benefits of a single deployment unit (simpler initial development and deployment) while maintaining modularity for easier maintenance and potential future decomposition into microservices if scaling demands it.

The frontend will be a Single Page Application (SPA), providing a rich, interactive user experience with fast transitions and reduced server load after initial page load.

3. Frontend Architecture (Client-Side)

  • Framework/Library: React.js (version 18+)

* Rationale: Widely adopted, strong community support, component-based architecture, excellent for building complex UIs.

  • State Management: React Query for server-state management (data fetching, caching, synchronization) combined with Zustand for global client-side state (e.g., UI preferences, modals).

* Rationale: React Query simplifies data handling from the API, reduces boilerplate, and provides excellent performance optimizations. Zustand is lightweight and easy to use for local state.

  • Routing: React Router DOM (v6)

* Rationale: Standard library for declarative routing in React applications.

  • Styling: Tailwind CSS with PostCSS

* Rationale: Utility-first CSS framework for rapid UI development, highly customizable, and produces small CSS bundles. PostCSS for processing and optimizing CSS.

  • Component Structure: Atomic Design Principles

* Organizing components into Atoms, Molecules, Organisms, Templates, and Pages for reusability, maintainability, and scalability.

  • Form Management: React Hook Form with Zod for schema validation.

* Rationale: Performance-optimized, flexible form library with strong validation capabilities.

  • Build Tool: Vite

* Rationale: Extremely fast development server and build tool, offering a superior developer experience compared to Webpack for many projects.

  • Internationalization (Optional but Recommended): react-i18next
  • Accessibility: Adhere to WCAG guidelines, use semantic HTML, and ARIA attributes where necessary.

4. Backend API Architecture (Server-Side)

  • Language & Framework: Node.js with NestJS (TypeScript-first framework)

* Rationale: Node.js for its non-blocking I/O and JavaScript ecosystem. NestJS provides a robust, opinionated, and highly structured framework inspired by Angular, promoting maintainable and scalable server-side applications with strong TypeScript support.

  • API Style: RESTful API

* Rationale: Industry standard, well-understood, and flexible for resource-oriented interactions.

  • Data Serialization: JSON
  • Database ORM: TypeORM

* Rationale: Feature-rich ORM that supports various databases (PostgreSQL, MySQL, etc.) and works seamlessly with TypeScript and NestJS decorators for entity definition.

  • Error Handling: Centralized, standardized error handling middleware that returns consistent JSON error responses (e.g., HTTP status codes 4xx for client errors, 5xx for server errors).
  • Validation: Class-validator integrated with NestJS pipes.
  • Middleware:

* Logging (e.g., Winston, Pino)

* CORS handling

* Security headers (Helmet)

* Rate limiting (express-rate-limit)

  • Project Structure (NestJS Modules):

* src/modules/auth

* src/modules/users

* src/modules/projects

* src/modules/tasks

* src/modules/comments

* src/modules/files

* src/shared (common utilities, DTOs, interfaces)

* Each module will contain its controllers, services, repositories, and DTOs.

5. Database Design

  • Database Type: PostgreSQL

* Rationale: Robust, open-source, highly reliable relational database, excellent for data integrity, complex queries, and ACID compliance.

  • Schema Design (Example Entities & Relationships):

* User Table:

* id (UUID, PK)

* email (VARCHAR, UNIQUE, NOT NULL)

* password_hash (VARCHAR, NOT NULL)

* first_name (VARCHAR, NOT NULL)

* last_name (VARCHAR, NOT NULL)

* profile_picture_url (VARCHAR, NULL)

* role (ENUM: 'ADMIN', 'PROJECT_MANAGER', 'MEMBER', NOT NULL, DEFAULT 'MEMBER')

* created_at (TIMESTAMP, NOT NULL, DEFAULT CURRENT_TIMESTAMP)

* updated_at (TIMESTAMP, NOT NULL, DEFAULT CURRENT_TIMESTAMP)

* Project Table:

* id (UUID, PK)

* name (VARCHAR, NOT NULL)

* description (TEXT, NULL)

* status (ENUM: 'PLANNING', 'IN_PROGRESS', 'COMPLETED', 'ARCHIVED', NOT NULL, DEFAULT 'PLANNING')

* start_date (DATE, NULL)

* end_date (DATE, NULL)

* created_by_user_id (UUID, FK to User.id, NOT NULL)

* created_at (TIMESTAMP, NOT NULL, DEFAULT CURRENT_TIMESTAMP)

* updated_at (TIMESTAMP, NOT NULL, DEFAULT CURRENT_TIMESTAMP)

* ProjectMember (Junction Table for Many-to-Many between User and Project):

* user_id (UUID, FK to User.id, PK)

* project_id (UUID, FK to Project.id, PK)

* role (ENUM: 'PROJECT_MANAGER', 'MEMBER', NOT NULL, DEFAULT 'MEMBER')

* joined_at (TIMESTAMP, NOT NULL, DEFAULT CURRENT_TIMESTAMP)

* Task Table:

* id (UUID, PK)

* title (VARCHAR, NOT NULL)

* description (TEXT, NULL)

* status (ENUM: 'TODO', 'IN_PROGRESS', 'DONE', 'BLOCKED', NOT NULL, DEFAULT 'TODO')

* priority (ENUM: 'LOW', 'MEDIUM', 'HIGH', NOT NULL, DEFAULT 'MEDIUM')

* due_date (DATE, NULL)

* project_id (UUID, FK to Project.id, NOT NULL)

* assigned_to_user_id (UUID, FK to User.id, NULL)

* created_by_user_id (UUID, FK to User.id, NOT NULL)

* created_at (TIMESTAMP, NOT NULL, DEFAULT CURRENT_TIMESTAMP)

* updated_at (TIMESTAMP, NOT NULL, DEFAULT CURRENT_TIMESTAMP)

* Comment Table:

* id (UUID, PK)

* content (TEXT, NOT NULL)

* task_id (UUID, FK to Task.id, NOT NULL)

* user_id (UUID, FK to User.id, NOT NULL)

* created_at (TIMESTAMP, NOT NULL, DEFAULT CURRENT_TIMESTAMP)

* updated_at (TIMESTAMP, NOT NULL, DEFAULT CURRENT_TIMESTAMP)

* FileAttachment Table:

* id (UUID, PK)

* file_name (VARCHAR, NOT NULL)

* file_url (VARCHAR, NOT NULL)

* mime_type (VARCHAR, NOT NULL)

* size_bytes (INTEGER, NOT NULL)

* task_id (UUID, FK to Task.id, NULL)

* project_id (UUID, FK to Project.id, NULL)

* uploaded_by_user_id (UUID, FK to User.id, NOT NULL)

* uploaded_at (TIMESTAMP, NOT NULL, DEFAULT CURRENT_TIMESTAMP)

  • Migration Strategy: TypeORM Migrations

* Rationale: Ensures database schema changes are version-controlled, repeatable, and easily deployable across environments.

6. Authentication & Authorization

  • Authentication Strategy: JWT (JSON Web Tokens)

* Flow:

1. User registers/logs in with email and password.

2. Backend authenticates credentials, generates an access_token (short-lived) and a refresh_token (long-lived).

3. access_token is sent in the Authorization header for subsequent API requests.

4. refresh_token is stored securely (e.g., HTTP-only cookie) and used to obtain new access_tokens without re-logging in.

* Security:

* Password hashing using Bcrypt.

* JWTs signed with a strong, secret key.

* Refresh tokens invalidated on logout.

* Implement secure cookie practices (HTTP-only, Secure, SameSite=Lax/Strict).

  • Authorization Strategy: Role-Based Access Control (RBAC)

* Roles: ADMIN, PROJECT_MANAGER, MEMBER.

* Implementation: NestJS Guards and Decorators to check user roles and permissions before allowing access to specific routes or resources.

* Example Permissions:

* ADMIN: Full access to all resources, user management.

* PROJECT_MANAGER: Create/manage projects, assign tasks within their projects.

* MEMBER: View assigned tasks, create comments, update own tasks.

7. Deployment Configuration

  • Cloud Provider: AWS (Amazon Web Services)

* Rationale: Comprehensive suite of services, high scalability, reliability, and global reach.

  • Containerization: Docker

* Rationale: Ensures consistent environments across development, testing, and production.

* Docker Compose for local development.

  • Frontend Deployment:

* AWS S3: Host static build files

typescript

// backend/src/modules/auth/auth.service.ts

import bcrypt from 'bcrypt';

import jwt from 'jsonwebtoken';

import prisma from '../../shared/prisma';

import env from '../../config/env';

import { User } from '@prisma/client';

const SALT_ROUNDS = 10;

export class AuthService {

/**

* Registers a new user.

* @param email User's email

* @param password User's plain text password

* @returns The created user object (without password hash)

* @throws Error if user with email already exists

*/

async register(email: string, password: string): Promise<Omit<User, 'passwordHash

gemini Output

Full Stack Application Blueprint: Comprehensive Deliverable

This document provides a comprehensive blueprint for your full-stack application, outlining the architecture, core technologies, design specifications for frontend, backend, database, authentication, deployment, and testing. This blueprint is designed to be actionable, guiding your development team through the build phase with clarity and precision.


1. Project Overview

This blueprint details the technical specifications for a modern, scalable, and secure full-stack application. It encompasses all critical layers from the user interface to the underlying data storage and infrastructure, ensuring a robust foundation ready for development.

Key Objectives of this Blueprint:

  • Define a clear, maintainable, and scalable application architecture.
  • Specify core technologies and frameworks for each application layer.
  • Outline essential frontend components, backend API endpoints, and database schema.
  • Detail the authentication and authorization mechanisms.
  • Propose a robust deployment strategy and CI/CD pipeline.
  • Establish a comprehensive testing strategy.

2. Core Technologies & Stack

We propose a modern, industry-standard technology stack known for its performance, scalability, and developer experience.

  • Frontend Framework: React.js (with Next.js for SSR/SSG capabilities)
  • Frontend Language: TypeScript
  • Frontend Styling: Tailwind CSS
  • Frontend State Management: React Query / Zustand (or Redux Toolkit for complex global state)
  • Backend Framework: NestJS (built on Node.js and TypeScript)
  • Backend Language: TypeScript
  • Database: PostgreSQL (Relational Database)
  • ORM: TypeORM (for NestJS integration)
  • Authentication: JSON Web Tokens (JWT)
  • Deployment & CI/CD: AWS (EC2/ECS, RDS, S3), Docker, GitHub Actions
  • Testing Frameworks: Jest (Unit/Integration), Cypress (E2E)

3. Application Architecture

The application will follow a decoupled, microservices-oriented (or modular monolithic) architecture, separating the frontend client from the backend API. This allows for independent development, scaling, and deployment of each layer.

  • Client-Side Rendering (CSR) / Server-Side Rendering (SSR) / Static Site Generation (SSG): Next.js will enable a hybrid approach, optimizing for performance (SSR/SSG for initial load) and interactivity (CSR for subsequent navigations).
  • API-Driven Backend: The backend will expose a RESTful API, serving data to the frontend and potentially other clients.
  • Database Layer: PostgreSQL will serve as the primary data store, accessed exclusively by the backend API.

graph TD
    A[User Browser/Mobile App] -->|HTTP/HTTPS| B(Next.js Frontend)
    B -->|API Calls (HTTP/HTTPS)| C(NestJS Backend API)
    C -->|Database Connection| D(PostgreSQL Database)
    C -->|File Storage| E(AWS S3)
    F[CI/CD Pipeline (GitHub Actions)] --> G(Docker Build & Push)
    G --> H(AWS ECS/EC2)
    H --> I(AWS RDS)
    J[Monitoring & Logging] --> C
    J --> H

4. Frontend Blueprint (Next.js with React & TypeScript)

The frontend will be built with a focus on user experience, performance, and maintainability.

4.1. Technology Stack

  • Framework: Next.js (React)
  • Language: TypeScript
  • Styling: Tailwind CSS (utility-first CSS framework)
  • State Management: React Query for server state (data fetching, caching, synchronization), Zustand for minimal client-side global state.
  • Form Management: React Hook Form
  • Routing: Next.js built-in file-system based router
  • UI Components: Custom components built with Tailwind CSS, potentially integrating a headless UI library (e.g., Radix UI) for accessibility and advanced behaviors.

4.2. Key Components & Pages (Illustrative Examples)

| Page/Component | Description | Interactivity / Data Needs |

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

| / (Homepage) | Landing page with key features, call-to-actions, and testimonials. | Static content, potential API call for dynamic testimonials. |

| /auth/login | User login form. | Form submission to /api/auth/login, JWT token storage. |

| /auth/register | User registration form. | Form submission to /api/auth/register. |

| /dashboard | Main user dashboard, displaying personalized data. | Fetches user-specific data (e.g., GET /api/users/me/data). |

| /profile | User profile management (view/edit). | Fetches user profile (GET /api/users/me), updates profile (PUT /api/users/me). |

| Header | Navigation bar with logo, links, user avatar/login button. | Conditional rendering based on authentication status. |

| Footer | Standard website footer with links and copyright. | Static content. |

| DataTable | Reusable component for displaying tabular data with pagination, sorting, filtering. | Fetches data from API, handles pagination/sorting parameters. |

| Modal | Generic modal component for alerts, forms, confirmations. | Controlled component, accepts content and action callbacks. |

4.3. State Management Strategy

  • Server State (Data Fetching): React Query will manage all asynchronous data fetching, caching, invalidation, and synchronization with the backend. This eliminates the need for complex global state for server-derived data.
  • Client State (UI State): Zustand will be used for lightweight, global UI state (e.g., theme preference, global loading indicators, temporary notifications). Local component state will handle most UI interactions.
  • Form State: React Hook Form will manage form inputs, validation, and submission logic efficiently.

4.4. Styling Strategy

  • Tailwind CSS: Utility-first approach for rapid and consistent styling. Custom themes and configurations will be managed via tailwind.config.js.
  • CSS Modules (for specific cases): Used sparingly for highly complex, isolated components where Tailwind's utility classes might become verbose or less readable.

4.5. Build Process

  • Next.js handles the build process, including code splitting, minification, and optimization for production.
  • TypeScript compilation ensures type safety.
  • ESLint and Prettier will enforce code quality and formatting.

5. Backend API Blueprint (NestJS with TypeScript)

The backend will be a robust, scalable, and secure RESTful API built with NestJS, leveraging its modular structure and enterprise-grade features.

5.1. Technology Stack

  • Framework: NestJS (Node.js)
  • Language: TypeScript
  • ORM: TypeORM
  • Database Driver: pg for PostgreSQL
  • Validation: Class Validator, Class Transformer
  • Authentication: Passport.js (JWT Strategy)
  • API Documentation: Swagger (OpenAPI)

5.2. API Endpoints (Illustrative Examples)

| Resource | HTTP Method | Endpoint | Description | Request Payload (Example) | Response Payload (Example) | Permissions |

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

| Auth | POST | /auth/register | Registers a new user. | { "email": "user@example.com", "password": "securepassword", "username": "JohnDoe" } | { "id": "uuid", "email": "user@example.com", "username": "JohnDoe" } | Public |

| | POST | /auth/login | Authenticates user and returns JWT. | { "email": "user@example.com", "password": "securepassword" } | { "accessToken": "jwt_token_here" } | Public |

| | POST | /auth/refresh | Refreshes access token using refresh token. | { "refreshToken": "refresh_token_here" } | { "accessToken": "new_jwt_token" } | Authenticated |

| Users | GET | /users/me | Retrieves current user's profile. | N/A | { "id": "uuid", "email": "user@example.com", "username": "JohnDoe", "role": "USER" } | Authenticated |

| | PUT | /users/me | Updates current user's profile. | { "username": "JaneDoe" } | { "id": "uuid", "email": "user@example.com", "username": "JaneDoe", "role": "USER" } | Authenticated |

| | GET | /users/:id | Retrieves a user by ID. | N/A | { "id": "uuid", "username": "JohnDoe", "role": "USER" } | ADMIN |

| Products | GET | /products | Fetches all products with pagination. | N/A (query: ?page=1&limit=10) | [{ "id": "uuid", "name": "Product A", "price": 19.99 }] | Public |

| | POST | /products | Creates a new product. | { "name": "New Product", "price": 29.99, "description": "..." } | { "id": "uuid", "name": "New Product", "price": 29.99 } | ADMIN |

| | GET | /products/:id | Fetches a single product by ID. | N/A | { "id": "uuid", "name": "Product A", "price": 19.99, "description": "..." } | Public |

5.3. Data Models (Examples, linked to Database Design)

  • User: id, email, passwordHash, username, role, createdAt, updatedAt
  • Product: id, name, description, price, stock, imageUrl, createdAt, updatedAt
  • Order: id, userId, totalAmount, status, createdAt, updatedAt
  • OrderItem: id, orderId, productId, quantity, priceAtPurchase

5.4. Error Handling Strategy

  • Consistent API error responses using HTTP status codes and a standardized JSON error payload (e.g., { "statusCode": 404, "message": "Not Found", "error": "Resource not found" }).
  • Global exception filters in NestJS to catch and handle all unhandled exceptions gracefully.
  • Custom exceptions for specific business logic errors.

5.5. Rate Limiting & Security Considerations

  • Rate Limiting: Implement rate limiting (e.g., using nestjs-throttler or an API Gateway) to prevent abuse and brute-force attacks on login endpoints.
  • CORS: Properly configure Cross-Origin Resource Sharing (CORS) to allow requests only from authorized frontend domains.
  • Input Validation: Strict input validation using class-validator and DTOs (Data Transfer Objects) to prevent injection attacks and ensure data integrity.
  • Helmet.js: Integrate Helmet.js for setting various HTTP headers that help protect the app from common web vulnerabilities.
  • Environment Variables: All sensitive configurations (database credentials, JWT secrets) will be stored as environment variables.

6. Database Design (PostgreSQL)

A relational database schema designed for data integrity, efficiency, and scalability.

6.1. Chosen Database

  • PostgreSQL: Chosen for its robustness, reliability, advanced features (JSONB, full-text search), and strong community support.

6.2. Schema Design (Illustrative Entities & Relationships)

Entities:

  • users Table:

* id (UUID, Primary Key)

* email (VARCHAR(255), UNIQUE, NOT NULL)

* password_hash (VARCHAR(255), NOT NULL)

* username (VARCHAR(100), UNIQUE, NOT NULL)

* role (ENUM('USER', 'ADMIN'), DEFAULT 'USER', NOT NULL)

* created_at (TIMESTAMP WITH TIME ZONE, DEFAULT NOW())

* updated_at (TIMESTAMP WITH TIME ZONE, DEFAULT NOW())

  • products Table:

* id (UUID, Primary Key)

* name (VARCHAR(255), NOT NULL)

* description (TEXT)

* price (DECIMAL(10, 2), NOT NULL, CHECK (price >= 0))

* stock (INTEGER, NOT NULL, DEFAULT 0, CHECK (stock >= 0))

* image_url (VARCHAR(255))

* created_at (TIMESTAMP WITH TIME ZONE, DEFAULT NOW())

* updated_at (TIMESTAMP WITH TIME ZONE, DEFAULT NOW())

  • orders Table:

* id (UUID, Primary Key)

* user_id (UUID, Foreign Key REFERENCES users(id), NOT NULL)

* total_amount (DECIMAL(10, 2), NOT NULL, CHECK (total_amount >= 0))

* status (ENUM('PENDING', 'PROCESSING', 'SHIPPED', 'DELIVERED', 'CANCELLED'), DEFAULT 'PENDING', NOT NULL)

* created_at (TIMESTAMP WITH TIME ZONE, DEFAULT NOW())

* updated_at (TIMESTAMP WITH TIME ZONE, DEFAULT NOW())

  • order_items Table: (Junction table for orders and products)

* id (UUID, Primary Key)

* order_id (UUID, Foreign Key REFERENCES orders(id), NOT NULL)

* product_id (UUID, Foreign Key REFERENCES products(id), NOT NULL)

* quantity (INTEGER, NOT NULL, CHECK (quantity > 0))

* price_at_purchase (DECIMAL(10, 2), NOT NULL, CHECK (price_at_purchase >= 0))

* created_at (TIMESTAMP WITH TIME ZONE, DEFAULT NOW())

* updated_at (TIMESTAMP WITH TIME ZONE, DEFAULT NOW())

Composite Unique Constraint:* (order_id, product_id) to prevent duplicate

full_stack_app_blueprint.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
\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);}});}