Preparing your workspace...

assistant-chat.tsx2.5k
utils.ts850
button.tsx720
Quick Actions
codmirDevelopers
MarketplaceMy Apps
Go to codmirSign In
Back to AI Docs

Architecture

The Codmir AI system consists of two main services that work together to provide intelligent, project-aware responses.

System Overview

┌─────────────────────────────────────────────────────────────────┐
│                         Web App (Next.js)                        │
│                                                                  │
│  ┌─────────────┐  ┌─────────────┐  ┌─────────────┐              │
│  │ useAIChat   │  │ useAITask   │  │ AIClient    │              │
│  └──────┬──────┘  └──────┬──────┘  └──────┬──────┘              │
└─────────┼────────────────┼────────────────┼─────────────────────┘
          │                │                │
          │ Internal API   │                │
          │ (/api/* in     │                │
          │  apps/web)     │                │
          ▼                ▼                ▼
┌─────────────────────────────────────────────────────────────────┐
│               Integrated AI Runtime (apps/web API)               │
│                       /api/chat and layers                       │
│                                                                  │
│  ┌─────────────────────────────────────────────────────────┐    │
│  │                       Modules                            │    │
│  │  ┌─────────┐ ┌──────────┐ ┌───────────┐ ┌───────────┐  │    │
│  │  │  Chat   │ │ Sessions │ │Completions│ │ Knowledge │  │    │
│  │  └────┬────┘ └────┬─────┘ └─────┬─────┘ └─────┬─────┘  │    │
│  └───────┼───────────┼─────────────┼─────────────┼────────┘    │
│          │           │             │             │              │
│  ┌───────┴───────────┴─────────────┴─────────────┴───────┐     │
│  │              AI Providers (OpenAI, Anthropic)          │     │
│  └─────────────────────────────────────────────────────────┘    │
│                              │                                   │
│  ┌───────────────────────────┴───────────────────────────┐     │
│  │              Upstash Vector (Knowledge Store)          │     │
│  └───────────────────────────────────────────────────────┘     │
│                              │                                   │
│  ┌───────────────────────────┴───────────────────────────┐     │
│  │              Tasks Dispatcher → Agent                  │     │
│  └───────────────────────────────────────────────────────┘     │
└─────────────────────────────────┬───────────────────────────────┘
                                  │
                                  │ HTTP (internal)
                                  ▼
┌─────────────────────────────────────────────────────────────────┐
│                  Agent Service (agent.codmir.com)                │
│                         Port 8080                                │
│                                                                  │
│  ┌─────────────────────────────────────────────────────────┐    │
│  │                     Task Handlers                        │    │
│  │  ┌──────────────────┐  ┌────────────────────────────┐  │    │
│  │  │  analyze-project │  │  generate-knowledge-base   │  │    │
│  │  └────────┬─────────┘  └──────────────┬─────────────┘  │    │
│  └───────────┼───────────────────────────┼─────────────────┘    │
│              │                           │                       │
│  ┌───────────┴───────────────────────────┴───────────────┐     │
│  │                   Analysis Service                     │     │
│  │  • Clone/pull repos                                    │     │
│  │  • Detect tech stack                                   │     │
│  │  • Analyze architecture                                │     │
│  │  • Extract components                                  │     │
│  └───────────────────────────────────────────────────────┘     │
│              │                                                   │
│  ┌───────────┴───────────────────────────────────────────┐     │
│  │              Knowledge Generator Service               │     │
│  │  • Generate chunks                                     │     │
│  │  • Send to AI service for embedding                    │     │
│  │  • Callback on completion                              │     │
│  └───────────────────────────────────────────────────────┘     │
└─────────────────────────────────────────────────────────────────┘

Services

Integrated AI API

apps/web /api/* - primary runtime path for AI interactions

  • Handles chat and completion requests
  • Manages conversation sessions
  • Stores and queries knowledge vectors
  • Dispatches tasks to Agent service
  • Supports long-running streams (15+ min)

Agent Service

agent.codmir.com:8080 - NestJS service for code operations

  • Clones and analyzes repositories
  • Detects tech stack and architecture
  • Generates knowledge chunks
  • Manages ephemeral runner containers
  • Executes code tasks

Upstash Vector

Serverless vector database for knowledge storage

  • Stores embeddings per project
  • Semantic similarity search
  • Metadata filtering
  • Auto-scaling and managed infrastructure

Data Flows

Chat with Project Context

  1. User sends message to AI service with projectId
  2. AI service queries Upstash Vector for relevant knowledge
  3. Retrieved chunks are injected into system prompt
  4. Request sent to AI provider (OpenAI/Anthropic)
  5. Response streamed back to client

Knowledge Base Generation

  1. Client dispatches task via AI service
  2. AI service forwards to Agent service
  3. Agent clones repo and analyzes codebase
  4. Generates knowledge chunks (code, docs, architecture)
  5. Sends chunks to AI service for embedding
  6. AI service generates embeddings and stores in Upstash Vector
  7. Callback sent to AI service with results

Environment Variables

Web App

# Canonical runtime path is internal /api/*
FEATURE_REMOTE_AI_DISPATCH=false
NEXT_PUBLIC_AI_SERVICE_URL=

AI Service

GEMINI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
UPSTASH_VECTOR_REST_URL=https://...
UPSTASH_VECTOR_REST_TOKEN=...
AGENT_SERVICE_URL=http://localhost:8080

Agent Service

# Optional legacy override only
AI_SERVICE_URL=
WORK_DIR=/tmp/codmir-analysis
GITHUB_TOKEN=ghp_...
AI Overview

Documentation

  • Getting Started
  • API Reference
  • SDK & CLI
  • Webhooks
  • Guides

Marketplace

  • Browse Apps
  • Featured Apps
  • Official Apps
  • Submit Your App

Resources

  • Community
  • Discord
  • GitHub
  • Blog

Company

  • About codmir
  • Careers
  • Status
  • Contact
codmirDevelopers
TermsPrivacyAPI TermsCodmir™ 2026. All rights reserved.