# kaleido34/n2n architecture

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

- Interactive diagram: https://gitdiagram.com/kaleido34/n2n
- Repository: https://github.com/kaleido34/n2n

## Overview

##### Project Type & Purpose
- Full‐stack web application for ingesting various content types (PDF, video, audio, image), processing them with AI (OCR, transcription, summarization, flashcards, mind maps, quizzes, etc.), and organizing results in user-specific “spaces.”
- Frontend: Next.js/React/Tailwind
- Backend: Next.js API routes + Python extraction server
- Persistence: PostgreSQL (via Prisma), vector search (Pinecone)
- Auth & BaaS: Supabase
- External AI: Google AI SDK

External Entities:
- User (web/mobile client)
- Admin (reindexing, management tasks)
- Google AI / OCR / Transcription service
- Pinecone Vector DB
- Supabase Auth service
Processes:
1.0 User Management
2.0 Content Ingestion
3.0 Content Processing
4.0 Workspace Management
5.0 Admin & Reindex
Data Stores:
A. User Store (PostgreSQL)
B. Raw Content Store (file blobs or object storage)
C. Processed Content Store (PostgreSQL + Prisma)
D. Embeddings Store (Pinecone)
Data Flows:
– User → 1.0 [signup/signin/profile data] → A
– User → 2.0 [upload requests + files] → B
– 2.0 → 3.0 [raw content pointer]
– 3.0 ↔ Google AI / OCR / Transcribe → 3.0
– 3.0 → C [summaries, transcripts, flashcards, etc.]
– 3.0 → D [vector embeddings]
– User → 4.0 [create/read/update spaces] → C
– Admin → 5.0 [reindex commands] → C/D

##### DFD Level 1 (Breakout of Context Processes)
1.0 User Management
1.1 Signup
1.2 Signin
1.3 Update Profile
1.4 Deactivate Account
2.0 Content Ingestion
2.1 Ingest PDF
2.2 Ingest YouTube Video
2.3 Ingest Audio File
2.4 Ingest Image (OCR)
3.0 Content Processing
3.1 Transcribe Audio/Video
3.2 OCR Documents/Images
3.3 Summarize Text/Audio
3.4 Generate Flashcards
3.5 Generate Mind Map
3.6 Generate Quiz
3.7 Generate Concept Matches
3.8 Generate Terms
4.0 Workspace Management
4.1 Create/Retrieve/Update/Delete Spaces
4.2 Assign Content to Spaces
5.0 Admin & Reindex
5.1 Reindex All Embeddings
5.2 Reindex Single Content Embeddings

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    User["User"]:::external

    %% Data Stores
    B["B: Raw Content Store"]:::datastore
    C["C: Processed Content Store"]:::datastore

    %% External AI Service
    GAI["Google AI / OCR / Transcribe"]:::external

    %% Processes Cluster: 2.0 Content Ingestion
    subgraph "2.0 Content Ingestion"
        P2_1["2.1 Ingest PDF"]:::process
        P2_2["2.2 Ingest YouTube Video"]:::process
        P2_3["2.3 Ingest Audio File"]:::process
        P2_4["2.4 Ingest Image (OCR)"]:::process
    end

    %% Subprocess Detail: 2.2 Ingest YouTube Video
    P2_2 -->|"upload request (YouTube URL)"| P2_2_in["Validate URL, fetch transcript"]:::process
    P2_2_in --> B
    P2_2_in -->|"metadata"| C
    P2_2_in -->|"raw video pointer"| T31

    %% Transcription Process
    T31["3.1 Transcribe Audio/Video"]:::process

    T31 -->|"transcripts"| C
    T31 <-->|"calls Transcribe()"| GAI

    %% Flows from external to ingestion
    User -->|"YouTube URL"| P2_2

    %% Click Events
    click P2_1 "https://github.com/kaleido34/n2n/blob/main/app/api/contents/upload/pdf/route.ts"
    click P2_2 "https://github.com/kaleido34/n2n/blob/main/app/api/contents/youtube/route.ts"
    click P2_3 "https://github.com/kaleido34/n2n/blob/main/app/api/contents/upload/audio/route.ts"
    click P2_4 "https://github.com/kaleido34/n2n/blob/main/app/api/contents/upload/image/route.ts"
    click T31 "https://github.com/kaleido34/n2n/blob/main/app/api/contents/transcript/route.ts"

    %% Styling
    classDef external fill:#AED6F1,stroke:#1F618D,color:#1B2631;
    classDef process fill:#ABEBC6,stroke:#1D8348,color:#1B2631;
    classDef datastore fill:#F9E79F,stroke:#B7950B,color:#1B2631;
    classDef flow stroke:#E74C3C,stroke-width:2px;
    
    %% Link Styles for Data Flows (red)
    linkStyle default stroke:#E74C3C,stroke-width:2px;
```
