How jhonortizgomez/monorepo-fullstack-test works
Project Type & Purpose
• This is a full-stack monorepo built using Next.js 15, consisting of separate frontend and backend applications.
• The project leverages Turborepo for efficient package management, and it splits shared logic and resources across several internal packages (e.g., @repo/core, @repo/ui).
• The backend exposes API endpoints for handling cart and product data, while the frontend consumes these endpoints to render the user interface.
File Structure
• Top-level directories like apps/backend, apps/frontend, and packages (with packages/core, packages/ui, etc.) clearly indicate a modular monorepo architecture.
• The “apps” folder contains the two separate Next.js applications (backend and frontend).
• Within each app, you see standard Next.js directories (such as src/app, API endpoints, public assets, and configuration files) that hint at file-based routing and API routes.
• The “packages” directory contains shared modules:
• packages/core holds the common logic such as backend business logic, API functions, shared data (products.json), form validation, and state management (e.g., budget and cart).
• packages/ui contains shared UI components (buttons, cards, inputs, etc.) that might be used across the frontend (or even within the backend for server-side rendering).
Key Architectural Components
a. Frontend Application:
• A Next.js 15 frontend located in apps/frontend.
• Contains reusable components, views (e.g., “OurProducts” page), and a structured UI built with TailwindCSS.
• Interacts with the backend API for product and cart operations.
b. Backend Application:
• A Next.js 15 backend in apps/backend exposing API routes for versioned endpoints (e.g., “api/v1/cart” and “api/v1/products”).
• Responsible for data processing and serving requests made by the frontend.
c. Core Shared Package (packages/core):
• Houses API definitions, common business logic, shared data (such as products.json), helper functions (e.g., validation, finding best product combinations), store implementations, and schema definitions.
• It’s integrated into both the frontend and backend.
d. UI Shared Package (packages/ui):
• Contains common UI components that further enforce consistency across applications.
• Offers components like buttons, cards, forms, etc.
e. Additional Dev and Configuration Tools:
• Packages for ESLint configuration and TypeScript configuration provide standardized coding practices across the monorepo.
• Turborepo is used for orchestrating the builds, development server, and scripts for both apps concurrently.
Relationships and Interactions
• The Frontend consumes the API endpoints exposed by the Backend.
• Both Frontend and Backend share common logic via the Core package – ensuring consistency in business rules (e.g., product validation, cart management).
• The UI package is integrated into the Frontend for building the user interface.
• You might also indicate that configuration packages (eslint-config and typescript-config) facilitate uniform development standards.
• API interactions from Frontend → Backend.
• Shared dependency links from Frontend & Backend → packages/core.
• UI dependency from Frontend → packages/ui.
Design Patterns and Architectural Principles
• Separation of concerns by showing independent applications for frontend and backend.
• Reusability by highlighting the shared modules (core and ui).
• Scalability by noting that adding more packages or services can follow the same pattern.
• That the monorepo and Turborepo setup facilitate efficient development, testing, and deployment processes.