# jhonortizgomez/monorepo-fullstack-test architecture

> Architecture diagram of the GitHub repository jhonortizgomez/monorepo-fullstack-test, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jhonortizgomez/monorepo-fullstack-test
- Repository: https://github.com/jhonortizgomez/monorepo-fullstack-test

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Applications Layer
    subgraph "Applications"
        FE["Frontend Application<br/>(Next.js 15, React 19, TailwindCSS)"]:::frontend
        BE["Backend Application<br/>(Next.js 15 API endpoints, v1)"]:::backend
    end

    %% Shared Packages Layer
    subgraph "Shared Packages"
        CORE["Core Shared Package<br/>(Shared Logic, Data, Schemas, Helpers, Zustand)"]:::shared
        UI["UI Shared Package<br/>(Reusable UI Components)"]:::shared
    end

    %% Development & Configuration Tools Layer
    subgraph "Dev & Config Tools"
        TURBO["Turborepo<br/>(Orchestration)"]:::dev
        ESLINT["ESLint Configuration"]:::config
        TS["TypeScript Configuration"]:::config
    end

    %% Relationships between layers
    FE -->|"APIcalls"| BE
    FE -->|"Uses"| CORE
    BE -->|"DependsOn"| CORE
    FE -->|"UIComponents"| UI

    TURBO -->|"Orchestrates"| FE
    TURBO -->|"Orchestrates"| BE

    %% Optional: Show that config tools support the entire project
    ESLINT --- FE
    ESLINT --- BE
    ESLINT --- CORE
    ESLINT --- UI
    TS --- FE
    TS --- BE
    TS --- CORE
    TS --- UI

    %% Click Events for Component Mapping
    click FE "https://github.com/jhonortizgomez/monorepo-fullstack-test/tree/main/apps/frontend"
    click BE "https://github.com/jhonortizgomez/monorepo-fullstack-test/tree/main/apps/backend"
    click CORE "https://github.com/jhonortizgomez/monorepo-fullstack-test/tree/main/packages/core"
    click UI "https://github.com/jhonortizgomez/monorepo-fullstack-test/tree/main/packages/ui"
    click ESLINT "https://github.com/jhonortizgomez/monorepo-fullstack-test/tree/main/packages/eslint-config"
    click TS "https://github.com/jhonortizgomez/monorepo-fullstack-test/tree/main/packages/typescript-config"
    click TURBO "https://github.com/jhonortizgomez/monorepo-fullstack-test/blob/main/turbo.json"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef backend fill:#F08080,stroke:#000,stroke-width:2px;
    classDef shared fill:#D3D3D3,stroke:#000,stroke-width:2px;
    classDef dev fill:#DEB887,stroke:#000,stroke-width:2px;
    classDef config fill:#90EE90,stroke:#000,stroke-width:2px;
```
