# macksimbondarew/fullstack-auth architecture

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

- Interactive diagram: https://gitdiagram.com/macksimbondarew/fullstack-auth
- Repository: https://github.com/macksimbondarew/fullstack-auth

## Overview

##### Project type and purpose
- This is a full‑stack web application.
- Frontend: Next.js (React + TypeScript)
- Backend: NestJS (Node.js + TypeScript)
- ORM/DB layer: Prisma (PostgreSQL)
- Features: user registration/login, email confirmation, password recovery, two‑factor authentication, OAuth social login

##### File structure
- Top‑level directories:
- frontend/ → a Next.js “app”‑directory project with feature slices under src/app and src/features
- nestjs-server/ → a modular NestJS server with controllers, services, DTOs, Prisma schema and generated client
- Frontend patterns:
- src/app for route‑based pages (auth, dashboard, settings, etc.)
- src/features for domain logic (auth, user) using hooks, services, schemes, component libraries
- src/shared for cross‑cutting pieces: API client, UI components, providers (TanStack Query, theme, toast), utils
- Backend patterns:
- Nest modules: auth (with sub‑modules: email‑confirmation, password‑recovery, provider/OAuth, 2FA), user, prisma, mail, common libs
- Layered MVC: controllers → services → Prisma ORM → database
- Config files for mailer, session, recaptcha, OAuth providers

