# emmanuelonah/nextjs-project-architecture-template architecture

> Architecture diagram of the GitHub repository emmanuelonah/nextjs-project-architecture-template, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/emmanuelonah/nextjs-project-architecture-template
- Repository: https://github.com/emmanuelonah/nextjs-project-architecture-template

## Overview

##### Main Components

a) Application Layers (Primary Components):
- View Layer (Next.js Pages/Components)
- Presenter Layer (Hooks/Controllers)
- Model Layer (Data/Business Logic)
- Design System
- Global Store
- Services Layer

b) Supporting Infrastructure:
- Testing Infrastructure
- Build/Deploy Pipeline
- External Services Integration

**[View Layer] <- -> [Presenter Layer] <- -> [Model Layer]**

##### Detailed Component Breakdown

A. View Layer (Left Column):
- Sub-components:
- Pages (`/src/app/*`)
- Shared Components (`/src/components/shared`)
- Layouts (`/src/layouts`)
- Design System Integration

B. Presenter Layer (Middle Column):
- Sub-components:
- Custom Hooks (`/src/hooks`)
- Presenters (`*.presenter.ts` files)
- Utils (`/src/utils`)

C. Model Layer (Right Column):
- Sub-components:
- Models (`/src/models`)
- HTTP Services (`/src/services`)
- Data Types (`/src/@types`)

D. Supporting Systems (Bottom Section):
- Global Store (`/src/globalstore`)
- Design System (`/src/design-system`)
- Testing Infrastructure (`/src/mocks`)

##### Connection and Flow Representation

- Bidirectional communication between View and Presenter
- Bidirectional communication between Presenter and Model
- No direct connection between View and Model (enforcing MVP)
- Design System influence on View components
- Global Store interactions

##### Additional Elements

- External integrations (RadixUI, Styled-components)
- Build/Deploy pipeline (Git Actions)
- Testing coverage requirements (80% minimum)

##### Notes Section

A notes section mentioning:
- MVP architecture principles
- Testing trophy pattern
- Code conventions
- File naming conventions

## Diagram (Mermaid)

```mermaid
graph TB
    %% Main Layers
    subgraph ViewLayer["View Layer"]
        Pages["Pages"]:::view
        SharedComponents["Shared Components"]:::view
        Layouts["Layouts"]:::view
    end

    subgraph PresenterLayer["Presenter Layer"]
        Hooks["Custom Hooks"]:::presenter
        Presenters["Presenters"]:::presenter
        Utils["Utils"]:::presenter
    end

    subgraph ModelLayer["Model Layer"]
        Models["Models"]:::model
        HTTPServices["HTTP Services"]:::model
        DataTypes["Data Types"]:::model
    end

    %% Supporting Systems
    subgraph SupportingSystems["Supporting Systems"]
        GlobalStore["Global Store"]:::support
        DesignSystem["Design System"]:::support
        TestingInfra["Testing Infrastructure"]:::support
    end

    %% Infrastructure
    subgraph Infrastructure["Infrastructure"]
        BuildPipeline["Build/Deploy Pipeline"]:::infra
        RoutesManagement["Routes Management"]:::infra
        ReactQuery["React Query Setup"]:::infra
    end

    %% Connections
    Pages <--> Presenters
    SharedComponents <--> Hooks
    Layouts <--> Presenters
    
    Presenters <--> Models
    Hooks <--> HTTPServices
    Utils <--> Models
    
    Models <--> HTTPServices
    HTTPServices <--> DataTypes
    
    GlobalStore <--> Presenters
    DesignSystem --> ViewLayer
    TestingInfra -.-> HTTPServices
    
    ReactQuery -.-> HTTPServices
    RoutesManagement -.-> Pages

    %% Click Events
    click Pages "https://github.com/emmanuelonah/nextjs-project-architecture-template/tree/master//src/app"
    click SharedComponents "https://github.com/emmanuelonah/nextjs-project-architecture-template/tree/master//src/components/shared"
    click Layouts "https://github.com/emmanuelonah/nextjs-project-architecture-template/tree/master//src/layouts"
    click Hooks "https://github.com/emmanuelonah/nextjs-project-architecture-template/tree/master//src/hooks"
    click Presenters "https://github.com/emmanuelonah/nextjs-project-architecture-template/blob/master//src/app/__example__/useChuckNorris.presenter.ts"
    click Utils "https://github.com/emmanuelonah/nextjs-project-architecture-template/tree/master//src/utils"
    click Models "https://github.com/emmanuelonah/nextjs-project-architecture-template/tree/master//src/models"
    click HTTPServices "https://github.com/emmanuelonah/nextjs-project-architecture-template/tree/master//src/services/http-service"
    click DataTypes "https://github.com/emmanuelonah/nextjs-project-architecture-template/tree/master//src/@types"
    click GlobalStore "https://github.com/emmanuelonah/nextjs-project-architecture-template/tree/master//src/globalstore"
    click DesignSystem "https://github.com/emmanuelonah/nextjs-project-architecture-template/tree/master//src/design-system"
    click TestingInfra "https://github.com/emmanuelonah/nextjs-project-architecture-template/tree/master//src/mocks"
    click BuildPipeline "https://github.com/emmanuelonah/nextjs-project-architecture-template/blob/master//.github/workflows/ci.yml"
    click RoutesManagement "https://github.com/emmanuelonah/nextjs-project-architecture-template/tree/master//src/routes"
    click ReactQuery "https://github.com/emmanuelonah/nextjs-project-architecture-template/blob/master//src/app/lib/react-query.provider.tsx"

    %% Styles
    classDef view fill:#2374ab,color:#fff
    classDef presenter fill:#2a9d8f,color:#fff
    classDef model fill:#e76f51,color:#fff
    classDef support fill:#8338ec,color:#fff
    classDef infra fill:#023047,color:#fff

    %% Legend
    subgraph Legend
        ViewComp["View Component"]:::view
        PresenterComp["Presenter Component"]:::presenter
        ModelComp["Model Component"]:::model
        SupportComp["Supporting Component"]:::support
        InfraComp["Infrastructure Component"]:::infra
    end
```
