Full Stack App Blueprint
Run ID: 69ccde5e3e7fb09ff16a5dae2026-04-01Development
PantheraHive BOS
BOS Dashboard

As a professional AI assistant within PantheraHive, I am pleased to present the detailed "Full Stack App Blueprint" as the deliverable for the plan_architecture step. This blueprint provides a comprehensive architectural plan, covering all essential components from frontend to deployment and testing, designed to be robust, scalable, and ready for development.


Full Stack Application Blueprint: [Project Name - e.g., "SaaS Productivity Suite"]

Date: October 26, 2023

Version: 1.0

Status: Approved for Development Planning


1. Project Overview

1.1. Project Title

[e.g., "PantheraHive Workflow Management System"]

1.2. Executive Summary

This document outlines the complete architectural blueprint for a modern full-stack application. The goal is to create a robust, scalable, and maintainable platform that delivers [briefly state core value proposition, e.g., "enhanced productivity through streamlined workflow management and collaborative tools"]. This blueprint details the technology stack, architectural patterns, database design, authentication mechanisms, deployment strategies, and testing methodologies required to build a high-quality application.

1.3. Core Goals & Objectives

1.4. Target Audience


2. Architectural Style & Principles

2.1. Architectural Style

Modular Monolith with API Gateway Pattern:

2.2. Architectural Principles


3. Core Features (High-Level)


4. Technology Stack Selection

4.1. Frontend

4.2. Backend (API Gateway & Core Services)

4.3. Database

4.4. Authentication & Authorization

4.5. Deployment & DevOps

4.6. Testing


5. Frontend Architecture (Next.js with React & TypeScript)

5.1. Project Structure

text • 1,197 chars
/src
├── app/                  # Next.js App Router (pages, layouts, loading, error, etc.)
│   ├── (auth)/           # Route group for authentication pages (login, register)
│   ├── (dashboard)/      # Route group for authenticated dashboard pages
│   │   ├── projects/
│   │   ├── tasks/
│   │   └── settings/
│   ├── api/              # Next.js API Routes (e.g., /api/auth/[...nextauth])
│   └── layout.tsx        # Root layout
├── components/           # Reusable UI components (buttons, inputs, cards)
│   ├── ui/               # Shadcn/ui or Radix UI components
│   └── common/           # Custom common components
├── hooks/                # Custom React hooks
├── lib/                  # Utility functions, helpers, constants
│   ├── api/              # API client setup (e.g., Axios instance)
│   ├── auth/             # Authentication related utilities
│   ├── utils.ts          # General utilities
│   └── validation/       # Zod schemas
├── styles/               # Global styles, Tailwind CSS config
├── types/                # TypeScript type definitions
├── providers/            # Context providers (e.g., AuthProvider, QueryClientProvider)
└── public/               # Static assets
Sandboxed live preview

6.2. API Design (RESTful)

  • Resource-Oriented: APIs designed around resources (e.g., /users, /projects, /tasks).
  • HTTP Methods: Use standard HTTP methods (GET, POST, PUT, PATCH, DELETE) appropriately.
  • Versioning: Prefix API routes with a version (e.g., /api/v1/).
  • Paging & Filtering: Implement query parameters for pagination, sorting, and filtering collections.
  • Error Handling: Consistent JSON error responses with appropriate HTTP status codes.

6.3. Layered Architecture

  • Controllers: Handle incoming HTTP requests, validate input, and delegate to services.
  • Services: Contain business logic, orchestrate data operations, and interact with the database.
  • Repositories/Prisma Client: Directly interact with the database (handled by Prisma).
  • DTOs (Data Transfer Objects): Define the structure of data being sent to and from the API, used for validation.

6.4. Error Handling

  • NestJS Exception Filters: Global exception filter to catch unhandled exceptions and return standardized error responses.
  • HTTP Exception Classes: Use NestJS's built-in HttpException or custom exceptions for specific error scenarios.
  • Logging: Log all errors with relevant context (stack trace, request details).

