# mickasmt/next-saas-stripe-starter architecture

> Architecture diagram of the GitHub repository mickasmt/next-saas-stripe-starter, 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/mickasmt/next-saas-stripe-starter
- Repository: https://github.com/mickasmt/next-saas-stripe-starter

## Overview

##### Main System Components

a) Frontend Layer:
- Marketing Pages (/(marketing) routes)
- Authentication Pages (/(auth) routes)
- Protected Dashboard (/(protected) routes)
- Documentation Pages (/(docs) routes)
- Blog System

b) Backend Layer:
- API Routes (/app/api)
- Authentication System (Auth.js)
- Database Layer (Prisma + Neon PostgreSQL)
- Email System (Resend + React Email)
- Payment System (Stripe Integration)

##### Key Architectural Elements

a) Next.js App Router Structure:
- Route grouping ((auth), (marketing), (protected), (docs))
- API routes organization
- Server and client components

b) Data Flow:
- Authentication flow with Auth.js
- API endpoints interaction
- Stripe webhook handling
- Email service integration

##### Integration Points

Clear connections between:
- Frontend components and API routes
- Authentication system and protected routes
- Stripe integration with billing features
- Database interactions through Prisma
- Email service integration points

##### Specific Implementation Details

a) Core Features:
- User authentication & authorization
- Subscription management
- Blog and documentation system
- Dashboard functionality

b) External Services:
- Neon PostgreSQL
- Stripe Payment Processing
- Resend Email Service
- Vercel Deployment

- Client Layer       |
- (Pages & Components)   |

- ↕

- API Layer          |
- (Routes & Endpoints)   |

- ↕

- Service Layer        |
- (Auth, Email, Payment) |

- ↕

- Database Layer       |
- (Prisma & Neon)       |

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        direction TB
        Marketing["Marketing Pages"]
        Auth["Auth Pages"]
        Dashboard["Dashboard"]
        Docs["Documentation"]
        Blog["Blog System"]
    end

    subgraph API["API Layer"]
        direction TB
        APIRoutes["API Routes"]:::api
        AuthSystem["Authentication System"]:::auth
        WebhookHandler["Webhook Handler"]:::api
    end

    subgraph Services["Service Layer"]
        direction TB
        EmailService["Email System"]:::service
        PaymentService["Payment System"]:::service
        ContentMgmt["Content Management"]:::service
        UserMgmt["User Management"]:::service
        SubMgmt["Subscription Management"]:::service
    end

    subgraph Data["Database Layer"]
        direction TB
        Prisma["Prisma ORM"]:::database
        PostgreSQL["Neon PostgreSQL"]:::database
    end

    %% Connections
    Marketing --> APIRoutes
    Auth --> AuthSystem
    Dashboard --> APIRoutes
    Docs --> ContentMgmt
    Blog --> ContentMgmt

    APIRoutes --> Services
    AuthSystem --> UserMgmt
    WebhookHandler --> PaymentService

    EmailService --> PostgreSQL
    PaymentService --> PostgreSQL
    UserMgmt --> Prisma
    SubMgmt --> Prisma
    
    Prisma --> PostgreSQL

    %% Click Events
    click Marketing "https://github.com/mickasmt/next-saas-stripe-starter/tree/main/app/(marketing)"
    click Auth "https://github.com/mickasmt/next-saas-stripe-starter/tree/main/app/(auth)"
    click Dashboard "https://github.com/mickasmt/next-saas-stripe-starter/tree/main/app/(protected)"
    click Docs "https://github.com/mickasmt/next-saas-stripe-starter/tree/main/app/(docs)"
    click Blog "https://github.com/mickasmt/next-saas-stripe-starter/tree/main/app/(marketing)/(blog-post)"
    
    click APIRoutes "https://github.com/mickasmt/next-saas-stripe-starter/tree/main/app/api"
    click AuthSystem "https://github.com/mickasmt/next-saas-stripe-starter/blob/main/auth.ts"
    click WebhookHandler "https://github.com/mickasmt/next-saas-stripe-starter/tree/main/app/api/webhooks/stripe"
    
    click EmailService "https://github.com/mickasmt/next-saas-stripe-starter/blob/main/lib/email.ts"
    click PaymentService "https://github.com/mickasmt/next-saas-stripe-starter/blob/main/lib/stripe.ts"
    click ContentMgmt "https://github.com/mickasmt/next-saas-stripe-starter/tree/main/content"
    click UserMgmt "https://github.com/mickasmt/next-saas-stripe-starter/blob/main/lib/user.ts"
    click SubMgmt "https://github.com/mickasmt/next-saas-stripe-starter/blob/main/lib/subscription.ts"
    
    click Prisma "https://github.com/mickasmt/next-saas-stripe-starter/blob/main/prisma/schema.prisma"

    %% Styles
    classDef frontend fill:#3b82f6,color:#fff
    classDef api fill:#fbbf24,color:#000
    classDef auth fill:#ef4444,color:#fff
    classDef service fill:#22c55e,color:#fff
    classDef database fill:#8b5cf6,color:#fff

    class Marketing,Auth,Dashboard,Docs,Blog frontend
    class APIRoutes,WebhookHandler api
    class AuthSystem auth
    class EmailService,PaymentService,ContentMgmt,UserMgmt,SubMgmt service
    class Prisma,PostgreSQL database

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        APIComponent["API Component"]:::api
        AuthComponent["Auth Component"]:::auth
        ServiceComponent["Service Component"]:::service
        DatabaseComponent["Database Component"]:::database
    end
```
