# jpedroschmitz/typescript-nextjs-starter architecture

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

- Interactive diagram: https://gitdiagram.com/jpedroschmitz/typescript-nextjs-starter
- Repository: https://github.com/jpedroschmitz/typescript-nextjs-starter

## Overview

##### Project type and purpose
- This is a full-stack, TypeScript-based Next.js starter/template.
- It provides a React 19 frontend with Next.js App Router (SSR/SSG), plus built-in tooling (linting, formatting, commit hooks, CI/CD, env management, redirects, CSP).

##### File structure
- Top level: configuration and tooling
- .github/workflows/ci.yml (CI pipeline)
- .husky/* (Git hooks)
- commitlint, ESLint, Prettier, Renovate, lint-staged
- next.config.ts (Next.js settings incl. CSP, redirects.ts)
- Public/static assets: public/
- Source: src/
- src/app/ – Next.js App Router components (layout.tsx, page.tsx, globals.css)
- src/lib/env/ – T3 Env definitions (client.ts, server.ts) for type-safe env vars
- Build & lock files: package.json, pnpm-lock.yaml, tsconfig.json

##### README insights
- Features SSR/SSG via Next.js 15
- Uses T3 Env for environment schemas
- Redirects configured in redirects.ts (typed)
- CSP configured in next.config.ts
- Emphasis on DX: Cursor rules, ESLint, Prettier, Husky, commitlint, Renovate

##### Main components
a. Browser (Client)
b. Next.js Server (Node runtime)
c. React Components & App Router
d. Static Assets / Public Directory
e. Environment Variables Layer (T3 Env)
f. Redirects & CSP (Next.js config)
g. DevOps & Tooling (GitHub Actions CI, Husky, commitlint, ESLint/Prettier)

##### Relationships & interactions
- Browser → Next.js Server
– HTTP requests for pages → App Router → SSR/SSG
– Requests for static assets → served from public/
- Next.js Server → src/lib/env
– Reads .env.local via T3 Env for runtime config
- Next.js Server (build step)
– Applies redirects.ts rules
– Applies CSP rules from next.config.ts
- DevOps & Tooling
– Commits trigger Husky hooks → commitlint / lint-staged → ESLint/Prettier
– Pushes / PRs trigger GitHub Actions CI → ts-check & linters

##### Architectural patterns & principles
- Component-based UI (React)
- App Router pattern (Next.js, SSR/SSG)
- Type-safe env management (T3 Env)
- Strict DX pipeline (lint-staged, Husky, commit conventions)
- CI/CD as code (GitHub Actions)

##### Technologies to call out
- Next.js 15 (App Router)
- React 19, TypeScript
- T3 Env (src/lib/env)
- ESLint, Prettier, Commitlint, Husky, Renovate
- pnpm (package manager)
- GitHub Actions (CI)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Browser (Client)"
        Layout["layout.tsx"]:::frontend
        Page["page.tsx"]:::frontend
        PageCSS["page.module.css"]:::frontend
        Globals["globals.css"]:::frontend
    end

    subgraph "Next.js Server (Node runtime + App Router)"
        NextConfig["next.config.ts"]:::backend
        Redirects["redirects.ts"]:::backend
    end

    subgraph "Environment Layer"
        EnvClient["client.ts"]:::backend
        EnvServer["server.ts"]:::backend
    end

    subgraph "Static Assets"
        Static["public/"]:::config
    end

    subgraph "DevOps & Tooling"
        GH["GitHub"]:::devops
        CI[".github/workflows/ci.yml"]:::devops
        Husky[".husky/"]:::devops
        Commitlint[".commitlintrc.json"]:::devops
        ESLint["eslint.config.mjs"]:::devops
        Prettier[".prettierrc.json"]:::devops
        Renovate["renovate.json"]:::devops
    end

    Layout -->|"requests"| NextConfig
    Page -->|"requests"| NextConfig
    PageCSS -->|"serves styles"| NextConfig
    Globals -->|"loads global CSS"| NextConfig
    NextConfig -->|"applies redirects"| Redirects
    NextConfig -->|"reads env schema"| EnvClient
    NextConfig -->|"reads env schema"| EnvServer
    Layout -->|"requests"| Static
    Page -->|"requests"| Static

    GH -->|"push/PR triggers"| CI
    Husky -->|"runs hooks"| ESLint
    Husky -->|"runs hooks"| Prettier
    Husky -->|"runs hooks"| Commitlint

    classDef frontend fill:#cce5ff,stroke:#3399ff,color:#004085;
    classDef backend fill:#d4edda,stroke:#28a745,color:#155724;
    classDef config fill:#e2e3e5,stroke:#6c757d,color:#383d41;
    classDef devops fill:#ffe5b4,stroke:#ff9900,color:#663400;

    click Layout "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/src/app/layout.tsx"
    click Page "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/src/app/page.tsx"
    click PageCSS "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/src/app/page.module.css"
    click Globals "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/src/app/globals.css"
    click NextConfig "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/next.config.ts"
    click Redirects "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/redirects.ts"
    click EnvClient "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/src/lib/env/client.ts"
    click EnvServer "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/src/lib/env/server.ts"
    click Static "https://github.com/jpedroschmitz/typescript-nextjs-starter/tree/main/public/"
    click CI "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/.github/workflows/ci.yml"
    click Husky "https://github.com/jpedroschmitz/typescript-nextjs-starter/tree/main/.husky/"
    click Commitlint "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/.commitlintrc.json"
    click ESLint "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/eslint.config.mjs"
    click Prettier "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/.prettierrc.json"
    click Renovate "https://github.com/jpedroschmitz/typescript-nextjs-starter/blob/main/renovate.json"
```
