# utkarshmohan2003/docsqueeze architecture

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

- Interactive diagram: https://gitdiagram.com/utkarshmohan2003/docsqueeze
- Repository: https://github.com/utkarshmohan2003/docsqueeze

## Overview

##### Project type and purpose
- DocSqueeze is a full-stack SaaS application for uploading PDF documents and generating AI-powered summaries.
- Built on Next.js (App Router), it uses Prisma ORM + SQLite for persistence, Clerk for auth, UploadThing for file uploads, and Google Gemini Flash 2.0 for summarization.

##### File structure
- **app/**
- Pages & layouts (App Router)
- `app/page.tsx` (public home)
- `app/sign-in`, `app/sign-up` (Clerk auth flows)
- `app/(logged-in)/upload` & `app/(logged-in)/your-summaries` (protected pages)
- `app/api/uploadthing/route.ts` (UploadThing serverless route)
- **components/**
- Reusable UI: common (header, footer), home (hero, cta, pricing), upload form, summary list
- **lib/**
- Business logic & integrations:
– `geminiAi.ts`, `langchain.ts`, `openai.ts` (AI model wrappers)
– `prisma.ts`, `queries.ts` (DB client & queries)
– `prompts.ts`, `utils.ts`
- **prisma/**
- Schema + migrations (SQLite in dev, can swap to Postgres in prod)
- **utils/**
- `uploadthing.ts` (client helper for UploadThing)
- Config & infra files: `next.config.ts`, `middleware.ts`, `tsconfig.json`, `schema.sql`

##### README for additional insights
- Confirms the tech stack and feature set
- Highlights modular, scalable architecture
- Mentions deployment target: Vercel / Node server

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% Frontend Layer
  subgraph "Frontend (Client Browser)" 
    direction TB
    Browser["Client Browser UI"]:::frontend
    PublicHome["Public Home Page"]:::frontend
    AuthFlows["Sign-In & Sign-Up Pages"]:::frontend
    ProtectedPages["Upload & Your Summaries Pages"]:::frontend
  end

  %% Backend Layer
  subgraph "Next.js Server" 
    direction TB
    AppRouter["App Router (Layouts & Pages)"]:::backend
    APIUploadRoute["UploadThing API Route"]:::backend
    CoreUploadLogic["UploadThing Core Logic"]:::backend
    UploadAction["Server Action: uploadAction"]:::backend
    subgraph "Business Logic Wrappers"
      direction TB
      GeminiWrapper["Gemini AI Wrapper (lib/geminiAi.ts)"]:::backend
      LangchainWrapper["LangChain Wrapper (lib/langchain.ts)"]:::backend
      OpenAIWrapper["OpenAI Wrapper (lib/openai.ts)"]:::backend
      Prompts["AI Prompts (lib/prompts.ts)"]:::backend
      Utils["Helpers (lib/utils.ts)"]:::backend
    end
    DBClient["Prisma Client (lib/prisma.ts)"]:::backend
    DBQueries["DB Queries (lib/queries.ts)"]:::backend
  end

  %% External Services
  Clerk["Clerk Auth Service"]:::external
  UploadThingService["UploadThing Service"]:::external
  GeminiService["Google Gemini Flash 2.0"]:::external

  %% Database
  DB["Database (Prisma + SQLite/SQL)"]:::db

  %% Relationships
  Browser -->|"page request / SSR"| AppRouter
  Browser -->|"uses SDK"| UploadThingService
  Browser -->|"fetch summaries"| AppRouter

  AppRouter -->|"validates token"| Clerk
  AppRouter -->|"invokes API"| APIUploadRoute
  APIUploadRoute -->|POST /api/uploadthing| CoreUploadLogic
  CoreUploadLogic -->|calls Action| UploadAction
  UploadAction -->|uses wrappers| GeminiWrapper & LangchainWrapper & OpenAIWrapper & Prompts & Utils
  GeminiWrapper -->|"summarize(text)"| GeminiService
  UploadAction -->|"Prisma.query()"| DBClient
  DBClient -->|"runs migrations / queries"| DB
  AppRouter -->|"Prisma.query()"| DBClient

  %% Component to External
  UploadThingService -->|"callback"| APIUploadRoute

  %% Click Events
  click Browser "https://github.com/utkarshmohan2003/docsqueeze/blob/main/app/layout.tsx"
  click PublicHome "https://github.com/utkarshmohan2003/docsqueeze/blob/main/app/page.tsx"
  click AuthFlows "https://github.com/utkarshmohan2003/docsqueeze/blob/main/app/sign-in/[[...sign-in]]/page.tsx"
  click AuthFlows "https://github.com/utkarshmohan2003/docsqueeze/blob/main/app/sign-up/[[...sign-up]]/page.tsx"
  click ProtectedPages "https://github.com/utkarshmohan2003/docsqueeze/blob/main/app/(logged-in)/upload/page.tsx"
  click ProtectedPages "https://github.com/utkarshmohan2003/docsqueeze/blob/main/app/(logged-in)/your-summaries/page.tsx"
  click APIUploadRoute "https://github.com/utkarshmohan2003/docsqueeze/blob/main/app/api/uploadthing/route.ts"
  click CoreUploadLogic "https://github.com/utkarshmohan2003/docsqueeze/blob/main/app/api/uploadthing/core.ts"
  click Utils "https://github.com/utkarshmohan2003/docsqueeze/blob/main/utils/uploadthing.ts"
  click UploadAction "https://github.com/utkarshmohan2003/docsqueeze/blob/main/app/actions/uploadAction.ts"
  click GeminiWrapper "https://github.com/utkarshmohan2003/docsqueeze/blob/main/lib/geminiAi.ts"
  click LangchainWrapper "https://github.com/utkarshmohan2003/docsqueeze/blob/main/lib/langchain.ts"
  click OpenAIWrapper "https://github.com/utkarshmohan2003/docsqueeze/blob/main/lib/openai.ts"
  click Prompts "https://github.com/utkarshmohan2003/docsqueeze/blob/main/lib/prompts.ts"
  click Utils "https://github.com/utkarshmohan2003/docsqueeze/blob/main/lib/utils.ts"
  click DBClient "https://github.com/utkarshmohan2003/docsqueeze/blob/main/lib/prisma.ts"
  click DBQueries "https://github.com/utkarshmohan2003/docsqueeze/blob/main/lib/queries.ts"
  click PrismaSchema "https://github.com/utkarshmohan2003/docsqueeze/blob/main/prisma/schema.prisma"
  click DB "https://github.com/utkarshmohan2003/docsqueeze/tree/main/prisma/migrations/20250426055803_init/"

  %% Styles
  classDef frontend fill:#E3F2FD,stroke:#90CAF9;
  classDef backend fill:#BBDEFB,stroke:#42A5F5;
  classDef external fill:#C8E6C9,stroke:#66BB6A;
  classDef db fill:#FFE0B2,stroke:#FB8C00;
```