6.5. Logging

  • Winston/Pino: Configured for structured logging (JSON format) to send logs to stdout/stderr.
  • Log Levels: Use appropriate log levels (debug, info, warn, error) for different severities.
  • Contextual Logging: Include request IDs, user IDs, and other relevant context in logs for easier debugging.

6.6. Background Jobs (if applicable

gemini Output

Full Stack App Blueprint: Project Management Tool

This document provides a comprehensive, detailed, and actionable blueprint for developing a robust Full Stack Project Management Tool. It covers the frontend, backend API, database design, authentication, deployment configurations, and testing strategies, complete with production-ready code examples and explanations.


1. Application Overview

Application Name: Panthera Projects (Example)

Description: A web-based project management tool enabling teams to create, organize, track, and collaborate on projects and tasks efficiently.

Key Features:

  • User Management: Registration, Login, Profile Management.
  • Project Management: Create, Read, Update, Delete (CRUD) projects. Assign project members, set deadlines.
  • Task Management: Create, Read, Update, Delete (CRUD) tasks within projects. Assign tasks, set statuses, due dates, priorities.
  • Collaboration: Commenting on tasks, activity feeds (optional for initial MVP).
  • Authentication & Authorization: Secure user access and role-based permissions.
  • Responsive Design: Accessible on various devices.

Technology Stack Rationale:

  • Frontend (React with TypeScript): Offers a component-based architecture, strong typing for maintainability, and a vast ecosystem.
  • Backend (Node.js with Express & TypeScript): Provides a performant, scalable, and non-blocking API layer. TypeScript enhances code quality and reduces runtime errors.
  • Database (PostgreSQL): A powerful, open-source, relational database known for its reliability, data integrity, and support for complex queries.
  • ORM (TypeORM): A robust ORM that works seamlessly with TypeScript, simplifying database interactions and object mapping.
  • Authentication (JWT & Bcrypt): Industry-standard for secure, stateless authentication and password hashing.
  • Styling (Tailwind CSS): Utility-first CSS framework for rapid UI development and highly customizable designs.
  • Deployment (Docker & AWS): Docker ensures consistent environments, while AWS provides a scalable, reliable, and secure cloud infrastructure.
  • Testing (Jest, React Testing Library, Supertest): Comprehensive testing frameworks for unit, integration, and API testing.

2. Frontend Blueprint (React with TypeScript)

The frontend will be built using React with TypeScript, leveraging a modern state management solution and a utility-first CSS framework.

2.1 Project Structure


panthera-projects-frontend/
├── public/
├── src/
│   ├── api/                  # API client configurations and services
│   │   └── apiClient.ts
│   ├── assets/               # Images, icons, fonts
│   ├── components/           # Reusable UI components
│   │   ├── common/           # Generic components (Header, Footer, Button, Input)
│   │   ├── auth/             # Auth-specific components (LoginForm, RegisterForm)
│   │   ├── projects/         # Project-specific components (ProjectCard, ProjectForm)
│   │   └── tasks/            # Task-specific components (TaskItem, TaskDetails)
│   ├── contexts/             # React Context API for global state (if not using Zustand for everything)
│   ├── hooks/                # Custom React hooks
│   ├── layouts/              # Layout components (e.g., AuthLayout, DashboardLayout)
│   ├── pages/                # Page-level components (e.g., LoginPage, DashboardPage, ProjectDetailsPage)
│   ├── store/                # Zustand stores for global state management
│   │   └── authStore.ts
│   ├── styles/               # Tailwind CSS config, base styles
│   │   └── index.css
│   ├── utils/                # Utility functions (date formatters, validators)
│   ├── App.tsx               # Main application component
│   ├── index.tsx             # Entry point
│   └── react-app-env.d.ts    # TypeScript declaration file
├── .env                      # Environment variables
├── .eslintrc.js              # ESLint configuration
├── .prettierrc               # Prettier configuration
├── tailwind.config.js        # Tailwind CSS configuration
├── tsconfig.json             # TypeScript configuration
├── package.json              # Project dependencies and scripts
└── README.md

2.2 Core Components & Pages

  • layouts/DashboardLayout.tsx: Provides the main application layout including header, sidebar, and content area.
  • components/common/Header.tsx: Application header with logo, navigation, and user menu.
  • pages/LoginPage.tsx: User login interface.
  • pages/RegisterPage.tsx: User registration interface.
  • pages/DashboardPage.tsx: Overview of assigned projects and tasks.
  • pages/ProjectsPage.tsx: Lists all projects, with options to create/manage.
  • pages/ProjectDetailsPage.tsx: Displays details for a specific project, including tasks.
  • components/projects/ProjectCard.tsx: Displays a summary of a single project.
  • components/tasks/TaskItem.tsx: Displays a single task with status, assignee, and due date.

2.3 State Management (Zustand)

Zustand is a lightweight, fast, and scalable state management solution that integrates well with React hooks.

src/store/authStore.ts


import { create } from 'zustand';

// Define the shape of a user object
interface User {
  id: string;
  username: string;
  email: string;
  // Add other user profile fields as needed
}

// Define the shape of the authentication state
interface AuthState {
  token: string | null;
  user: User | null;
  isAuthenticated: boolean;
  setToken: (token: string | null) => void;
  setUser: (user: User | null) => void;
  login: (token: string, user: User) => void;
  logout: () => void;
}

/**
 * Zustand store for authentication state management.
 * Manages the JWT token, user information, and authentication status.
 */
export const useAuthStore = create<AuthState>((set) => ({
  token: localStorage.getItem('jwt_token'), // Initialize from localStorage
  user: null, // User details will be fetched after login or from token
  isAuthenticated: !!localStorage.getItem('jwt_token'), // Check if token exists

  /**
   * Sets the JWT token in the store and localStorage.
   * @param token The JWT token string.
   */
  setToken: (token) => {
    if (token) {
      localStorage.setItem('jwt_token', token);
      set({ token, isAuthenticated: true });
    } else {
      localStorage.removeItem('jwt_token');
      set({ token: null, isAuthenticated: false });
    }
  },

  /**
   * Sets the authenticated user's details in the store.
   * @param user The User object.
   */
  setUser: (user) => set({ user }),

  /**
   * Handles user login: sets token, user, and updates authentication status.
   * @param token The JWT token received upon successful login.
   * @param user The User object received upon successful login.
   */
  login: (token, user) => {
    localStorage.setItem('jwt_token', token);
    set({ token, user, isAuthenticated: true });
  },

  /**
   * Handles user logout: clears token, user, and resets authentication status.
   */
  logout: () => {
    localStorage.removeItem('jwt_token');
    set({ token: null, user: null, isAuthenticated: false });
  },
}));

2.4 API Integration (Axios)

src/api/apiClient.ts


import axios from 'axios';
import { useAuthStore } from '../store/authStore';

/**
 * Creates an Axios instance for making API requests to the backend.
 * Includes interceptors for attaching JWT tokens and handling authentication errors.
 */
const apiClient = axios.create({
  baseURL: process.env.REACT_APP_API_BASE_URL || 'http://localhost:5000/api', // Default API base URL
  timeout: 10000, // Request timeout
  headers: {
    'Content-Type': 'application/json',
  },
});

// Request interceptor to attach the JWT token to outgoing requests
apiClient.interceptors.request.use(
  (config) => {
    const token = useAuthStore.getState().token; // Get token from Zustand store
    if (token) {
      config.headers.Authorization = `Bearer ${token}`;
    }
    return config;
  },
  (error) => {
    return Promise.reject(error);
  }
);

// Response interceptor to handle authentication errors (e.g., token expiration)
apiClient.interceptors.response.use(
  (response) => {
    return response;
  },
  (error) => {
    if (error.response && error.response.status === 401) {
      // If 401 Unauthorized, log out the user
      useAuthStore.getState().logout();
      // Optionally redirect to login page
      // window.location.href = '/login';
    }
    return Promise.reject(error);
  }
);

export default apiClient;

2.5 Example Frontend Code

package.json (Frontend Dependencies)


{
  "name": "panthera-projects-frontend",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@heroicons/react": "^2.1.3",
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "axios": "^1.6.8",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-router-dom": "^6.22.3",
    "react-scripts": "5.0.1",
    "typescript": "^4.9.5",
    "web-vitals": "^2.1.4",
    "zustand": "^4.5.2"
  },
  "devDependencies": {
    "@types/jest": "^27.5.2",
    "@types/node": "^16.18.96",
    "@types/react": "^18.2.75",
    "@types/react-dom": "^18.2.24",
    "autoprefixer": "^10.4.19",
    "postcss": "^8.4.38",
    "tailwindcss": "^3.4.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

src/App.tsx (Main Application Component with Routing)


import React from 'react';
import { BrowserRouter as Router, Routes, Route, Navigate } from 'react-router-dom';
import { useAuthStore } from './store/authStore';

// Import Layouts
import AuthLayout from './layouts/AuthLayout';
import DashboardLayout from './layouts/DashboardLayout';

// Import Pages
import LoginPage from './pages/LoginPage';
import RegisterPage from './pages/RegisterPage';
import DashboardPage from './pages/DashboardPage';
import ProjectsPage from './pages/ProjectsPage';
import ProjectDetailsPage from './pages/ProjectDetailsPage';
import NotFoundPage from './pages/NotFoundPage'; // A simple 404 page

/**
 * A private
gemini Output

This document provides a comprehensive Full Stack Application Blueprint, outlining the architecture, technology stack, detailed component designs, database schema, authentication mechanisms, deployment strategies, and testing suites for a robust and scalable application. This blueprint is designed to be a ready-to-build guide, translating high-level requirements into actionable technical specifications.


1. Executive Summary

This blueprint details the complete technical architecture for a modern, full-stack web application, focusing on a Task Management & Collaboration Platform as a concrete example. It covers all essential layers: frontend, backend, database, authentication, deployment, and testing. The proposed solutions leverage industry best practices and a robust technology stack to ensure performance, scalability, security, and maintainability.

2. Core Application Concept: Task Management & Collaboration Platform

The application aims to provide a platform for teams to manage projects, track tasks, and facilitate collaboration.

Key Features:

  • User Management: Registration, Login, Profile Management.
  • Project Management: Create, view, update, and delete projects. Assign project members with roles.
  • Task Management: Create, view, update, delete tasks within projects. Assign tasks to users, set due dates, priorities, and statuses.
  • Collaboration: Add comments to tasks.
  • Notifications: (Future consideration) Real-time updates on task/project changes.

3. Technology Stack Recommendation

A modern, scalable, and developer-friendly technology stack is recommended:

  • Frontend Framework: React.js with Next.js (for server-side rendering, routing, and build optimization)
  • Backend Framework: Node.js with NestJS (for robust, scalable, and maintainable API development using TypeScript)
  • Database: PostgreSQL (Relational Database, ACID compliant, excellent for structured data)
  • ORM (Object-Relational Mapper): Prisma or TypeORM (for database interaction and schema management)
  • Authentication: JSON Web Tokens (JWT)
  • Styling: Tailwind CSS (Utility-first CSS framework)
  • Containerization: Docker
  • Cloud Provider: AWS (Amazon Web Services)
  • CI/CD: GitHub Actions / GitLab CI

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

4.1. Architecture

  • Framework: Next.js for its hybrid rendering capabilities (SSR, SSG, CSR), file-system routing, API routes, and optimized build processes.
  • Structure: A well-organized folder structure (e.g., pages, components, hooks, utils, styles, services). Consider a monorepo setup if frontend and backend are tightly coupled.
  • Data Fetching: SWR or React Query for efficient data fetching, caching, and state management of server data.
  • Client-Side State Management: React Context API for local component state, and optionally Zustand or Jotai for global client-side state if complexity demands.

4.2. Key Pages & Components

Pages (Next.js pages directory):

  • /: Marketing Landing Page (or redirect to /dashboard if logged in)
  • /login: User Login Form
  • /register: User Registration Form
  • /dashboard: Overview of user's projects and assigned tasks
  • /projects: List of all accessible projects
  • /projects/[id]: Project Details page (tasks, members, settings)
  • /tasks/[id]: Task Details page (description, comments, history)
  • /profile: User Profile Management
  • /settings: Application-wide or user-specific settings

Reusable Components (components directory):

  • UI Primitives: Button, Input, Textarea, Checkbox, Dropdown, Modal, Spinner, Avatar.
  • Layout Components: Header, Sidebar, Footer, Layout (wrapper for common UI elements).
  • Application-Specific: ProjectCard, TaskCard, TaskList, UserList, CommentSection, NotificationToast.
  • Forms: LoginForm, RegisterForm, ProjectForm, TaskForm.

4.3. State Management

  • Server State: SWR or React Query for managing asynchronous data, caching, revalidation, and error handling.
  • Client State: React Context API for themes, user preferences, and small global states. Use useState and useReducer for local component state.
  • Form State: React Hook Form or Formik for efficient form management, validation, and submission.

4.4. Styling Strategy

  • Framework: Tailwind CSS for a utility-first approach, enabling rapid UI development and consistent design.
  • Component-Specific Styles: CSS Modules for encapsulating component styles when necessary, or using Styled Components for more dynamic, JS-driven styling.
  • Theming: Implement a simple theme switcher using CSS variables and Context API for light/dark mode.

4.5. Accessibility (A11y) & Internationalization (i18n)

  • A11y: Adhere to WCAG guidelines. Use semantic HTML, ARIA attributes where appropriate, keyboard navigation, and focus management.
  • i18n: Use next-i18next for managing translations and language switching, supporting multiple locales.

5. Backend API Blueprint (Node.js with NestJS)

5.1. Architecture

  • Framework: NestJS, a progressive Node.js framework for building efficient, reliable, and scalable server-side applications. It uses TypeScript and is heavily inspired by Angular's modular structure.
  • API Style: RESTful API for standard resource-based interactions.
  • Modular Design: Organize the application into logical modules (e.g., AuthModule, UsersModule, ProjectsModule, TasksModule, CommentsModule). Each module contains its controllers, services, repositories, and DTOs.

5.2. Core Endpoints

Authentication & User Management:

  • POST /auth/register: Register a new user.
  • POST /auth/login: Authenticate user and return JWT tokens.
  • POST /auth/refresh: Refresh access token using refresh token.
  • POST /auth/logout: Invalidate refresh token.
  • GET /users/me: Get current user's profile.
  • PUT /users/me: Update current user's profile.

Project Management:

  • GET /projects: Get all projects accessible by the user.
  • POST /projects: Create a new project.
  • GET /projects/:id: Get details of a specific project.
  • PUT /projects/:id: Update a project.
  • DELETE /projects/:id: Delete a project.
  • POST /projects/:id/members: Add a member to a project.
  • PUT /projects/:id/members/:userId: Update a member's role in a project.
  • DELETE /projects/:id/members/:userId: Remove a member from a project.

Task Management:

  • GET /projects/:projectId/tasks: Get all tasks for a specific project.
  • POST /projects/:projectId/tasks: Create a new task within a project.
  • GET /tasks/:id: Get details of a specific task.
  • PUT /tasks/:id: Update a task.
  • DELETE /tasks/:id: Delete a task.
  • GET /users/:userId/tasks: Get all tasks assigned to a specific user.

Comments:

  • GET /tasks/:taskId/comments: Get all comments for a specific task.
  • POST /tasks/:taskId/comments: Add a new comment to a task.
  • DELETE /comments/:id: Delete a comment.

5.3. Data Models (API Perspective)

  • User: id, username, email, firstName, lastName, createdAt, updatedAt
  • Project: id, name, description, ownerId, createdAt, updatedAt, members (array of User objects with roles)
  • Task: id, title, description, status (e.g., 'todo', 'in-progress', 'done'), priority (e.g., 'low', 'medium', 'high'), dueDate, projectId, assignedToId, createdAt, updatedAt
  • Comment: id, content, taskId, userId, createdAt

5.4. Error Handling

  • Standardized JSON error responses: { "statusCode": 400, "message": "Bad Request", "error": "Validation failed" }.

*

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