# thisnaeem/keyword-tool architecture

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

- Interactive diagram: https://gitdiagram.com/thisnaeem/keyword-tool
- Repository: https://github.com/thisnaeem/keyword-tool

## Overview

##### Main System Components

a) Frontend Layer:
- Sub-components:
- Landing Pages (/(landing))
- Authentication Pages (/(auth))
- Dashboard Pages (/dashboard)
- Admin Interface (/admin)
- Components Library

b) API Layer:
- Sub-routes:
- Authentication API (/api/auth)
- Admin API (/api/admin)
- Feedback API (/api/feedback)
- Search Volume API (/api/search-volume)

c) Backend Services:
- Database (Prisma + Database)
- Authentication Service (NextAuth.js)
- External Services:
- Gemini API (based on gemini.ts)
- Google Analytics

##### Architectural Patterns to Highlight

Following architectural patterns:
- Route Groups (indicated by the (auth), (landing) folders)
- API Route Handlers
- Server-side Components
- Client-side Components
- Database Layer

##### Data Flow Representation

- Client-Server Communication
- API Endpoints Communication
- Database Interactions
- Authentication Flow

##### Specific Implementation Details

- Prisma Schema (from prisma/schema.prisma)
- Authentication Flow (from lib/auth.ts)
- API Route Handlers
- Context Providers (from context/ConfigContext.tsx)

##### Component Organization

- Shared Components
- Admin Components
- Landing Components
- Dashboard Components

**[Client Layer (Browser)]**
- ↕
**[Next.js Frontend (Pages & Components)]**
- ↕
**[API Routes Layer]**
- ↕
**[Backend Services]**
- ↕
**[Database Layer]**

Important Considerations:

##### Search volume and keyword tools integration

Additional Elements to Include:

- Middleware functionality (from middleware.ts)
- Type definitions and validations
- Export functionality
- Tour/Onboarding system components

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        Browser["Web Browser"]
    end

    subgraph Frontend
        LP["Landing Pages"]:::frontend
        AP["Authentication Pages"]:::frontend
        DP["Dashboard Pages"]:::frontend
        AI["Admin Interface"]:::frontend
        CL["Components Library"]:::frontend
        TC["Tour/Onboarding"]:::frontend
        GA["Google Analytics"]:::external
    end

    subgraph APILayer
        AuthAPI["Authentication API"]:::api
        AdminAPI["Admin API"]:::api
        FeedbackAPI["Feedback API"]:::api
        SearchAPI["Search Volume API"]:::api
    end

    subgraph BackendServices
        AuthService["Authentication Service"]:::auth
        MW["Middleware"]:::service
        CP["Context Provider"]:::service
        Types["Type Definitions"]:::service
        Valid["Validation Services"]:::service
        Export["Export Service"]:::service
        GeminiAPI["Gemini API"]:::external
    end

    subgraph DataLayer
        DB[(Database)]:::database
        Prisma["Prisma Client"]:::database
    end

    %% Connections
    Browser --> LP & AP & DP & AI
    LP & AP & DP & AI --> APILayer
    APILayer --> BackendServices
    BackendServices --> DataLayer
    AuthService --> DB
    MW --> AuthService

    %% Click Events
    click LP "https://github.com/thisnaeem/keyword-tool/tree/main/app/(landing)"
    click AP "https://github.com/thisnaeem/keyword-tool/tree/main/app/(auth)"
    click DP "https://github.com/thisnaeem/keyword-tool/tree/main/app/dashboard"
    click AI "https://github.com/thisnaeem/keyword-tool/tree/main/app/admin"
    click CL "https://github.com/thisnaeem/keyword-tool/tree/main/components/"
    click AuthAPI "https://github.com/thisnaeem/keyword-tool/tree/main/app/api/auth"
    click AdminAPI "https://github.com/thisnaeem/keyword-tool/tree/main/app/api/admin"
    click FeedbackAPI "https://github.com/thisnaeem/keyword-tool/tree/main/app/api/feedback"
    click SearchAPI "https://github.com/thisnaeem/keyword-tool/tree/main/app/api/search-volume"
    click DB "https://github.com/thisnaeem/keyword-tool/tree/main/prisma/"
    click AuthService "https://github.com/thisnaeem/keyword-tool/blob/main/lib/auth.ts"
    click GeminiAPI "https://github.com/thisnaeem/keyword-tool/blob/main/lib/gemini.ts"
    click GA "https://github.com/thisnaeem/keyword-tool/blob/main/components/GoogleAnalytics.tsx"
    click MW "https://github.com/thisnaeem/keyword-tool/blob/main/middleware.ts"
    click CP "https://github.com/thisnaeem/keyword-tool/blob/main/context/ConfigContext.tsx"
    click Types "https://github.com/thisnaeem/keyword-tool/tree/main/types/"
    click Valid "https://github.com/thisnaeem/keyword-tool/tree/main/lib/validations/"
    click TC "https://github.com/thisnaeem/keyword-tool/blob/main/components/ClientOnboardingTour.tsx"
    click Export "https://github.com/thisnaeem/keyword-tool/blob/main/lib/export.ts"
    click Prisma "https://github.com/thisnaeem/keyword-tool/blob/main/lib/prisma.ts"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#e74c3c,stroke:#c0392b,color:white
    classDef database fill:#f39c12,stroke:#d35400,color:white
    classDef auth fill:#9b59b6,stroke:#8e44ad,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Component"]:::frontend
        API["API Route"]:::api
        Service["Service"]:::service
        Database["Database"]:::database
        Auth["Auth Service"]:::auth
        External["External Service"]:::external
    end
```
