# noxify/turbo-lucia-starter architecture

> Architecture diagram of the GitHub repository noxify/turbo-lucia-starter, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/noxify/turbo-lucia-starter
- Repository: https://github.com/noxify/turbo-lucia-starter

## Overview

##### Main Components

a) Frontend Layer (Next.js Application):
- Authentication Routes (/auth)
- Protected Dashboard Routes
- API Routes (for auth providers)
- Internationalization System
- Components Layer

b) Authentication Layer:
- Provider Connections (GitHub, Discord, Mock)
- Session Management
- User Management

c) Database Layer:
- PostgreSQL Database container with tables:
- Users
- OAuth Accounts
- Sessions

d) Package Ecosystem:
- UI Components (shadcn/ui based)
- Localization
- Database Access
- Helpers
- Logging
- Search Parameters

##### Relationships and Data Flow

- User authentication flow through providers
- API routes communication with auth layer
- Database interactions
- Package dependencies and usage

##### Specific Implementation Details

**[External Auth Providers] <---> [Next.js API Routes]**
- ↓
**[Lucia Auth Layer] <---> [Database Layer]**
- ↑
**[Frontend Routes/Components]**
- ↙   ↓    ↘
**[UI] [Locales] [Helpers]**

##### Key Technical Elements to Highlight
- Turborepo workspace structure
- Next.js 15.1 app router architecture
- Drizzle ORM integration
- Internationalization with next-intl
- Playwright test infrastructure

##### Development Tools Integration
- A section showing CI/CD workflow
- Testing infrastructure (Playwright)
- Tooling configuration flow

- Monorepo structure with clear package separation
- Authentication flow with multiple providers
- Database schema relationships
- Frontend routing and protection
- Shared package utilization

- Component grouping
- External service integration

- Clear separation of concerns
- Modular package structure
- Type-safe database access
- Secure authentication implementation
- Comprehensive testing capabilities
- Internationalization support
- Scalable UI component system

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        FE["Next.js Frontend"]
        AuthRoutes["Authentication Routes"]:::frontend
        DashRoutes["Dashboard Routes"]:::frontend
        APIRoutes["API Routes"]:::frontend
        I18N["Internationalization"]:::frontend
        Components["Components Layer"]:::frontend
        
        FE --> AuthRoutes
        FE --> DashRoutes
        FE --> APIRoutes
        FE --> I18N
        FE --> Components
    end

    subgraph "Authentication Layer"
        LA["Lucia Auth"]:::auth
        GitHub["GitHub Provider"]:::auth
        Discord["Discord Provider"]:::auth
        Mock["Mock Provider"]:::auth
        UserMgmt["User Management"]:::auth
        
        LA --> GitHub
        LA --> Discord
        LA --> Mock
        LA --> UserMgmt
    end

    subgraph "Database Layer"
        DB[(PostgreSQL)]:::db
        Users[("Users Table")]:::db
        OAuth[("OAuth Accounts")]:::db
        Sessions[("Sessions")]:::db
        
        DB --> Users
        DB --> OAuth
        DB --> Sessions
    end

    subgraph "Shared Packages"
        UI["UI Components"]:::package
        Locales["Localization"]:::package
        DBAccess["Database Access"]:::package
        Helpers["Helpers"]:::package
        Logging["Logging"]:::package
        SearchParams["Search Parameters"]:::package
    end

    subgraph "Development Tools"
        Playwright["Testing (Playwright)"]:::tools
        ESLint["ESLint"]:::tools
        TypeScript["TypeScript"]:::tools
        Tailwind["Tailwind"]:::tools
    end

    APIRoutes --> LA
    LA --> DB
    AuthRoutes --> LA
    DashRoutes --> LA

    classDef frontend fill:#3498db,stroke:#2980b9,color:#fff
    classDef auth fill:#2ecc71,stroke:#27ae60,color:#fff
    classDef db fill:#f1c40f,stroke:#f39c12,color:#000
    classDef package fill:#9b59b6,stroke:#8e44ad,color:#fff
    classDef tools fill:#95a5a6,stroke:#7f8c8d,color:#fff

    click FE "https://github.com/noxify/turbo-lucia-starter/tree/main/apps/nextjs/"
    click AuthRoutes "https://github.com/noxify/turbo-lucia-starter/tree/main/apps/nextjs/src/app/[locale]/(unauthorized)/auth/"
    click DashRoutes "https://github.com/noxify/turbo-lucia-starter/tree/main/apps/nextjs/src/app/[locale]/(authorized)/(dashboard)/"
    click APIRoutes "https://github.com/noxify/turbo-lucia-starter/tree/main/apps/nextjs/src/app/api/auth/"
    click Components "https://github.com/noxify/turbo-lucia-starter/tree/main/apps/nextjs/src/components/"
    click GitHub "https://github.com/noxify/turbo-lucia-starter/blob/main/packages/auth/src/providers/github.ts"
    click Discord "https://github.com/noxify/turbo-lucia-starter/blob/main/packages/auth/src/providers/discord.ts"
    click Mock "https://github.com/noxify/turbo-lucia-starter/blob/main/packages/auth/src/providers/mock-provider.ts"
    click UserMgmt "https://github.com/noxify/turbo-lucia-starter/blob/main/packages/auth/src/user-handler.ts"
    click DBAccess "https://github.com/noxify/turbo-lucia-starter/tree/main/packages/db/"
    click UI "https://github.com/noxify/turbo-lucia-starter/tree/main/packages/ui/"
    click Locales "https://github.com/noxify/turbo-lucia-starter/tree/main/packages/locales/"
    click Helpers "https://github.com/noxify/turbo-lucia-starter/tree/main/packages/helpers/"
    click Logging "https://github.com/noxify/turbo-lucia-starter/tree/main/packages/logging/"
    click SearchParams "https://github.com/noxify/turbo-lucia-starter/tree/main/packages/search-params/"
    click Playwright "https://github.com/noxify/turbo-lucia-starter/tree/main/tooling/playwright/"
    click ESLint "https://github.com/noxify/turbo-lucia-starter/tree/main/tooling/eslint/"
    click TypeScript "https://github.com/noxify/turbo-lucia-starter/tree/main/tooling/typescript/"
    click Tailwind "https://github.com/noxify/turbo-lucia-starter/tree/main/tooling/tailwind/"
    click I18N "https://github.com/noxify/turbo-lucia-starter/blob/main/apps/nextjs/src/i18n.ts"
```
