# sc30gsw/next15-first-sns-app-with architecture

> Architecture diagram of the GitHub repository sc30gsw/next15-first-sns-app-with, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sc30gsw/next15-first-sns-app-with
- Repository: https://github.com/sc30gsw/next15-first-sns-app-with

## Overview

##### Project type and purpose
- This is a full-stack Next.js application (using the App Router) that provides user authentication, posting, and liking functionality.
- Key indicators:
- `src/app/(auth)` and `src/features/auth` for sign-in/sign-up flows.
- `src/app/(posts)` and `src/features/posts` for CRUD operations on posts.
- A set of SQL migration scripts under `migrations/` and a Drizzle ORM config (`drizzle.config.ts`), indicating a relational database backend.

##### File structure
- Top-level directories and files:
- `src/app`: Next.js routes & layouts (split into `auth`, `posts`, and global layouts).
- `src/app/api`: API route handlers, including NextAuth (`src/app/api/auth/…`) and a wildcard route (`[[...route]]`).
- `src/components`: UI primitives and providers (theme, sidebar, toast, dialogs).
- `src/features`: Domain-driven modules for auth, posts, and likes (each with actions, components, types, server code for posts).
- `src/libs`: Shared libraries (authentication config, session helpers, database connection via Drizzle, fetchers, RPC utils).
- `migrations/`: SQL migrations + meta snapshots, confirming a relational DB like PostgreSQL.
- Build & config files: `next.config.ts`, `tsconfig.json`, Tailwind and PostCSS configs.

##### README for additional insights
- Uses `next/font` for font optimization and deploys on Vercel by default.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Frontend (AzureBlue)" 
        direction TB
        Client["Client Browser"]:::external
        UI["UI Pages & Layouts"]:::frontend
        GlobalLayout["Global Layout & Styling"]:::frontend
        AuthPages["Auth UI Routes"]:::frontend
        PostsPages["Posts UI Routes"]:::frontend
        SharedUI["Shared UI Components Library"]:::frontend
        SidebarProviders["App Sidebar & Providers"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend (ForestGreen)"
        direction TB
        NextServer["Next.js App Server"]:::backend
        Middleware["Middleware (Global Request Handling)"]:::backend
        APIRoutes["Next.js API Route Handlers"]:::backend
        NextAuthAPI["NextAuth API Routes"]:::backend
        AuthBL["Feature Module: Auth Business Logic"]:::backend
        PostsBL["Feature Module: Posts Business Logic"]:::backend
        LikesBL["Feature Module: Likes Business Logic"]:::backend
        AuthConfig["Authentication Config & Session Helpers"]:::backend
        RPCFetcher["RPC Utilities & Fetcher"]:::backend
        DrizzleConfig["Drizzle ORM Configuration"]:::backend
    end

    %% Database Layer
    subgraph "Database (CarrotOrange)"
        direction TB
        DB["PostgreSQL DB"]:::database
        Migrations["Database Migrations"]:::database
    end

    %% External Services
    subgraph "External (Gray)"
        direction TB
        Vercel["Vercel Hosting"]:::external
        FontCDN["Font CDN"]:::external
    end

    %% Connections
    Client -->|"SSR/SSG Requests"| NextServer
    Client -->|"API Calls"| APIRoutes
    NextServer -->|uses| Middleware
    APIRoutes -->|calls| AuthBL
    APIRoutes -->|calls| PostsBL
    APIRoutes -->|calls| LikesBL
    NextAuthAPI -->|session mgmt| NextServer
    NextAuthAPI -->|invokes| AuthConfig
    AuthBL -->|imports| AuthConfig
    AuthBL -->|calls| DB
    PostsBL -->|imports| RPCFetcher
    PostsBL -->|uses| DrizzleConfig
    AdsMiddleware---|applies| NextAuthAPI
    PostsBL -->|calls| DB
    LikesBL -->|calls| DB
    DrizzleConfig -->|connects| DB
    Migrations -->|migrates| DB
    NextServer -->|deploys on| Vercel
    Client -->|loads fonts| FontCDN

    %% Click Events
    click UI "https://github.com/sc30gsw/next15-first-sns-app-with/tree/main/src/app"
    click GlobalLayout "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/app/layout.tsx"
    click AuthPages "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/app/(auth)/sign-in/page.tsx"
    click AuthPages "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/app/(auth)/sign-up/page.tsx"
    click PostsPages "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/app/(posts)/page.tsx"
    click PostsPages "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/app/(posts)/[postId]/page.tsx"
    click APIRoutes "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/app/api/[[...route]]/route.ts"
    click NextAuthAPI "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click AuthBL "https://github.com/sc30gsw/next15-first-sns-app-with/tree/main/src/features/auth/actions"
    click AuthBL "https://github.com/sc30gsw/next15-first-sns-app-with/tree/main/src/features/auth/components"
    click AuthBL "https://github.com/sc30gsw/next15-first-sns-app-with/tree/main/src/features/auth/types"
    click PostsBL "https://github.com/sc30gsw/next15-first-sns-app-with/tree/main/src/features/posts/actions"
    click PostsBL "https://github.com/sc30gsw/next15-first-sns-app-with/tree/main/src/features/posts/components"
    click PostsBL "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/features/posts/server/route.ts"
    click PostsBL "https://github.com/sc30gsw/next15-first-sns-app-with/tree/main/src/features/posts/types"
    click LikesBL "https://github.com/sc30gsw/next15-first-sns-app-with/tree/main/src/features/likes/actions"
    click LikesBL "https://github.com/sc30gsw/next15-first-sns-app-with/tree/main/src/features/likes/components"
    click LikesBL "https://github.com/sc30gsw/next15-first-sns-app-with/tree/main/src/features/likes/types"
    click SharedUI "https://github.com/sc30gsw/next15-first-sns-app-with/tree/main/src/components/ui"
    click SidebarProviders "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/components/app-sidebar.tsx"
    click SidebarProviders "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/components/providers.tsx"
    click SidebarProviders "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/components/sidebar-provider.tsx"
    click SidebarProviders "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/components/sidebar-user-menu.tsx"
    click SidebarProviders "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/components/theme-provider.tsx"
    click DrizzleConfig "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/drizzle.config.ts"
    click DrizzleConfig "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/libs/db/drizzle.ts"
    click DrizzleConfig "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/libs/db/schema.ts"
    click Migrations "https://github.com/sc30gsw/next15-first-sns-app-with/tree/main/migrations/"
    click AuthConfig "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/libs/auth/config.ts"
    click AuthConfig "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/libs/auth/session.ts"
    click RPCFetcher "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/libs/rpc.ts"
    click RPCFetcher "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/libs/fetcher.ts"
    click Middleware "https://github.com/sc30gsw/next15-first-sns-app-with/blob/main/src/middleware.ts"

    %% Styles
    classDef frontend fill:#e0f7fa,stroke:#006064,color:#004d40
    classDef backend fill:#e8f5e9,stroke:#1b5e20,color:#2e7d32
    classDef database fill:#fff3e0,stroke:#ef6c00,color:#e65100
    classDef external fill:#f5f5f5,stroke:#9e9e9e,color:#616161
```
