# nathan20021/summer-portfolio architecture

> Architecture diagram of the GitHub repository nathan20021/summer-portfolio, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nathan20021/summer-portfolio
- Repository: https://github.com/nathan20021/summer-portfolio

## Overview

##### Main System Components

a) Frontend Layer:
- Next.js Client-Side Components (under /components)
- Page Routes (under /pages)
- Static Assets (under /public)

b) Backend Layer:
- API Routes (under /pages/api)
- Authentication System (using NextAuth.js)
- Database Layer (Prisma ORM)

c) External Services:
- AWS S3 for file storage
- Database (likely PostgreSQL, based on Prisma schema)

##### Component Relationships

a) Client-Side Flow:
- How pages connect to components
- Component hierarchy (Layout → Nav → specific components)
- Demonstrate how hooks (/hooks) interact with components

b) Data Flow:
- API routes handling
- Authentication flow
- File management with S3
- Blog content management

##### Specific Implementation Details

Create sections for:

a) Blog System:
- Content Management (Editor components)
- Storage (S3 integration)
- Rendering (Markdown components)
- Analytics tracking

b) Authentication:
- NextAuth.js flow
- User management
- Protected routes

##### Key Architectural Patterns to Highlight

- Next.js Pages Router architecture
- API Routes pattern
- Component composition pattern
- Server-side vs Client-side rendering
- File storage architecture

##### Detailed Component Breakdown

Create subsections for:

a) Core Components:
- Blog components
- Analytics components
- Editor components
- File Tree components

b) Utility Services:
- AWS S3 integration
- Authentication
- Database operations
- API endpoints

##### Technical Stack Indicators

