# bmurf17/down-the-hall architecture

> Architecture diagram of the GitHub repository bmurf17/down-the-hall, 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/bmurf17/down-the-hall
- Repository: https://github.com/bmurf17/down-the-hall

## Overview

##### Main System Components

A. Frontend Layer
- Client-Side Components (React/Next.js)
- Pages (/app directory structure)
- UI Components (/components directory)
- Client-Side Actions (/actions directory)

B. API Layer
- Next.js API Routes (/app/api directory)
- External API Integrations (Google Books, OpenLibrary, Hardcover)

C. Database Layer
- SQL Database (indicated by Drizzle ORM usage)
- Schema (defined in /lib/schema.ts)

D. Authentication Layer
- Firebase Authentication (indicated by firebase-config.ts)

##### Key Relationships to Highlight

- Client-to-API interactions
- API-to-Database flows
- External API integrations
- Authentication flows

##### Detailed Component Breakdown

Frontend Section:
- Pages
- Home (/)
- Book Details (/book/[bookId])
- Track (/track)
- Find (/find)
- Goals (/goals)
- Stats (/stats)

API Routes Section:
- /api
- books
- goals
- stats
- useractivitylog

##### Implementation Details

Specific features like:
- Book tracking functionality
- Reading goals system
- Statistics tracking
- User activity logging
- Book search and discovery

##### Technical Stack Indicators

- Next.js
- React
- TypeScript
- Drizzle ORM
- Firebase
- TailwindCSS
- External APIs

##### Data Flow Patterns

Illustrate:
- User interaction flows
- Data fetching patterns
- State management
- API request/response cycles

##### Data Persistence Layer (Bottom)

Remember to indicate the scalability points and potential areas for system expansion, as suggested by the modular structure of the components and the presence of multiple API integrations.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Frontend Layer"
        Pages["Pages"]:::frontend
        UIComponents["UI Components"]:::frontend
        ClientActions["Client Actions"]:::frontend

        subgraph "Pages Components"
            Home["Home Page"]:::frontend
            BookDetails["Book Details"]:::frontend
            Track["Track Page"]:::frontend
            Find["Find Page"]:::frontend
            Goals["Goals Page"]:::frontend
            Stats["Stats Page"]:::frontend
        end

        subgraph "UI Components"
            BasicUI["Basic UI"]:::frontend
            BookDetailsUI["Book Details UI"]:::frontend
            TrackUI["Track UI"]:::frontend
            GoalsUI["Goals UI"]:::frontend
            StatsUI["Stats UI"]:::frontend
            Nav["Navigation"]:::frontend
        end

        subgraph "Client Actions"
            BookAct["Book Actions"]:::frontend
            GoalsAct["Goals Actions"]:::frontend
            ExtAPIAct["External API Actions"]:::frontend
        end
    end

    subgraph "API Layer"
        BooksAPI["Books API"]:::api
        GoalsAPI["Goals API"]:::api
        StatsAPI["Stats API"]:::api
        UserActivityAPI["User Activity API"]:::api
    end

    subgraph "External APIs"
        GoogleBooks["Google Books API"]:::external
        OpenLibrary["OpenLibrary API"]:::external
        Hardcover["Hardcover API"]:::external
    end

    subgraph "Database Layer"
        DB[(SQL Database)]:::database
        Schema["Schema"]:::database
        Migrations["Migrations"]:::database
    end

    subgraph "Authentication Layer"
        FirebaseAuth["Firebase Auth"]:::auth
        UserMgmt["User Management"]:::auth
    end

    subgraph "Utils Layer"
        CoreUtils["Core Utils"]:::utils
        Helpers["Helpers"]:::utils
        Types["Type Definitions"]:::utils
    end

    %% Relationships
    Pages --> UIComponents
    UIComponents --> ClientActions
    ClientActions --> BooksAPI
    ClientActions --> GoalsAPI
    ClientActions --> StatsAPI
    ClientActions --> UserActivityAPI
    ClientActions --> ExtAPIAct
    ExtAPIAct --> GoogleBooks
    ExtAPIAct --> OpenLibrary
    ExtAPIAct --> Hardcover
    BooksAPI --> DB
    GoalsAPI --> DB
    StatsAPI --> DB
    UserActivityAPI --> DB
    DB --> Schema
    Schema --> Migrations
    FirebaseAuth --> UserMgmt
    UserMgmt --> Pages

    %% Click Events
    click Pages "https://github.com/bmurf17/down-the-hall/tree/master/app"
    click Home "https://github.com/bmurf17/down-the-hall/blob/master/app/page.tsx"
    click BookDetails "https://github.com/bmurf17/down-the-hall/blob/master/app/book/[bookId]/page.tsx"
    click Track "https://github.com/bmurf17/down-the-hall/blob/master/app/track/page.tsx"
    click Find "https://github.com/bmurf17/down-the-hall/blob/master/app/find/page.tsx"
    click Goals "https://github.com/bmurf17/down-the-hall/blob/master/app/goals/page.tsx"
    click Stats "https://github.com/bmurf17/down-the-hall/blob/master/app/stats/page.tsx"
    click UIComponents "https://github.com/bmurf17/down-the-hall/tree/master/components"
    click BasicUI "https://github.com/bmurf17/down-the-hall/tree/master/components/basicUI"
    click BookDetailsUI "https://github.com/bmurf17/down-the-hall/tree/master/components/bookDetails"
    click TrackUI "https://github.com/bmurf17/down-the-hall/tree/master/components/track"
    click GoalsUI "https://github.com/bmurf17/down-the-hall/tree/master/components/goals"
    click StatsUI "https://github.com/bmurf17/down-the-hall/tree/master/components/stats"
    click Nav "https://github.com/bmurf17/down-the-hall/tree/master/components/nav"
    click BookAct "https://github.com/bmurf17/down-the-hall/blob/master/actions/bookActions.ts"
    click GoalsAct "https://github.com/bmurf17/down-the-hall/blob/master/actions/goalsActions.ts"
    click ExtAPIAct "https://github.com/bmurf17/down-the-hall/blob/master/actions/googleBookActions.ts"
    click BooksAPI "https://github.com/bmurf17/down-the-hall/tree/master/app/api/books"
    click GoalsAPI "https://github.com/bmurf17/down-the-hall/tree/master/app/api/goals"
    click StatsAPI "https://github.com/bmurf17/down-the-hall/tree/master/app/api/stats"
    click UserActivityAPI "https://github.com/bmurf17/down-the-hall/tree/master/app/api/useractivitylog"
    click Schema "https://github.com/bmurf17/down-the-hall/blob/master/lib/schema.ts"
    click FirebaseAuth "https://github.com/bmurf17/down-the-hall/blob/master/lib/firebase-config.ts"
    click UserMgmt "https://github.com/bmurf17/down-the-hall/blob/master/components/UserManagement.tsx"
    click CoreUtils "https://github.com/bmurf17/down-the-hall/blob/master/lib/utils.ts"
    click Types "https://github.com/bmurf17/down-the-hall/tree/master/types"
    click Migrations "https://github.com/bmurf17/down-the-hall/tree/master/drizzle"

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