# oanaspatacean/bookishhub architecture

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

- Interactive diagram: https://gitdiagram.com/oanaspatacean/bookishhub
- Repository: https://github.com/oanaspatacean/bookishhub

## Overview

##### Project type and purpose
- From the file tree and minimal README, we see “BookishHub” is a full-stack Next.js application.
- It provides user-facing pages (PDF upload/breakdown, language lessons, account management) and an admin console (user, PDF, lesson, assessment management).
- It exposes numerous RESTful API routes under `app/api/...` for language processing, authentication, payments, PDF summarization, etc.

##### File structure
- Top-level “bookishhub/app” holds Next.js “app router” pages. Subfolders divide into public routes (`page.tsx`) and dynamic routes (`[fileId]`, `[languageId]`, etc).
- The “app/api” directory defines API endpoints—grouped by feature (auth, payment, language, admin, PDF).
- “components” contains reusable React UI pieces. “lib” contains server-side utility modules (database, authentication, OpenAI, S3, payment).
- “prisma/schema.prisma” defines the database. Config files include Next.js, Tailwind, ESLint, TS.

##### Additional README insights
- Although the README is empty, the file names imply integration with:
- A relational database via Prisma
- AWS S3 for PDF storage
- OpenAI for summaries, translations, pronunciations
- Stripe (or similar) via lib/payment.ts for membership
- Unsplash / YouTube for media

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph "Client Layer" 
        direction TB
        Client["Web/Mobile Client"]:::client
    end

    %% Frontend Layer
    subgraph "Next.js Frontend" 
        direction TB
        Frontend["Next.js Frontend (app/)"]:::frontend
        UIComponents["UI Components (components/)"]:::frontend
        SharedUI["Shared UI Primitives (components/ui/)"]:::frontend
    end

    %% API Layer
    subgraph "Next.js API" 
        direction TB
        API["Next.js API Routes (app/api/)"]:::api
    end

    %% Service Layer
    subgraph "Service Modules" 
        direction TB
        AuthService["Authentication Service"]:::service
        DBService["Database Service"]:::service
        Membership["Membership Logic"]:::service
        PaymentService["Payment Gateway Integration"]:::service
        OpenAIService["OpenAI Service"]:::service
        S3Service["AWS S3 Storage Service"]:::service
        UnsplashService["Unsplash Integration"]:::service
        YouTubeService["YouTube Integration"]:::service
        Utils["Utility Helpers"]:::service
    end

    %% Data & Storage Layer
    subgraph "Data & Storage" 
        direction TB
        Database["Prisma Database (PostgreSQL/MySQL)"]:::database
    end

    %% External Services
    subgraph "External Third-Party Services" 
        direction TB
        ExternalOpenAI["OpenAI API"]:::external
        ExternalS3["AWS S3"]:::external
        ExternalStripe["Stripe"]:::external
        ExternalUnsplash["Unsplash"]:::external
        ExternalYouTube["YouTube API"]:::external
    end

    %% Connections
    Client -->|"HTTP/HTTPS"| Frontend
    Frontend -->|"Renders Pages / SSR"| UIComponents
    Frontend -->|"Uses Primitives"| SharedUI
    Frontend -->|"fetch/XHR"| API

    API -->|"calls auth"| AuthService
    API -->|"calls membership"| Membership
    API -->|"calls payment"| PaymentService
    API -->|"calls OpenAI"| OpenAIService
    API -->|"calls S3"| S3Service
    API -->|"calls Unsplash"| UnsplashService
    API -->|"calls YouTube"| YouTubeService
    API -->|"uses utils"| Utils
    API -->|"uses DB client"| DBService

    AuthService -->|"queries"| DBService
    Membership -->|"reads/writes"| DBService
    PaymentService -->|"reads/writes"| DBService
    PaymentService -->|"processes payments"| ExternalStripe
    Membership -->|"manages subscription"| ExternalStripe
    OpenAIService -->|"requests"| ExternalOpenAI
    S3Service -->|"uploads/downloads"| ExternalS3
    UnsplashService -->|"fetches images"| ExternalUnsplash
    YouTubeService -->|"fetches video data"| ExternalYouTube
    DBService -->|"connects to"| Database

    %% Click Events
    click Frontend "https://github.com/oanaspatacean/bookishhub/tree/master/bookishhub/app/"
    click API "https://github.com/oanaspatacean/bookishhub/tree/master/bookishhub/app/api/"
    click UIComponents "https://github.com/oanaspatacean/bookishhub/tree/master/bookishhub/components/"
    click SharedUI "https://github.com/oanaspatacean/bookishhub/tree/master/bookishhub/components/ui/"
    click AuthService "https://github.com/oanaspatacean/bookishhub/blob/master/bookishhub/app/api/auth/[...nextauth]/route.ts"
    click AuthService "https://github.com/oanaspatacean/bookishhub/blob/master/bookishhub/lib/authentication.ts"
    click DBService "https://github.com/oanaspatacean/bookishhub/blob/master/bookishhub/lib/database.ts"
    click Membership "https://github.com/oanaspatacean/bookishhub/blob/master/bookishhub/lib/membership.ts"
    click PaymentService "https://github.com/oanaspatacean/bookishhub/blob/master/bookishhub/lib/payment.ts"
    click PaymentService "https://github.com/oanaspatacean/bookishhub/blob/master/bookishhub/app/api/payment/route.ts"
    click OpenAIService "https://github.com/oanaspatacean/bookishhub/blob/master/bookishhub/lib/openai.ts"
    click S3Service "https://github.com/oanaspatacean/bookishhub/blob/master/bookishhub/lib/s3.ts"
    click UnsplashService "https://github.com/oanaspatacean/bookishhub/blob/master/bookishhub/lib/unsplash.ts"
    click YouTubeService "https://github.com/oanaspatacean/bookishhub/blob/master/bookishhub/lib/yt.ts"
    click Utils "https://github.com/oanaspatacean/bookishhub/blob/master/bookishhub/lib/utils.ts"
    click Database "https://github.com/oanaspatacean/bookishhub/blob/master/bookishhub/prisma/schema.prisma"

    %% Styles
    classDef client fill:#D6EFFF,stroke:#0366d6,color:#0366d6;
    classDef frontend fill:#E8F5FF,stroke:#1E90FF,color:#1E90FF;
    classDef api fill:#E0F7EA,stroke:#00A676,color:#00A676;
    classDef service fill:#F5F5F5,stroke:#888888,color:#444444;
    classDef database fill:#FFE8A1,stroke:#FFB300,color:#FF8C00;
    classDef external fill:#F3E8FF,stroke:#A855F7,color:#7C3AED;
```