Technology badges for:
- Next.js
- React
- Tailwind CSS
- Prisma
- AWS S3
- NextAuth.js
- TypeScript

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        Pages[Pages]
        Components[Components]
        StaticAssets[Static Assets]:::static
        Pages --> Components
        Components --> StaticAssets
    end

    subgraph Core["Core Components"]
        Layout[Layout]:::component
        Nav[Navigation]:::component
        Footer[Footer]:::component
        Layout --> Nav
        Layout --> Footer
    end

    subgraph BlogSystem["Blog System"]
        BlogComponents[Blog Components]:::component
        BlogPages[Blog Pages]:::page
        BlogAPI[Blog API]:::api
        Templates[Templates]:::static
        BlogComponents --> BlogPages
        BlogPages --> BlogAPI
        BlogComponents --> Templates
    end

    subgraph Analytics["Analytics System"]
        AnalyticsComponents[Analytics Components]:::component
        BlogStats[Blog Stats API]:::api
        AnalyticsComponents --> BlogStats
    end

    subgraph Editor["Editor System"]
        EditorComponents[Editor Components]:::component
        EditorPages[Editor Pages]:::page
        BlogUpdateAPI[Blog Update API]:::api
        BlogCreateAPI[Blog Create API]:::api
        EditorComponents --> EditorPages
        EditorPages --> BlogUpdateAPI
        EditorPages --> BlogCreateAPI
    end

    subgraph FileManagement["File Management"]
        FileTreeComponents[File Tree Components]:::component
        AWSLib[AWS Integration]:::service
        S3FileAPI[S3 File API]:::api
        S3FolderAPI[S3 Folder API]:::api
        FileTreeComponents --> AWSLib
        AWSLib --> S3FileAPI
        AWSLib --> S3FolderAPI
    end

    subgraph Auth["Authentication"]
        NextAuth[NextAuth API]:::api
        UserAPI[User API]:::api
        LoginPage[Login Page]:::page
        NextAuth --> UserAPI
        LoginPage --> NextAuth
    end

    subgraph Database["Database Layer"]
        PrismaSchema[Prisma Schema]:::db
        DBConfig[Database Config]:::db
    end

    subgraph MarkdownSystem["Markdown Processing"]
        MarkdownComponents[Markdown Components]:::component
        RemarkPlugins[Remark Plugins]:::util
        MarkdownComponents --> RemarkPlugins
    end

    subgraph Utils["Utilities"]
        Hooks[Hooks]:::util
        Types[Types]:::util
    end

    %% External Services
    AWS[AWS S3]:::external
    DB[(PostgreSQL)]:::external

    %% Connections
    FileManagement --> AWS
    Database --> DB
    Components --> Core
    Components --> BlogSystem
    Components --> Analytics
    Components --> Editor
    Components --> FileManagement
    Components --> MarkdownSystem

    %% Styling
    classDef component fill:#2563eb,color:white
    classDef page fill:#4b5563,color:white
    classDef api fill:#22c55e,color:white
    classDef service fill:#eab308,color:white
    classDef db fill:#9333ea,color:white
    classDef external fill:#ef4444,color:white
    classDef static fill:#64748b,color:white
    classDef util fill:#6b7280,color:white

    %% Click Events
    click Layout "https://github.com/nathan20021/summer-portfolio/blob/main//components/Layout.tsx"
    click Nav "https://github.com/nathan20021/summer-portfolio/blob/main//components/Nav.tsx"
    click Footer "https://github.com/nathan20021/summer-portfolio/blob/main//components/Footer.tsx"
    click BlogComponents "https://github.com/nathan20021/summer-portfolio/tree/main//components/Blog"
    click BlogPages "https://github.com/nathan20021/summer-portfolio/tree/main//pages/blogs"
    click BlogAPI "https://github.com/nathan20021/summer-portfolio/tree/main//pages/api/blog"
    click Templates "https://github.com/nathan20021/summer-portfolio/tree/main//public/posts/templates"
    click AnalyticsComponents "https://github.com/nathan20021/summer-portfolio/tree/main//components/Analytics"
    click BlogStats "https://github.com/nathan20021/summer-portfolio/blob/main//pages/api/blogStats.ts"
    click EditorComponents "https://github.com/nathan20021/summer-portfolio/tree/main//components/Editor"
    click EditorPages "https://github.com/nathan20021/summer-portfolio/tree/main//pages/admin/editor"
    click BlogUpdateAPI "https://github.com/nathan20021/summer-portfolio/blob/main//pages/api/blog/update.ts"
    click BlogCreateAPI "https://github.com/nathan20021/summer-portfolio/blob/main//pages/api/blog/create.ts"
    click FileTreeComponents "https://github.com/nathan20021/summer-portfolio/tree/main//components/FileTree"
    click AWSLib "https://github.com/nathan20021/summer-portfolio/blob/main//lib/aws-lib.ts"
    click S3FileAPI "https://github.com/nathan20021/summer-portfolio/tree/main//pages/api/s3-blog-file"
    click S3FolderAPI "https://github.com/nathan20021/summer-portfolio/tree/main//pages/api/s3-blog-folder"
    click NextAuth "https://github.com/nathan20021/summer-portfolio/blob/main//pages/api/auth/[...nextauth].js"
    click UserAPI "https://github.com/nathan20021/summer-portfolio/tree/main//pages/api/user"
    click LoginPage "https://github.com/nathan20021/summer-portfolio/blob/main//pages/login.tsx"
    click PrismaSchema "https://github.com/nathan20021/summer-portfolio/blob/main//prisma/schema.prisma"
    click DBConfig "https://github.com/nathan20021/summer-portfolio/blob/main//db.ts"
    click MarkdownComponents "https://github.com/nathan20021/summer-portfolio/tree/main//components/Markdown"
    click RemarkPlugins "https://github.com/nathan20021/summer-portfolio/tree/main//plugins/remark"
    click StaticAssets "https://github.com/nathan20021/summer-portfolio/tree/main//public"
    click Hooks "https://github.com/nathan20021/summer-portfolio/tree/main//hooks"
    click Types "https://github.com/nathan20021/summer-portfolio/tree/main//interfaces"
```
