# learningcampili/basic-auth architecture

> Architecture diagram of the GitHub repository learningcampili/basic-auth, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/learningcampili/basic-auth
- Repository: https://github.com/learningcampili/basic-auth

## Overview

##### Project type and purpose
- This is a full-stack web application built on Next.js (React) that provides user authentication, profile management, contact forms, and email workflows (confirmation, password reset).
- It uses Prisma as an ORM backed by a relational database (e.g., PostgreSQL), NextAuth for session management, a mailing library (in `src/lib/mail.ts` + JSX email templates), and Tailwind CSS for styling.

##### File structure
- Top-level:
- docker-compose.yml – brings up local services (database).
- prisma/ – schema and migrations for the database model.
- src/app/ – Next.js “app router” pages and API routes (server and client components).
- src/api/ – under app/api for NextAuth and email verification endpoints.
- src/components/ – reusable UI components (forms, navbar, avatars).
- src/actions/ – server-side business logic (auth, contacts, password resets).
- src/lib/ – helpers (Prisma client, mail sender, Zod schemas, utils).
- emails/ + src/templates/ – TSX templates for transactional emails.
- next.config.mjs, postcss.config.mjs, tailwind.config.ts, tsconfig.json – build and tooling config.

##### README for additional insights
- It’s a standard create-next-app scaffold, optimized for both server-rendered and static pages.

##### Elements
- Browser → Next.js UI
- Browser → API Routes → Actions → Prisma → DB
- Actions → Mail Service
- NextAuth → OAuth Providers
- Blue for UI layers,
- Green for business/data layers,
- Orange for external services.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Browser
    Browser["Browser"]:::client

    %% Frontend Layer
    subgraph "Frontend Layer"
        UI["Next.js UI Pages"]:::client
        Components["UI Components"]:::client
        Zod["Validation Schemas (Zod)"]:::client
        Utils["Utility Functions"]:::client
    end

    %% Backend Layer
    subgraph "Backend Layer"
        API["Next.js API Routes"]:::api
        AuthRoute["NextAuth Route Handler"]:::api
        AuthConfig["NextAuth Config & Types"]:::api
        Actions["Business Logic (Actions)"]:::business
        PrismaClient["Prisma Client"]:::data
        Mail["Email Service"]:::externalOrange
        Templates["Transactional Email Templates"]:::externalOrange
    end

    %% Infrastructure & External Services
    subgraph "Infrastructure & External Services"
        Docker["Docker Compose"]:::infra
        DB[(PostgreSQL Database)]:::database
        OAuth["OAuth Providers"]:::externalOrange
        SMTP["SMTP / SMTP API"]:::externalOrange
    end

    %% Connections
    Browser -->|"HTTP GET/JSX"| UI
    Browser -->|"AJAX HTTP"| API
    UI -->|"uses Zod"| Zod
    UI -->|"uses Utils"| Utils
    API -->|"calls"| Actions
    AuthRoute -->|"invokes auth actions"| Actions
    Actions -->|"ORM Query"| PrismaClient
    AuthRoute -->|"ORM Query"| PrismaClient
    PrismaClient -->|"SQL Query"| DB
    Actions -->|"sendEmail() via SMTP"| SMTP
    Mail -->|"SMTP API"| SMTP
    Actions -->|"uses mail templates"| Templates
    AuthRoute -->|"OAuth Flow"| OAuth
    Docker -->|"manages DB container"| DB

    %% Click Events
    click UI "https://github.com/learningcampili/basic-auth/tree/main/src/app/"
    click Components "https://github.com/learningcampili/basic-auth/tree/main/src/components/"
    click Zod "https://github.com/learningcampili/basic-auth/blob/main/src/lib/zod.ts"
    click Utils "https://github.com/learningcampili/basic-auth/blob/main/src/lib/utils.ts"
    click API "https://github.com/learningcampili/basic-auth/tree/main/src/app/api/"
    click Actions "https://github.com/learningcampili/basic-auth/tree/main/src/actions/"
    click PrismaClient "https://github.com/learningcampili/basic-auth/blob/main/src/lib/prisma.ts"
    click AuthRoute "https://github.com/learningcampili/basic-auth/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click AuthConfig "https://github.com/learningcampili/basic-auth/blob/main/src/auth.ts"
    click Mail "https://github.com/learningcampili/basic-auth/blob/main/src/lib/mail.ts"
    click Templates "https://github.com/learningcampili/basic-auth/tree/main/emails/"
    click Templates "https://github.com/learningcampili/basic-auth/tree/main/src/templates/"
    click Docker "https://github.com/learningcampili/basic-auth/blob/main/docker-compose.yml"

    %% Styles
    classDef client fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef api fill:#E0F7FA,stroke:#006064,color:#006064
    classDef business fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32
    classDef data fill:#E8F5E9,stroke:#388E3C,color:#388E3C
    classDef database fill:#E8F5E9,stroke:#1B5E20,color:#1B5E20
    classDef externalOrange fill:#FFF3E0,stroke:#EF6C00,color:#E65100
    classDef infra fill:#F3F4F6,stroke:#374151,color:#374151
    classDef external fill:#F3F4F6,stroke:#374151,color:#374151
```
