# kunal00000/docuconvo architecture

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

- Interactive diagram: https://gitdiagram.com/kunal00000/docuconvo
- Repository: https://github.com/kunal00000/docuconvo

## Overview

##### Main Components
- Frontend Web Application – Located under apps/web, this Next.js‑based UI contains routes for authentication, marketing pages, and a dashboard for managing projects, logs, and settings.
- Backend/API Layer – Built into the Next.js app (using the “app/api” routes), these endpoints handle authentication (e.g. [...nextauth] routes), log collection, email sending, and processing search requests.
- SDK/Client Library – Found under apps/sdk, this package exposes client‑side functions (e.g. “client.ts” and “index.ts”) so that organizations can easily integrate and invoke the DocuConvo search functionality.
- Documentation Crawling & Knowledge Base Creation – Although not isolated as a separate service in the file tree, the README outlines modules that internally crawl documentation websites, process content to create vector embeddings, and store these embeddings into Pinecone.
- External Services:
- Pinecone Vector Database – Stores vector embeddings that represent the crawled documentation.
- OpenAI’s GPT‑3.5 API – Used to generate conversational search responses by feeding relevant context from similar vectors.
- (Optional) A relational database via Prisma – The presence of a “prisma/schema.prisma” file suggests a local database component that might store user, session, or other structured data.

##### Relationships and Data Flows
- The Frontend interacts with the Backend/API endpoints for authentication, dashboard operations, and search requests.
- When a search query is submitted:
– The frontend sends the query to a dedicated API endpoint.
– The API layer retrieves or triggers the identification of similar vector embeddings from the Pinecone database.
– These embeddings, along with the search query, are forwarded to the OpenAI GPT‑3.5 API.
– The GPT‑3.5 response is then returned through the API layer back to the frontend.
- The SDK provides helper functions that wrap these interactions so that external consumers can integrate DocuConvo’s capabilities without managing the underlying API calls directly.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Each major folder (apps/web for the UI, apps/sdk for the client library, and packages for common tooling) isolates a different aspect of the project.
- API-First and Modular: The use of Next.js App Router with clearly segmented API routes shows emphasis on modularity.
- External Integration: Patterns for interfacing with external services (Pinecone for vector storage and OpenAI for AI responses) are critical to the design.
- Extensibility: The design encourages integration via the SDK and customizable configuration (e.g., Pinecone and API keys provided by the user).

##### Specific Elements
– Data flow from the user interface to API endpoints for search and authentication.
– The interaction between the API and external services (Pinecone and OpenAI).
– The integration of the SDK with the backend.
– Internal components (Frontend, Backend, SDK).
– External services (Pinecone, OpenAI).
– Configuration/infrastructure components (Prisma for structured data if applicable).

##### Detail Essential Architectural Elements
- Notes on significant technologies: Next.js (including its App Router and API routes), TypeScript for code quality, and external integrations (Pinecone, OpenAI).
- Config components or middleware (e.g., middleware.ts) that might play a role in request handling.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Nodes
    user("User (Browser)"):::external

    subgraph "Frontend Domain"
        web("Web UI (Next.js App)"):::frontend
    end

    subgraph "SDK Domain"
        sdkClient("SDK Client (client.ts)"):::sdk
        sdkIndex("SDK Index (index.ts)"):::sdk
    end

    subgraph "Backend Domain"
        api("API Routes (Next.js API Endpoints)"):::backend
        crawler("Documentation Crawler & Vector Processing"):::backend
        prisma("Prisma Database"):::backend
    end

    subgraph "External Services"
        pinecone("Pinecone Vector DB"):::external
        openai("OpenAI GPT‑3.5 API"):::external
    end

    %% Connections
    user -->|"initiates"| web
    web -->|"calls"| api
    sdkClient -->|"invokes"| api
    sdkIndex -->|"invokes"| api
    api -->|"processes search"| crawler
    crawler -->|"generates vectors"| pinecone
    api -->|"queries for AI response"| openai
    api -->|"stores structured data"| prisma
    api -->|"returns response"| web

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#2471A3,stroke-width:2px;
    classDef backend fill:#A9DFBF,stroke:#239B56,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef sdk fill:#FDEBD0,stroke:#F39C12,stroke-width:2px;

    %% Click Events
    click web "https://github.com/kunal00000/docuconvo/tree/main/apps/web/app"
    click api "https://github.com/kunal00000/docuconvo/tree/main/apps/web/app/api"
    click sdkClient "https://github.com/kunal00000/docuconvo/blob/main/apps/sdk/src/client.ts"
    click sdkIndex "https://github.com/kunal00000/docuconvo/blob/main/apps/sdk/src/index.ts"
    click pinecone "https://github.com/kunal00000/docuconvo/blob/main/apps/web/components/dashboard/pinecone-form.tsx"
    click prisma "https://github.com/kunal00000/docuconvo/blob/main/apps/web/prisma/schema.prisma"
```
