# skolaczk/next-starter architecture

> Architecture diagram of the GitHub repository skolaczk/next-starter, 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/skolaczk/next-starter
- Repository: https://github.com/skolaczk/next-starter

## Overview

##### Main Components
- Frontend Layer: Represented by the Next.js App (found in the src/app directory), UI components (in src/components and its subdirectories), and styling (in src/styles). This layer includes the pages, layouts, and components that make up the user interface.
- Server Actions & Utilities: The src/actions directory contains server actions (e.g., hello-action.ts) that likely encapsulate business logic. Likewise, the src/lib folder holds important utilities such as database configurations (prisma.ts), Stripe integration (stripe.ts), and other helper functions.
- Database: The prisma directory holds the Prisma schema (schema.prisma) and its migrations, which define the data models and database evolution.
- Testing: With both unit and end-to-end tests set up in src/__tests__/unit and src/__tests__/e2e, include a component that represents the testing framework infrastructure (Jest and Playwright configuration files).
- Configuration & Tooling: Top-level config files (e.g., next.config.js, tailwind.config.ts, .eslintrc.js, .prettierrc.js) indicate the development and deployment pipeline. GitHub workflows in .github/workflows capture CI/CD aspects.
- Internationalization (i18n): The src/messages directory (and project.inlang config) suggest built-in support for multilingual support.
- Authentication & Authorization: Although part of the API layer, note that next-auth is a critical integration for handling user authentication.

##### Relationships and Interactions
- The Frontend interacts with the API endpoints for authentication and Stripe payments.
- Components from the Frontend layer consume data and services provided by server actions and utilities from the src/lib directory.
- Database operations are abstracted via Prisma, connecting the API layer’s business logic to the underlying database.
- Testing layers interact with both the frontend (React Testing Library and unit tests) and the API logic (Playwright for e2e tests) to verify system functionality.
- Deployment and CI/CD pipelines (GitHub actions, Husky, Commitlint) assure quality and consistency before code integration.

##### Architectural Patterns & Technologies
- Next.js App Router is utilized to separate routes, enable server-side processing, and further isolate API endpoints.
- Separation of concerns is clearly visible: UI components, server actions, database models, and utilities are all organized in their own directories.
- Use of industry-standard tools:
- Next.js, React, and Typescript for the frontend.
- Prisma and a dedicated migration folder for database operations.
- Stripe for payment processing and next-auth for authentication.
- TailwindCSS and Shadcn/ui for styling and a customizable interface.
- Standard testing frameworks (Jest, Playwright) for automated testing.
- Environment management with T3-env, ESLint, Prettier, and Husky ensures rapid and consistent development.

##### Essential Elements
- A block for the Frontend, subdividing into pages, components, and styling.
- A block for the API Layer showing separate endpoints for authentication and payments.
- A Database block showing the Prisma ORM and how migrations are applied.
- A testing block explaining how unit and e2e tests are set up.
- Additional blocks or notes for configuration and CI/CD that connect to both the development workflow and deployment pipeline.

## Diagram (Mermaid)

```mermaid
flowchart TD

    subgraph "Frontend Layer"
        F1["Next.js App"]
        F2["UI Components"]
        F3["Styling"]
    end

    subgraph "API Layer"
        A1["Auth API (next‑auth)"]
        A2["Stripe Checkout"]
        A3["Stripe Webhook"]
    end

    subgraph "Server Actions & Utilities"
        S1["Server Actions"]
        S2["Utilities"]
    end

    subgraph "Database"
        D1["Prisma ORM"]
    end

    subgraph "Testing"
        T1["Testing Frameworks"]
    end

    subgraph "Configuration & Tooling"
        C1["Next.js Config"]
        C2["Tailwind CSS Config"]
        C3["ESLint"]
        C4["Prettier"]
        C5["CI/CD (GitHub Workflows)"]
        C6["Commitlint"]
        C7["Husky"]
    end

    subgraph "Internationalization"
        I1["Messages"]
        I2["Inlang Config"]
    end

    %% Connections
    F1 -->|"calls"| A1
    F1 -->|"calls"| A2
    F1 -->|"calls"| A3
    F2 -->|"invokes"| S1
    S1 -->|"uses"| S2
    A1 -->|"queries"| D1
    A2 -->|"queries"| D1
    A3 -->|"queries"| D1
    C1 -->|"configures"| F1
    C2 -->|"styles"| F1
    C5 -->|"triggers"| T1
    I1 -->|"localizes"| F2

    %% Testing interactions
    T1 -->|"tests"| F1
    T1 -->|"tests"| A1
    T1 -->|"tests"| A2
    T1 -->|"tests"| A3

    %% Styles
    classDef frontend fill:#a3d5ff,stroke:#333,stroke-width:2px;
    classDef api fill:#ffc0cb,stroke:#333,stroke-width:2px;
    classDef server fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef database fill:#fad7a0,stroke:#333,stroke-width:2px;
    classDef testing fill:#f9e79f,stroke:#333,stroke-width:2px;
    classDef config fill:#d2b4de,stroke:#333,stroke-width:2px;
    classDef i18n fill:#aed6f1,stroke:#333,stroke-width:2px;

    class F1,F2,F3 frontend;
    class A1,A2,A3 api;
    class S1,S2 server;
    class D1 database;
    class T1 testing;
    class C1,C2,C3,C4,C5,C6,C7 config;
    class I1,I2 i18n;

    %% Click Events
    click F1 "https://github.com/skolaczk/next-starter/tree/main/src/app"
    click F2 "https://github.com/skolaczk/next-starter/tree/main/src/components"
    click F3 "https://github.com/skolaczk/next-starter/tree/main/src/styles"
    click A1 "https://github.com/skolaczk/next-starter/blob/main/src/app/api/auth/[...nextauth]"
    click A2 "https://github.com/skolaczk/next-starter/tree/main/src/app/api/stripe/checkout-session"
    click A3 "https://github.com/skolaczk/next-starter/tree/main/src/app/api/stripe/webhook"
    click S1 "https://github.com/skolaczk/next-starter/blob/main/src/actions/hello-action.ts"
    click S2 "https://github.com/skolaczk/next-starter/tree/main/src/lib"
    click D1 "https://github.com/skolaczk/next-starter/tree/main/prisma"
    click T1 "https://github.com/skolaczk/next-starter/tree/main/src/__tests__"
    click C1 "https://github.com/skolaczk/next-starter/blob/main/next.config.js"
    click C2 "https://github.com/skolaczk/next-starter/blob/main/tailwind.config.ts"
    click C3 "https://github.com/skolaczk/next-starter/blob/main/.eslintrc.js"
    click C4 "https://github.com/skolaczk/next-starter/blob/main/.prettierrc.js"
    click C5 "https://github.com/skolaczk/next-starter/tree/main/.github/workflows"
    click C6 "https://github.com/skolaczk/next-starter/blob/main/commitlint.config.js"
    click C7 "https://github.com/skolaczk/next-starter/blob/main/.husky"
    click I1 "https://github.com/skolaczk/next-starter/tree/main/src/messages"
    click I2 "https://github.com/skolaczk/next-starter/blob/main/project.inlang"
```
