# lucenmae/meeples-landing architecture

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

- Interactive diagram: https://gitdiagram.com/lucenmae/meeples-landing
- Repository: https://github.com/lucenmae/meeples-landing

## Overview

##### Main System Components

A. Client Layer
- Components from src/components/* (UI, layout, admin, home)
- Key client-side features: Admin Dashboard, Game Management, Login System

B. Next.js Application Layer
- In the middle
- App Router structure (from src/app/*)
- API Routes (src/app/api/*)
- Authentication flow

C. Data & Services Layer
- At the bottom
- MongoDB connection
- External services (BoardGameGeek API integration)

##### Component Relationships

A. Frontend Flow
**User Interface (Components) → App Routes → API Routes → Data Layer**

B. Authentication Flow
**Login Component → NextAuth → MongoDB (Users)**

C. Game Management Flow
**Admin Components → API Routes → MongoDB (Games) ↔ BGG API**

##### Specific Implementation Details

Key architectural elements:

A. Authentication & Authorization
- NextAuth.js implementation (src/app/api/auth/[...nextauth])
- Session management
- Admin role verification (src/hooks/useAdmin.ts)

B. Data Management
- MongoDB models (User, Game)
- API route handlers
- BGG integration service

C. Frontend Architecture
- Component hierarchy
- UI component library
- Client-side state management

##### Additional Elements

Supporting components:
- Configuration files (next.config.js, tailwind.config.ts)
- Public assets structure
- Environment variables flow
- Type definitions (src/types/*)

##### Specific Notes for This Project

- The separation between admin and public interfaces
- The game inventory management system
- The authentication and authorization flow
- The integration with BoardGameGeek's API
- The MongoDB data model structure

##### Technical Stack Highlights

Key technologies:
- Next.js 13+ (App Router)
- MongoDB
- NextAuth.js
- Tailwind CSS
- TypeScript

Remember to:
- Clear data flow directions
- Notes for important configuration points
- Security boundaries
- Error handling paths

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client
        UI[Client Interface]
        CH[Client Home]:::client
        click CH "https://github.com/lucenmae/meeples-landing/blob/main/src/components/ClientHome.tsx"
        
        subgraph Admin
            AD[Dashboard]:::admin
            click AD "https://github.com/lucenmae/meeples-landing/blob/main/src/components/admin/Dashboard.tsx"
            GM[Game Management]:::admin
            click GM "https://github.com/lucenmae/meeples-landing/blob/main/src/components/admin/GameManagement.tsx"
            
            subgraph "Game Dialogs"
                AGD[Add Game Dialog]:::admin
                click AGD "https://github.com/lucenmae/meeples-landing/blob/main/src/components/admin/dialogs/AddGameDialog.tsx"
                EGD[Edit Game Dialog]:::admin
                click EGD "https://github.com/lucenmae/meeples-landing/blob/main/src/components/admin/dialogs/EditGameDialog.tsx"
                DGD[Delete Game Dialog]:::admin
                click DGD "https://github.com/lucenmae/meeples-landing/blob/main/src/components/admin/dialogs/DeleteGameDialog.tsx"
            end
        end
        
        subgraph "Layout Components"
            NB[Navbar]:::layout
            click NB "https://github.com/lucenmae/meeples-landing/blob/main/src/components/layout/Navbar.tsx"
            SB[Sidebar]:::layout
            click SB "https://github.com/lucenmae/meeples-landing/blob/main/src/components/layout/Sidebar.tsx"
        end
        
        LF[Login Form]:::auth
        click LF "https://github.com/lucenmae/meeples-landing/blob/main/src/components/login/LoginForm.tsx"
        SP[Session Provider]:::auth
        click SP "https://github.com/lucenmae/meeples-landing/blob/main/src/components/SessionProvider.tsx"
    end
    
    subgraph "Application Layer"
        direction TB
        
        subgraph "API Routes"
            AR_AUTH["/api/auth"]:::api
            click AR_AUTH "https://github.com/lucenmae/meeples-landing/blob/main/src/app/api/auth/[...nextauth]/route.ts"
            AR_GAMES["/api/games"]:::api
            click AR_GAMES "https://github.com/lucenmae/meeples-landing/blob/main/src/app/api/games/route.ts"
            AR_GAME_ID["/api/games/[id]"]:::api
            click AR_GAME_ID "https://github.com/lucenmae/meeples-landing/blob/main/src/app/api/games/[id]/route.ts"
            AR_BGG["/api/bgg-search"]:::api
            click AR_BGG "https://github.com/lucenmae/meeples-landing/blob/main/src/app/api/bgg-search/route.ts"
        end
        
        UA[Admin Authorization]:::auth
        click UA "https://github.com/lucenmae/meeples-landing/blob/main/src/hooks/useAdmin.ts"
        AU[Auth Utils]:::auth
        click AU "https://github.com/lucenmae/meeples-landing/blob/main/src/app/utils/auth.ts"
    end
    
    subgraph "Data Layer"
        MC[MongoDB Connection]:::db
        click MC "https://github.com/lucenmae/meeples-landing/blob/main/src/lib/mongodb.ts"
        
        subgraph "Database Models"
            GM_MODEL[Game Model]:::model
            click GM_MODEL "https://github.com/lucenmae/meeples-landing/blob/main/src/models/Game.ts"
            UM_MODEL[User Model]:::model
            click UM_MODEL "https://github.com/lucenmae/meeples-landing/blob/main/src/models/User.ts"
        end
        
        BGG_API[BoardGameGeek API]:::external
    end
    
    %% Connections
    UI --> CH
    UI --> Admin
    UI --> LF
    
    LF --> AR_AUTH
    AR_AUTH --> UM_MODEL
    
    AD --> GM
    GM --> AGD & EGD & DGD
    
    AGD & EGD & DGD --> AR_GAMES
    AR_GAMES --> GM_MODEL
    AR_GAMES --> BGG_API
    
    AR_BGG --> BGG_API
    
    GM_MODEL & UM_MODEL --> MC
    
    %% Styles
    classDef client fill:#E3F2FD,stroke:#2196F3
    classDef admin fill:#E8F5E9,stroke:#4CAF50
    classDef layout fill:#F3E5F5,stroke:#9C27B0
    classDef auth fill:#FFF3E0,stroke:#FF9800
    classDef api fill:#FFEBEE,stroke:#F44336
    classDef db fill:#E0F7FA,stroke:#00BCD4
    classDef model fill:#F5F5F5,stroke:#9E9E9E
    classDef external fill:#FFF8E1,stroke:#FFC107
    
    %% Legend
    subgraph Legend
        L1[Client Components]:::client
        L2[Admin Components]:::admin
        L3[Layout Components]:::layout
        L4[Auth Components]:::auth
        L5[API Routes]:::api
        L6[Database]:::db
        L7[Models]:::model
        L8[External Services]:::external
    end
```
