> ## Documentation Index
> Fetch the complete documentation index at: https://docs.brainstormer.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Tech Stack

> Complete technology stack for Brainstormer V2: frameworks, libraries, databases, AI integrations, and infrastructure.

## Frontend

| Technology   | Version  | Purpose                                         |
| ------------ | -------- | ----------------------------------------------- |
| Next.js      | 15       | React framework with App Router, SSR, Turbopack |
| React        | 19       | UI component library                            |
| TypeScript   | 5        | Type-safe development                           |
| Tailwind CSS | 3        | Utility-first CSS framework                     |
| Shadcn/ui    | Latest   | Component library built on Radix UI             |
| Turbopack    | Built-in | Fast development bundler (Next.js 15)           |

## Backend

| Technology | Version | Purpose                                             |
| ---------- | ------- | --------------------------------------------------- |
| Node.js    | 20+     | Runtime environment                                 |
| Fastify    | 4.x     | Web framework for all microservices                 |
| TypeScript | 5       | Type-safe backend development                       |
| Turborepo  | Latest  | Monorepo build orchestration                        |
| tsx        | Latest  | TypeScript execution with watch mode (dev)          |
| Zod        | Latest  | Schema validation for env config and request bodies |

## Database and Storage

| Technology | Version    | Purpose                                                   |
| ---------- | ---------- | --------------------------------------------------------- |
| PostgreSQL | 15         | Primary relational database (raw SQL, repository pattern) |
| Redis      | 7          | Caching, BullMQ job queue, rate limiting, session storage |
| ChromaDB   | Latest     | Vector database (local development)                       |
| Pinecone   | v3         | Vector database (production)                              |
| AWS S3     | Latest SDK | Cloud file storage (optional, local fallback)             |

<Note>
  There is no ORM. All database access uses raw SQL with parameterized queries through the `pg` driver, organized in a repository pattern.
</Note>

## AI and Machine Learning

| Technology         | Purpose                                                              |
| ------------------ | -------------------------------------------------------------------- |
| LangChain          | AI orchestration, conversation memory, chat pipeline                 |
| OpenRouter         | Unified API gateway to 300+ AI models (GPT-4, Claude, Gemini, Llama) |
| Gemini Embedding 2 | Multimodal embeddings (text, image, video, audio) at 3072 dimensions |
| LlamaParse         | Advanced document parsing (PDF, DOCX)                                |
| OpenRouter Whisper | Audio/video transcription                                            |
| OpenRouter Vision  | Image and PDF text extraction                                        |
| ElevenLabs         | Voice cloning and text-to-speech                                     |

## Async Processing

| Technology | Version | Purpose                                                           |
| ---------- | ------- | ----------------------------------------------------------------- |
| BullMQ     | 5.34+   | Job queue for document processing, graph indexing, URL processing |
| Redis      | 7       | Queue backend                                                     |

## Testing

| Technology             | Purpose                                 |
| ---------------------- | --------------------------------------- |
| Jest                   | Test runner with ts-jest for TypeScript |
| @testing-library/react | React component testing                 |
| Playwright             | Browser automation testing              |

## Code Quality

| Technology  | Purpose                     |
| ----------- | --------------------------- |
| ESLint      | Linting                     |
| Prettier    | Code formatting             |
| Husky       | Git hooks                   |
| lint-staged | Pre-commit hook enforcement |

## Infrastructure and DevOps

| Technology     | Purpose                                                 |
| -------------- | ------------------------------------------------------- |
| Docker         | Infrastructure containers (PostgreSQL, Redis, ChromaDB) |
| Docker Compose | Multi-container orchestration                           |
| npm workspaces | Monorepo package management                             |
| Turborepo      | Build caching and task orchestration                    |

## Service Architecture

<Columns>
  <Card title="Web App" icon="browser">
    **Port 3000** -- Next.js 15 frontend with React 19, Tailwind CSS, Shadcn/ui
  </Card>

  <Card title="API Gateway" icon="door-open">
    **Port 4000** -- Fastify with CORS, Helmet, rate limiting, JWT verify middleware
  </Card>
</Columns>

<Columns>
  <Card title="Auth Service" icon="lock">
    **Port 4001** -- JWT auth, org management, RBAC, platform config, email (Resend)
  </Card>

  <Card title="Bot Service" icon="robot">
    **Port 4002** -- LangChain chat, OpenRouter models, RAG retrieval, billing
  </Card>
</Columns>

<Columns>
  <Card title="Realtime Audio" icon="microphone">
    **Port 4003** -- ElevenLabs voice cloning, LiveKit WebRTC, Whisper STT
  </Card>

  <Card title="Knowledge Service" icon="book">
    **Port 4005** -- RAG pipeline, content connectors, embeddings, knowledge graph
  </Card>
</Columns>

## Key Libraries

<Tabs>
  <Tab title="Backend">
    ```json theme={null}
    {
      "fastify": "^4.25.2",
      "@fastify/cors": "latest",
      "@fastify/helmet": "latest",
      "@fastify/rate-limit": "latest",
      "@fastify/multipart": "latest",
      "pg": "^8.x",
      "bullmq": "^5.34.4",
      "ioredis": "latest",
      "langchain": "^0.3.30",
      "@langchain/openai": "latest",
      "llamaindex": "^0.12.0",
      "@pinecone-database/pinecone": "^3.0.3",
      "chromadb": "^1.10.2",
      "zod": "latest",
      "jsonwebtoken": "latest",
      "bcrypt": "latest"
    }
    ```
  </Tab>

  <Tab title="Frontend">
    ```json theme={null}
    {
      "next": "^15.x",
      "react": "^19.x",
      "typescript": "^5.x",
      "tailwindcss": "^3.x",
      "@radix-ui/react-tooltip": "latest",
      "lucide-react": "latest"
    }
    ```
  </Tab>

  <Tab title="Shared">
    ```json theme={null}
    {
      "@brainstormer/shared": "file:../../packages/shared"
    }
    ```
  </Tab>
</Tabs>

## Model Selection

Brainstormer V2 supports 300+ AI models via OpenRouter, auto-synced every 60 minutes:

| Provider      | Models                                  |
| ------------- | --------------------------------------- |
| OpenAI        | GPT-4o, GPT-4, GPT-3.5-turbo            |
| Anthropic     | Claude 3.5 Sonnet, Claude 3 Haiku, Opus |
| Google        | Gemini 2.0 Flash, Gemini Pro            |
| Meta          | Llama 3.x models                        |
| And many more | 300+ models via OpenRouter              |

## Embedding Strategy

<Note>
  Brainstormer V2 uses **Gemini Embedding 2** (`gemini-embedding-exp-03-07`) for all embeddings, with native multimodal embedding support across text, images, video, and audio content at 3072 dimensions.
</Note>
