{
  "services": [
    {
      "id": "web",
      "name": "Chatbot UI (Next.js app)",
      "kind": "web",
      "framework": "next",
      "evidence": [
        {
          "file": "package.json",
          "lines": "1-80",
          "note": "Next 14 app with Supabase and multi-provider LLM SDKs"
        },
        {
          "file": "next.config.js",
          "lines": "1-35",
          "note": "PWA wrapper; sharp/onnxruntime external packages"
        },
        {
          "file": "middleware.ts",
          "lines": "1-45",
          "note": "i18n routing and Supabase session middleware"
        }
      ]
    }
  ],
  "routes": [
    {
      "id": "mw-session",
      "serviceId": "web",
      "method": "ALL",
      "path": "*",
      "kind": "middleware",
      "auth": "public",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "supabase-auth"
      ],
      "work": "light",
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "middleware.ts",
          "lines": "7-40",
          "note": "getSession per page request; workspace query only on '/'"
        },
        {
          "file": "middleware.ts",
          "lines": "43-45",
          "note": "matcher excludes api, static, auth, _next"
        }
      ],
      "confidence": "medium"
    },
    {
      "id": "chat-openai",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/chat/openai",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "openai",
        "supabase-auth"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "openai",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "inputSize": "large",
          "streaming": true,
          "frequency": "always",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/chat/openai/route.ts",
              "lines": "27-37",
              "note": "cap 4096 only for vision/gpt-4o, else null"
            }
          ]
        }
      ],
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "app/api/chat/openai/route.ts",
          "lines": "10-60",
          "note": "streams completion; profile lookup via getServerProfile"
        },
        {
          "file": "lib/server/server-chat-helpers.ts",
          "lines": "6-34",
          "note": "auth.getUser plus profiles select"
        },
        {
          "file": "lib/server/server-chat-helpers.ts",
          "lines": "37-62",
          "note": "env keys override profile keys"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "chat-anthropic",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/chat/anthropic",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "anthropic",
        "supabase-auth"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "anthropic",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "maxOutputTokens": 4096,
          "inputSize": "large",
          "streaming": true,
          "frequency": "always",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/chat/anthropic/route.ts",
              "lines": "52-66",
              "note": "max_tokens from limits table, 4096 for all Claude"
            },
            {
              "file": "lib/chat-setting-limits.ts",
              "lines": "12-47",
              "note": "Claude output limits all 4096"
            }
          ]
        }
      ],
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "app/api/chat/anthropic/route.ts",
          "lines": "11-100",
          "note": "converts messages, streams Anthropic response"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "chat-azure",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/chat/azure",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "azure-openai",
        "supabase-auth"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "azure-openai",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "inputSize": "large",
          "streaming": true,
          "frequency": "always",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/chat/azure/route.ts",
              "lines": "44-59",
              "note": "cap 4096 only for vision, else null"
            }
          ]
        }
      ],
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "app/api/chat/azure/route.ts",
          "lines": "9-70",
          "note": "maps model to Azure deployment id, streams"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "chat-custom",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/chat/custom",
      "kind": "api",
      "auth": "public",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "custom-llm"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "custom-llm",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "inputSize": "large",
          "streaming": true,
          "frequency": "always",
          "keySource": "byok",
          "evidence": [
            {
              "file": "app/api/chat/custom/route.ts",
              "lines": "36-46",
              "note": "no output cap; key and base_url from models row"
            }
          ]
        }
      ],
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/api/chat/custom/route.ts",
          "lines": "20-34",
          "note": "service-role lookup of models row, no auth check"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "chat-google",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/chat/google",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "google-gemini",
        "supabase-auth"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "google-gemini",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "inputSize": "large",
          "streaming": true,
          "frequency": "always",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/chat/google/route.ts",
              "lines": "19-31",
              "note": "no maxOutputTokens in generationConfig"
            }
          ]
        }
      ],
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "app/api/chat/google/route.ts",
          "lines": "7-45",
          "note": "streams Gemini chunks through ReadableStream"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "chat-groq",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/chat/groq",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "groq",
        "supabase-auth"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "groq",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "maxOutputTokens": 8192,
          "inputSize": "large",
          "streaming": true,
          "frequency": "always",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/chat/groq/route.ts",
              "lines": "26-32",
              "note": "cap from limits table, 4096-8192 per model"
            }
          ]
        }
      ],
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "app/api/chat/groq/route.ts",
          "lines": "8-50",
          "note": "OpenAI SDK against Groq baseURL"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "chat-mistral",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/chat/mistral",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "mistral",
        "supabase-auth"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "mistral",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "maxOutputTokens": 2000,
          "inputSize": "large",
          "streaming": true,
          "frequency": "always",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/chat/mistral/route.ts",
              "lines": "27-33",
              "note": "cap from limits table, 2000 for all Mistral"
            }
          ]
        }
      ],
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "app/api/chat/mistral/route.ts",
          "lines": "9-50",
          "note": "OpenAI SDK against Mistral baseURL"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "chat-openrouter",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/chat/openrouter",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "openrouter",
        "supabase-auth"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "openrouter",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "inputSize": "large",
          "streaming": true,
          "frequency": "always",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/chat/openrouter/route.ts",
              "lines": "27-33",
              "note": "max_tokens explicitly undefined"
            }
          ]
        }
      ],
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "app/api/chat/openrouter/route.ts",
          "lines": "10-45",
          "note": "OpenAI SDK against OpenRouter baseURL"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "chat-perplexity",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/chat/perplexity",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "perplexity",
        "supabase-auth"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "perplexity",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "inputSize": "large",
          "streaming": true,
          "frequency": "always",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/chat/perplexity/route.ts",
              "lines": "26-30",
              "note": "no max_tokens set"
            }
          ]
        }
      ],
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "app/api/chat/perplexity/route.ts",
          "lines": "8-45",
          "note": "OpenAI SDK against Perplexity baseURL"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "chat-tools",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/chat/tools",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "openai",
        "user-tool-apis",
        "supabase-auth"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "openai",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "inputSize": "large",
          "streaming": false,
          "frequency": "always",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/chat/tools/route.ts",
              "lines": "64-68",
              "note": "first non-streaming call with tools, no cap"
            }
          ]
        },
        {
          "externalCallId": "openai",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "inputSize": "large",
          "streaming": true,
          "frequency": "sometimes",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/chat/tools/route.ts",
              "lines": "200-219",
              "note": "follow-up call after tool calls; truncated, inferred"
            }
          ]
        }
      ],
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/api/chat/tools/route.ts",
          "lines": "82-198",
          "note": "sequential awaited fetches to user-defined tool URLs"
        },
        {
          "file": "lib/openapi-conversion.ts",
          "lines": "90-150",
          "note": "schema dereference per selected tool"
        }
      ],
      "confidence": "medium"
    },
    {
      "id": "command",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/command",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "openai",
        "supabase-auth"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "openai",
          "kind": "chat",
          "model": "gpt-4-1106-preview",
          "modelSource": "hardcoded",
          "callsPerRequest": 1,
          "maxOutputTokens": 4096,
          "inputSize": "small",
          "streaming": false,
          "frequency": "always",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/command/route.ts",
              "lines": "23-40",
              "note": "non-streaming; cap via gpt-4-turbo-preview limits entry"
            },
            {
              "file": "lib/chat-setting-limits.ts",
              "lines": "112-118",
              "note": "gpt-4-turbo-preview output limit 4096"
            }
          ]
        }
      ],
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/api/command/route.ts",
          "lines": "7-55",
          "note": "single GPT-4 completion for command input"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "assistants-openai",
      "serviceId": "web",
      "method": "GET",
      "path": "/api/assistants/openai",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "openai",
        "supabase-auth"
      ],
      "work": "light",
      "trafficHint": "rare",
      "evidence": [
        {
          "file": "app/api/assistants/openai/route.ts",
          "lines": "7-30",
          "note": "lists up to 100 OpenAI assistants; no inference"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "keys",
      "serviceId": "web",
      "method": "GET",
      "path": "/api/keys",
      "kind": "api",
      "auth": "public",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/api/keys/route.ts",
          "lines": "6-38",
          "note": "reports which env keys are set; no auth check"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "retrieval-process",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/retrieval/process",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        },
        {
          "dataStoreId": "supabase-storage",
          "pattern": "point"
        }
      ],
      "writes": [
        {
          "dataStoreId": "supabase-db"
        }
      ],
      "externalCallIds": [
        "openai",
        "azure-openai",
        "supabase-auth"
      ],
      "work": "long-running",
      "llmCalls": [
        {
          "externalCallId": "openai",
          "kind": "embedding",
          "model": "text-embedding-3-small",
          "modelSource": "hardcoded",
          "callsPerRequest": 1,
          "inputSize": "large",
          "streaming": false,
          "frequency": "sometimes",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/retrieval/process/route.ts",
              "lines": "100-115",
              "note": "one batched call; Azure if configured, none for local"
            }
          ]
        }
      ],
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/api/retrieval/process/route.ts",
          "lines": "16-150",
          "note": "download, chunk, embed, bulk upsert file_items"
        },
        {
          "file": "lib/generate-local-embedding.ts",
          "lines": "3-17",
          "note": "local path reloads model pipeline per chunk"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "retrieval-process-docx",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/retrieval/process/docx",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [
        {
          "dataStoreId": "supabase-db"
        }
      ],
      "externalCallIds": [
        "openai",
        "azure-openai",
        "supabase-auth"
      ],
      "work": "long-running",
      "llmCalls": [
        {
          "externalCallId": "openai",
          "kind": "embedding",
          "model": "text-embedding-3-small",
          "modelSource": "hardcoded",
          "callsPerRequest": 1,
          "inputSize": "large",
          "streaming": false,
          "frequency": "sometimes",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/retrieval/process/docx/route.ts",
              "lines": "55-68",
              "note": "one batched call; none when provider is local"
            }
          ]
        }
      ],
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/api/retrieval/process/docx/route.ts",
          "lines": "11-115",
          "note": "chunk docx text, embed, upsert; no ownership check"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "retrieval-retrieve",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/retrieval/retrieve",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        },
        {
          "dataStoreId": "supabase-db",
          "pattern": "search"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "openai",
        "azure-openai",
        "supabase-auth"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "openai",
          "kind": "embedding",
          "model": "text-embedding-3-small",
          "modelSource": "hardcoded",
          "callsPerRequest": 1,
          "inputSize": "small",
          "streaming": false,
          "frequency": "sometimes",
          "keySource": "either",
          "evidence": [
            {
              "file": "app/api/retrieval/retrieve/route.ts",
              "lines": "45-52",
              "note": "single query embedding; local provider skips API"
            }
          ]
        }
      ],
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/api/retrieval/retrieve/route.ts",
          "lines": "54-85",
          "note": "vector match RPC over file_items, client-supplied count"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "username-available",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/username/available",
      "kind": "api",
      "auth": "public",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/api/username/available/route.ts",
          "lines": "14-27",
          "note": "service-role username lookup, no auth"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "username-get",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/username/get",
      "kind": "api",
      "auth": "public",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/api/username/get/route.ts",
          "lines": "14-30",
          "note": "service-role lookup by userId, no auth"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "auth-callback",
      "serviceId": "web",
      "method": "GET",
      "path": "/auth/callback",
      "kind": "api",
      "auth": "public",
      "reads": [],
      "writes": [],
      "externalCallIds": [
        "supabase-auth"
      ],
      "work": "light",
      "trafficHint": "rare",
      "evidence": [
        {
          "file": "app/auth/callback/route.ts",
          "lines": "5-21",
          "note": "exchanges auth code for session, redirects"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "page-login",
      "serviceId": "web",
      "method": "GET",
      "path": "/[locale]/login",
      "kind": "page",
      "auth": "public",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "supabase-auth"
      ],
      "work": "light",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/[locale]/login/page.tsx",
          "lines": "15-48",
          "note": "server render; workspace query only if session exists"
        }
      ],
      "confidence": "medium"
    },
    {
      "id": "action-login",
      "serviceId": "web",
      "method": "POST",
      "path": "/[locale]/login",
      "kind": "server-action",
      "auth": "public",
      "reads": [
        {
          "dataStoreId": "supabase-db",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [
        "supabase-auth",
        "vercel-edge-config"
      ],
      "work": "light",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/[locale]/login/page.tsx",
          "lines": "50-150",
          "note": "signIn, signUp, reset password form actions"
        }
      ],
      "confidence": "medium"
    },
    {
      "id": "page-login-password",
      "serviceId": "web",
      "method": "GET",
      "path": "/[locale]/login/password",
      "kind": "page",
      "auth": "authenticated",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "rare",
      "evidence": [
        {
          "file": "app/[locale]/login/password/page.tsx",
          "lines": "1-30",
          "note": "client component; session checked in browser"
        }
      ],
      "confidence": "medium"
    },
    {
      "id": "page-home",
      "serviceId": "web",
      "method": "GET",
      "path": "/[locale]",
      "kind": "page",
      "auth": "public",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/[locale]/page.tsx",
          "lines": "1-28",
          "note": "static landing page"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "page-help",
      "serviceId": "web",
      "method": "GET",
      "path": "/[locale]/help",
      "kind": "page",
      "auth": "public",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "rare",
      "evidence": [
        {
          "file": "app/[locale]/help/page.tsx",
          "lines": "1-7",
          "note": "static placeholder"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "page-setup",
      "serviceId": "web",
      "method": "GET",
      "path": "/[locale]/setup",
      "kind": "page",
      "auth": "authenticated",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "rare",
      "evidence": [
        {
          "file": "app/[locale]/setup/page.tsx",
          "lines": "1-130",
          "note": "client onboarding; Supabase calls from browser"
        }
      ],
      "confidence": "medium"
    },
    {
      "id": "page-workspace",
      "serviceId": "web",
      "method": "GET",
      "path": "/[locale]/[workspaceid]",
      "kind": "page",
      "auth": "unknown",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/[locale]/[workspaceid]/page.tsx",
          "lines": "1-14",
          "note": "client component showing workspace name"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "page-chat",
      "serviceId": "web",
      "method": "GET",
      "path": "/[locale]/[workspaceid]/chat",
      "kind": "page",
      "auth": "unknown",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "app/[locale]/[workspaceid]/chat/page.tsx",
          "lines": "1-60",
          "note": "client chat shell; data via browser Supabase"
        }
      ],
      "confidence": "medium"
    },
    {
      "id": "page-chat-id",
      "serviceId": "web",
      "method": "GET",
      "path": "/[locale]/[workspaceid]/chat/[chatid]",
      "kind": "page",
      "auth": "unknown",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "app/[locale]/[workspaceid]/chat/[chatid]/page.tsx",
          "lines": "1-7",
          "note": "client ChatUI wrapper"
        }
      ],
      "confidence": "medium"
    }
  ],
  "dataStores": [
    {
      "id": "supabase-db",
      "kind": "postgres",
      "provider": "supabase",
      "tableCount": 25,
      "connection": "http-api",
      "evidence": [
        {
          "file": "lib/supabase/browser-client.ts",
          "lines": "1-7",
          "note": "browser client talks to Supabase directly"
        },
        {
          "file": "lib/server/server-chat-helpers.ts",
          "lines": "6-34",
          "note": "server client reads profiles"
        },
        {
          "file": "app/api/retrieval/retrieve/route.ts",
          "lines": "54-85",
          "note": "pgvector match RPCs on file_items"
        },
        {
          "file": "db/chats.ts",
          "lines": "1-30",
          "note": "typical table access via supabase-js"
        }
      ]
    },
    {
      "id": "supabase-storage",
      "kind": "object-storage",
      "provider": "supabase",
      "connection": "http-api",
      "evidence": [
        {
          "file": "db/storage/files.ts",
          "lines": "1-35",
          "note": "files bucket uploads, 10MB default limit"
        },
        {
          "file": "db/storage/message-images.ts",
          "lines": "1-20",
          "note": "message_images bucket"
        },
        {
          "file": "app/api/retrieval/process/route.ts",
          "lines": "40-46",
          "note": "server downloads file for chunking"
        }
      ]
    }
  ],
  "jobs": [],
  "externals": [
    {
      "id": "openai",
      "category": "llm",
      "provider": "openai",
      "blocking": true,
      "evidence": [
        {
          "file": "app/api/chat/openai/route.ts",
          "lines": "22-37",
          "note": "chat completions"
        },
        {
          "file": "app/api/command/route.ts",
          "lines": "18-40",
          "note": "gpt-4-1106-preview"
        },
        {
          "file": "app/api/retrieval/process/route.ts",
          "lines": "100-115",
          "note": "embeddings"
        }
      ]
    },
    {
      "id": "azure-openai",
      "category": "llm",
      "provider": "azure-openai",
      "blocking": true,
      "evidence": [
        {
          "file": "app/api/chat/azure/route.ts",
          "lines": "44-59",
          "note": "Azure deployments via OpenAI SDK"
        },
        {
          "file": "app/api/retrieval/retrieve/route.ts",
          "lines": "33-43",
          "note": "Azure embeddings when use_azure_openai"
        }
      ]
    },
    {
      "id": "anthropic",
      "category": "llm",
      "provider": "anthropic",
      "blocking": true,
      "evidence": [
        {
          "file": "app/api/chat/anthropic/route.ts",
          "lines": "52-66",
          "note": "messages.create streaming"
        }
      ]
    },
    {
      "id": "google-gemini",
      "category": "llm",
      "provider": "google",
      "blocking": true,
      "evidence": [
        {
          "file": "app/api/chat/google/route.ts",
          "lines": "19-31",
          "note": "startChat and sendMessageStream"
        }
      ]
    },
    {
      "id": "groq",
      "category": "llm",
      "provider": "groq",
      "blocking": true,
      "evidence": [
        {
          "file": "app/api/chat/groq/route.ts",
          "lines": "21-32",
          "note": "OpenAI-compatible endpoint"
        }
      ]
    },
    {
      "id": "mistral",
      "category": "llm",
      "provider": "mistral",
      "blocking": true,
      "evidence": [
        {
          "file": "app/api/chat/mistral/route.ts",
          "lines": "22-33",
          "note": "OpenAI-compatible endpoint"
        }
      ]
    },
    {
      "id": "perplexity",
      "category": "llm",
      "provider": "perplexity",
      "blocking": true,
      "evidence": [
        {
          "file": "app/api/chat/perplexity/route.ts",
          "lines": "21-30",
          "note": "OpenAI-compatible endpoint"
        }
      ]
    },
    {
      "id": "openrouter",
      "category": "llm",
      "provider": "openrouter",
      "blocking": true,
      "evidence": [
        {
          "file": "app/api/chat/openrouter/route.ts",
          "lines": "22-33",
          "note": "OpenAI-compatible endpoint"
        }
      ]
    },
    {
      "id": "custom-llm",
      "category": "llm",
      "provider": "user-defined OpenAI-compatible",
      "blocking": true,
      "evidence": [
        {
          "file": "app/api/chat/custom/route.ts",
          "lines": "36-46",
          "note": "base_url and api_key from models row"
        }
      ]
    },
    {
      "id": "user-tool-apis",
      "category": "other",
      "provider": "user-defined OpenAPI tool endpoints",
      "blocking": true,
      "evidence": [
        {
          "file": "app/api/chat/tools/route.ts",
          "lines": "120-195",
          "note": "fetch to user-supplied URLs inside request"
        }
      ]
    },
    {
      "id": "supabase-auth",
      "category": "auth",
      "provider": "supabase",
      "blocking": true,
      "evidence": [
        {
          "file": "lib/server/server-chat-helpers.ts",
          "lines": "18-23",
          "note": "auth.getUser on every authenticated API call"
        },
        {
          "file": "middleware.ts",
          "lines": "11-13",
          "note": "getSession in middleware"
        }
      ]
    },
    {
      "id": "vercel-edge-config",
      "category": "other",
      "provider": "vercel",
      "blocking": true,
      "evidence": [
        {
          "file": "app/[locale]/login/page.tsx",
          "lines": "88-93",
          "note": "signup whitelist lookup when EDGE_CONFIG set"
        }
      ]
    }
  ],
  "realtime": [],
  "warnings": [
    "app/api/chat/custom: unauthenticated; service-role fetch of models row and its stored api_key by id.",
    "app/api/username/available and /get are unauthenticated service-role lookups; enumeration and abuse risk.",
    "app/api/retrieval/process/docx: no check that fileId belongs to the caller; service-role writes.",
    "app/api/chat/tools: file truncated at line 200; second streaming call is inferred. Tool URLs are user-supplied and fetched without timeouts.",
    "Several chat routes (openai, azure, openrouter, perplexity, custom, google, tools) pass no output cap for most models.",
    "Most CRUD goes from the browser straight to Supabase (db/*.ts); that load is not visible as Next routes.",
    "Local embeddings reload the transformer pipeline per chunk, concurrently via Promise.all; heavy CPU and memory on Node runtime.",
    "Env API keys silently override per-user keys, so keySource is 'either' for platform-hosted deployments.",
    "No rate limiting seen on any LLM route; platform keys could be abused by any signed-in user."
  ],
  "schemaVersion": 1,
  "meta": {
    "source": "github",
    "repo": "https://github.com/mckaywrigley/chatbot-ui",
    "analyzedAt": "2026-10-27T14:45:16.025Z",
    "fileCount": 306,
    "extractorModel": "anthropic/claude-sonnet-5.5",
    "skeramVersion": "0.0.1",
    "commit": "81328b61d2a4",
    "framework": "next"
  }
}