# diego-lopes/acme architecture

> Architecture diagram of the GitHub repository diego-lopes/acme, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/diego-lopes/acme
- Repository: https://github.com/diego-lopes/acme

## Overview

##### Project type and purpose
- This is a full-stack Next.js application using the new App Router (Next.js 13+), serving a dashboard with customers and invoices, plus login and seed routes.
- Purpose: demonstration starter for a dashboard course—CRUD on invoices, lists of customers, revenue‐chart, etc., with client/server components and a simple auth flow.

##### File structure
- Top‐level: next.config.ts, middleware.ts, auth.ts/auth.config.ts → global configuration & auth middleware.
- app/ directory (Next.js App Router):
- app/layout.tsx, app/dashboard/layout.tsx → server layouts.
- app/dashboard/(overview), customers, invoices → nested route groups and pages.
- app/login/page.tsx, app/seed/route.ts → special routes (login form + data seeding API).
- app/lib/ → server utilities: data fetching, action handlers, placeholder data, common types.
- app/ui/ → shared React components (buttons, tables, charts, forms).
- public/, global.css, tailwind.config.ts → static assets and global styling.
- package.json, pnpm-lock.yaml → dependencies and scripts.

##### README
- Confirms it’s a “starter template for the Next.js App Router Course” focused on a dashboard application.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser["User Client<br/>(React hydration)"]:::client

    %% Next.js Server
    subgraph "Next.js Server" 
        direction TB

        subgraph "App Router / Page Rendering"
            direction TB
            RootLayout["Root Layout"]:::server
            DashboardLayout["Dashboard Layout<br/>(/dashboard)"]:::server
            OverviewRoutes["Overview Routes<br/>(app/dashboard/(overview))"]:::server
            CustomersPage["Customers Page"]:::server
            subgraph "Invoices Module"
                direction TB
                InvoicesList["Invoices List"]:::server
                InvoiceDetail["Invoice Detail"]:::server
                EditInvoice["Edit Invoice"]:::server
                CreateInvoice["Create Invoice"]:::server
            end
            LoginPage["Login Page"]:::server
        end

        subgraph "API Routes"
            direction TB
            SeedAPI["Seed API Route<br/>(POST /api/seed)"]:::server
        end

        subgraph "Middleware / Auth Flow"
            direction TB
            MiddlewareEntry["Middleware Entry<br/>(middleware.ts)"]:::server
            AuthHelper["Auth Helper Logic<br/>(auth.ts)"]:::server
            AuthConfig["Auth Configuration<br/>(auth.config.ts)"]:::server
        end
    end

    %% Data Layer
    DataLayer["Placeholder DB<br/>(app/lib/placeholder-data.ts)"]:::data
    DataUtilities["Data Utilities<br/>(app/lib/data.ts,<br/>definitions.ts,<br/>action.ts, utils.ts)"]:::data

    %% UI Component Library
    subgraph "UI Component Library<br/>(Client Components)" 
        direction TB
        UILib["app/ui/"]:::ui
    end

    %% External Services
    subgraph External
        direction TB
        AuthProvider["Auth Provider"]:::external
        CDN["CDN / Static Assets"]:::external
    end

    %% Static Assets & Config
    PublicAssets["Public Folder<br/>(public/)"]:::external
    TailwindConfig["Tailwind Config<br/>(tailwind.config.ts)"]:::external
    NextConfig["Next.js Config<br/>(next.config.ts)"]:::external

    %% Connections
    Browser -->|"GET /dashboard, /login"| RootLayout
    RootLayout --> DashboardLayout
    DashboardLayout --> OverviewRoutes
    DashboardLayout --> CustomersPage
    DashboardLayout --> InvoicesList
    InvoicesList --> InvoiceDetail
    InvoiceDetail --> EditInvoice
    InvoicesList --> CreateInvoice
    Browser -->|"submitForm()"| SeedAPI
    SeedAPI --> DataLayer
    RootLayout --> UILib
    DashboardLayout --> UILib
    LoginPage --> UILib
    OverviewRoutes --> DataUtilities
    CustomersPage --> DataUtilities
    InvoicesList --> DataUtilities
    InvoiceDetail --> DataUtilities
    EditInvoice --> DataUtilities
    CreateInvoice --> DataUtilities
    MiddlewareEntry --> AuthHelper
    MiddlewareEntry --> AuthConfig
    Browser -->|"fetchPage() /static"| CDN
    CDN --> PublicAssets
    RootLayout --> PublicAssets
    PublicAssets -->|"uses"| TailwindConfig
    PublicAssets -->|"uses"| NextConfig
    MiddlewareEntry -->|"auth check"| AuthProvider
    AuthProvider --> AuthConfig

    %% Click Events - Next.js App Router components
    click RootLayout "https://github.com/diego-lopes/acme/blob/main/app/layout.tsx"
    click DashboardLayout "https://github.com/diego-lopes/acme/blob/main/app/dashboard/layout.tsx"
    click OverviewRoutes "https://github.com/diego-lopes/acme/tree/main/app/dashboard/(overview)/"
    click CustomersPage "https://github.com/diego-lopes/acme/blob/main/app/dashboard/customers/page.tsx"
    click InvoicesList "https://github.com/diego-lopes/acme/blob/main/app/dashboard/invoices/page.tsx"
    click InvoiceDetail "https://github.com/diego-lopes/acme/blob/main/app/dashboard/invoices/[id]/page.tsx"
    click EditInvoice "https://github.com/diego-lopes/acme/blob/main/app/dashboard/invoices/[id]/edit/page.tsx"
    click CreateInvoice "https://github.com/diego-lopes/acme/blob/main/app/dashboard/invoices/create/page.tsx"
    click LoginPage "https://github.com/diego-lopes/acme/blob/main/app/login/page.tsx"
    click SeedAPI "https://github.com/diego-lopes/acme/blob/main/app/seed/route.ts"
    click DataUtilities "https://github.com/diego-lopes/acme/tree/main/app/lib/"
    click DataLayer "https://github.com/diego-lopes/acme/blob/main/app/lib/placeholder-data.ts"
    click MiddlewareEntry "https://github.com/diego-lopes/acme/blob/main/middleware.ts"
    click AuthHelper "https://github.com/diego-lopes/acme/blob/main/auth.ts"
    click AuthConfig "https://github.com/diego-lopes/acme/blob/main/auth.config.ts"
    click UILib "https://github.com/diego-lopes/acme/tree/main/app/ui/"

    %% Styles
    classDef client fill:#E0F7FA,stroke:#006064,color:#006064
    classDef server fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32
    classDef data fill:#FFF3E0,stroke:#EF6C00,color:#EF6C00
    classDef ui fill:#EDE7F6,stroke:#5E35B1,color:#5E35B1
    classDef external fill:#ECEFF1,stroke:#607D8B,color:#37474F
```
