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.
Date: October 26, 2023
Version: 1.0
Status: Approved for Development Planning
[e.g., "PantheraHive Workflow Management System"]
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.
Modular Monolith with API Gateway Pattern:
/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
/users, /projects, /tasks)./api/v1/).HttpException or custom exceptions for specific error scenarios.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.
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:
Technology Stack Rationale:
The frontend will be built using React with TypeScript, leveraging a modern state management solution and a utility-first CSS framework.
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
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.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 });
},
}));
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;
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
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.
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.
The application aims to provide a platform for teams to manage projects, track tasks, and facilitate collaboration.
Key Features:
A modern, scalable, and developer-friendly technology stack is recommended:
pages, components, hooks, utils, styles, services). Consider a monorepo setup if frontend and backend are tightly coupled.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 settingsReusable Components (components directory):
Button, Input, Textarea, Checkbox, Dropdown, Modal, Spinner, Avatar.Header, Sidebar, Footer, Layout (wrapper for common UI elements).ProjectCard, TaskCard, TaskList, UserList, CommentSection, NotificationToast.LoginForm, RegisterForm, ProjectForm, TaskForm.useState and useReducer for local component state.next-i18next for managing translations and language switching, supporting multiple locales.AuthModule, UsersModule, ProjectsModule, TasksModule, CommentsModule). Each module contains its controllers, services, repositories, and DTOs.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.id, username, email, firstName, lastName, createdAt, updatedAtid, name, description, ownerId, createdAt, updatedAt, members (array of User objects with roles)id, title, description, status (e.g., 'todo', 'in-progress', 'done'), priority (e.g., 'low', 'medium', 'high'), dueDate, projectId, assignedToId, createdAt, updatedAtid, content, taskId, userId, createdAt{ "statusCode": 400, "message": "Bad Request", "error": "Validation failed" }.*