##### Key insights (README is blank, so inferred from structure)
- REST API with JSON payloads
- External dependencies: SMTP/email service, OAuth providers (Google, Yandex), reCAPTCHA

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Layers
    Browser["Browser"]:::external
    subgraph "Frontend Layer"
        direction TB
        NextJS["Next.js Frontend"]:::frontend

        subgraph "Pages"
            direction TB
            Login["Login"]:::frontend
            Register["Register"]:::frontend
            NewPassword["New Password"]:::frontend
            EmailVerification["Email Verification"]:::frontend
            ResetPassword["Reset Password"]:::frontend
            Dashboard["Dashboard"]:::frontend
            Settings["Settings"]:::frontend
        end

        subgraph "Features"
            direction TB
            AuthFeature["Auth Feature Logic"]:::frontend
            UserFeature["User Feature Logic"]:::frontend
        end

        subgraph "Shared"
            direction TB
            APIClient["API Client"]:::frontend
            UIComponents["UI Components"]:::frontend
            Providers["Providers (Query, Theme, Toast)"]:::frontend
            Utils["Utils & Styles"]:::frontend
        end
    end

    subgraph "Backend Layer"
        direction TB
        Main["nestjs-server/src/main.ts"]:::backend

        subgraph "Auth Module"
            direction TB
            AuthModule["Auth Module"]:::backend
            EmailConfirm["Email Confirmation Sub-Mod"]:::backend
            PasswordRecovery["Password Recovery Sub-Mod"]:::backend
            OAuthProvider["OAuth Provider Sub-Mod"]:::backend
            TwoFA["Two-Factor Auth Sub-Mod"]:::backend
        end

        UserModule["User Module"]:::backend
        PrismaModule["Prisma Module"]:::backend
        MailModule["Mail Module"]:::backend
        Common["Common Utils & Guards"]:::backend
    end

    subgraph "Data Layer"
        DB["PostgreSQL Database"]:::database
    end

    subgraph "External Services"
        direction TB
        SMTP["SMTP Mail Server"]:::external
        OAuthProviders["OAuth Providers (Google, Yandex)"]:::external
        reCAPTCHA["reCAPTCHA Service"]:::external
    end

    %% Connections
    Browser --> NextJS
    NextJS --> Login
    NextJS --> Register
    NextJS --> NewPassword
    NextJS --> EmailVerification
    NextJS --> ResetPassword
    NextJS --> Dashboard
    NextJS --> Settings
    NextJS --> AuthFeature
    NextJS --> UserFeature
    NextJS --> APIClient
    NextJS --> Providers
    NextJS --> UIComponents
    NextJS --> Utils

    APIClient -->|HTTP REST| Main
    Main --> AuthModule
    Main --> UserModule
    AuthModule --> EmailConfirm
    AuthModule --> PasswordRecovery
    AuthModule --> OAuthProvider
    AuthModule --> TwoFA
    AuthModule --> Common
    AuthModule --> MailModule
    AuthModule --> reCAPTCHA
    PasswordRecovery --> MailModule
    MailModule --> SMTP
    OAuthProvider --> OAuthProviders
    AuthModule --> PrismaModule
    UserModule --> PrismaModule
    PrismaModule --> DB

    %% Click Events
    click NextJS "https://github.com/macksimbondarew/fullstack-auth/tree/main/frontend/src"
    click Login "https://github.com/macksimbondarew/fullstack-auth/blob/main/frontend/src/app/auth/login/page.tsx"
    click Register "https://github.com/macksimbondarew/fullstack-auth/blob/main/frontend/src/app/auth/register/page.tsx"
    click NewPassword "https://github.com/macksimbondarew/fullstack-auth/blob/main/frontend/src/app/auth/new-password/page.tsx"
    click EmailVerification "https://github.com/macksimbondarew/fullstack-auth/blob/main/frontend/src/app/auth/new-verification/page.tsx"
    click ResetPassword "https://github.com/macksimbondarew/fullstack-auth/blob/main/frontend/src/app/auth/reset-password/page.tsx"
    click Dashboard "https://github.com/macksimbondarew/fullstack-auth/tree/main/frontend/src/app/dashboard"
    click Settings "https://github.com/macksimbondarew/fullstack-auth/blob/main/frontend/src/app/dashboard/settings/page.tsx"
    click AuthFeature "https://github.com/macksimbondarew/fullstack-auth/tree/main/frontend/src/features/auth"
    click UserFeature "https://github.com/macksimbondarew/fullstack-auth/tree/main/frontend/src/features/user"
    click APIClient "https://github.com/macksimbondarew/fullstack-auth/blob/main/frontend/src/shared/api/instance.api.ts"
    click UIComponents "https://github.com/macksimbondarew/fullstack-auth/tree/main/frontend/src/shared/components/ui"
    click Providers "https://github.com/macksimbondarew/fullstack-auth/tree/main/frontend/src/shared/providers"
    click Utils "https://github.com/macksimbondarew/fullstack-auth/tree/main/frontend/src/shared/utils"
    click Main "https://github.com/macksimbondarew/fullstack-auth/blob/main/nestjs-server/src/main.ts"
    click AuthModule "https://github.com/macksimbondarew/fullstack-auth/blob/main/nestjs-server/src/auth/auth.module.ts"
    click EmailConfirm "https://github.com/macksimbondarew/fullstack-auth/blob/main/nestjs-server/src/auth/email-confirmation/email-confirmation.module.ts"
    click PasswordRecovery "https://github.com/macksimbondarew/fullstack-auth/blob/main/nestjs-server/src/auth/password-recovery/password-recovery.module.ts"
    click OAuthProvider "https://github.com/macksimbondarew/fullstack-auth/blob/main/nestjs-server/src/auth/provider/provider.module.ts"
    click TwoFA "https://github.com/macksimbondarew/fullstack-auth/blob/main/nestjs-server/src/auth/two-factor-auth/two-factor-auth.module.ts"
    click UserModule "https://github.com/macksimbondarew/fullstack-auth/blob/main/nestjs-server/src/user/user.module.ts"
    click PrismaModule "https://github.com/macksimbondarew/fullstack-auth/blob/main/nestjs-server/src/prisma/prisma.module.ts"
    click MailModule "https://github.com/macksimbondarew/fullstack-auth/blob/main/nestjs-server/src/libs/mail/mail.module.ts"
    click Common "https://github.com/macksimbondarew/fullstack-auth/tree/main/nestjs-server/src/libs/common"

    %% Styles
    classDef frontend fill:#e0f7fa,stroke:#006064,stroke-width:1px
    classDef backend fill:#e8eaf6,stroke:#303f9f,stroke-width:1px
    classDef database fill:#e8f5e9,stroke:#1b5e20,stroke-width:1px
    classDef external fill:#fff3e0,stroke:#e65100,stroke-width:1px
```
