{
  "services": [
    {
      "id": "web",
      "name": "Chatbot Next.js app",
      "kind": "web",
      "framework": "next",
      "entrypoint": "proxy.ts",
      "evidence": [
        {
          "file": "package.json",
          "lines": "39-40",
          "note": "Next 16, AI SDK, deployed on Vercel"
        },
        {
          "file": "vercel.json",
          "note": "framework nextjs"
        },
        {
          "file": "proxy.ts",
          "lines": "5-37",
          "note": "Edge-style proxy gating all routes"
        }
      ]
    }
  ],
  "routes": [
    {
      "id": "middleware-proxy",
      "serviceId": "web",
      "method": "ALL",
      "path": "*",
      "kind": "middleware",
      "auth": "public",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "proxy.ts",
          "lines": "5-37",
          "note": "JWT check only; redirects tokenless to guest sign-in"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "auth-nextauth",
      "serviceId": "web",
      "method": "ALL",
      "path": "/api/auth/[...nextauth]",
      "kind": "api",
      "auth": "public",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(auth)/api/auth/[...nextauth]/route.ts",
          "lines": "1-1",
          "note": "Re-exports handlers; auth.ts not shown"
        }
      ],
      "confidence": "medium"
    },
    {
      "id": "auth-guest",
      "serviceId": "web",
      "method": "GET",
      "path": "/api/auth/guest",
      "kind": "api",
      "auth": "public",
      "reads": [],
      "writes": [
        {
          "dataStoreId": "postgres"
        }
      ],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(auth)/api/auth/guest/route.ts",
          "lines": "6-24",
          "note": "Guest signIn; user insert inferred from queries"
        },
        {
          "file": "lib/db/queries.ts",
          "lines": "58-72",
          "note": "createGuestUser inserts user row"
        }
      ],
      "confidence": "medium"
    },
    {
      "id": "chat-stream-resume",
      "serviceId": "web",
      "method": "GET",
      "path": "/api/chat/[id]/stream",
      "kind": "api",
      "auth": "authenticated",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(chat)/api/chat/[id]/stream/route.ts",
          "lines": "1-3",
          "note": "Stub returning 204; gated by proxy token"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "chat-post",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/chat",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "aggregate"
        },
        {
          "dataStoreId": "postgres",
          "pattern": "point"
        },
        {
          "dataStoreId": "postgres",
          "pattern": "list"
        }
      ],
      "writes": [
        {
          "dataStoreId": "postgres"
        },
        {
          "dataStoreId": "redis"
        }
      ],
      "externalCallIds": [
        "ai-gateway",
        "botid",
        "ai-gateway-catalog",
        "open-meteo"
      ],
      "work": "llm",
      "llmCalls": [
        {
          "externalCallId": "ai-gateway",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "loopCap": 5,
          "inputSize": "large",
          "streaming": true,
          "keySource": "platform",
          "evidence": [
            {
              "file": "app/(chat)/api/chat/route.ts",
              "lines": "269-330",
              "note": "streamText with tools, stopWhen 5 steps, allowlisted model"
            }
          ]
        },
        {
          "externalCallId": "ai-gateway",
          "kind": "chat",
          "model": "moonshotai/kimi-k2.5",
          "modelSource": "hardcoded",
          "callsPerRequest": 1,
          "inputSize": "small",
          "streaming": false,
          "frequency": "sometimes",
          "keySource": "platform",
          "evidence": [
            {
              "file": "app/(chat)/actions.ts",
              "lines": "28-34",
              "note": "Title generateText, only for new chats"
            },
            {
              "file": "app/(chat)/api/chat/route.ts",
              "lines": "125-133",
              "note": "Triggered when chat doesn't exist"
            }
          ]
        },
        {
          "externalCallId": "ai-gateway",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "inputSize": "medium",
          "streaming": true,
          "frequency": "sometimes",
          "keySource": "platform",
          "evidence": [
            {
              "file": "artifacts/text/server.ts",
              "lines": "8-52",
              "note": "Artifact text create/update via tool"
            },
            {
              "file": "artifacts/code/server.ts",
              "lines": "9-57",
              "note": "Artifact code create/update via tool"
            },
            {
              "file": "artifacts/sheet/server.ts",
              "lines": "8-50",
              "note": "Artifact sheet create/update via tool"
            }
          ]
        },
        {
          "externalCallId": "ai-gateway",
          "kind": "chat",
          "modelSource": "request",
          "callsPerRequest": 1,
          "inputSize": "large",
          "streaming": true,
          "frequency": "sometimes",
          "keySource": "platform",
          "evidence": [
            {
              "file": "lib/ai/tools/request-suggestions.ts",
              "lines": "43-57",
              "note": "Suggestions streamText over whole document"
            }
          ]
        }
      ],
      "trafficHint": "hot",
      "evidence": [
        {
          "file": "app/(chat)/api/chat/route.ts",
          "lines": "70-445",
          "note": "Streaming chat; rate limits, DB reads/writes, resumable stream"
        },
        {
          "file": "lib/ratelimit.ts",
          "lines": "22-47",
          "note": "Redis IP rate limit, production only"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "chat-delete",
      "serviceId": "web",
      "method": "DELETE",
      "path": "/api/chat",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "point"
        }
      ],
      "writes": [
        {
          "dataStoreId": "postgres"
        }
      ],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "rare",
      "evidence": [
        {
          "file": "app/(chat)/api/chat/route.ts",
          "lines": "447-471",
          "note": "Owner-checked chat delete"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "document-get",
      "serviceId": "web",
      "method": "GET",
      "path": "/api/document",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "list"
        }
      ],
      "writes": [],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(chat)/api/document/route.ts",
          "lines": "18-48",
          "note": "Returns all document versions, no pagination"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "document-post",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/document",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "list"
        }
      ],
      "writes": [
        {
          "dataStoreId": "postgres"
        }
      ],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(chat)/api/document/route.ts",
          "lines": "51-108",
          "note": "Saves new version or manual edit; editor autosave"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "document-delete",
      "serviceId": "web",
      "method": "DELETE",
      "path": "/api/document",
      "kind": "api",
      "auth": "authenticated",
      "reads": [],
      "writes": [
        {
          "dataStoreId": "postgres"
        }
      ],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "rare",
      "evidence": [
        {
          "file": "app/(chat)/api/document/route.ts",
          "lines": "110-120",
          "note": "File truncated; body inferred from imports"
        }
      ],
      "confidence": "low"
    },
    {
      "id": "files-upload",
      "serviceId": "web",
      "method": "POST",
      "path": "/api/files/upload",
      "kind": "api",
      "auth": "authenticated",
      "reads": [],
      "writes": [
        {
          "dataStoreId": "blob"
        }
      ],
      "externalCallIds": [
        "vercel-blob"
      ],
      "work": "light",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(chat)/api/files/upload/route.ts",
          "lines": "18-65",
          "note": "5MB image upload buffered, public blob put"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "history-get",
      "serviceId": "web",
      "method": "GET",
      "path": "/api/history",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "list"
        }
      ],
      "writes": [],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(chat)/api/history/route.ts",
          "lines": "6-37",
          "note": "Cursor pagination, limit capped at 50"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "history-delete",
      "serviceId": "web",
      "method": "DELETE",
      "path": "/api/history",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "list"
        }
      ],
      "writes": [
        {
          "dataStoreId": "postgres"
        }
      ],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "rare",
      "evidence": [
        {
          "file": "app/(chat)/api/history/route.ts",
          "lines": "39-48",
          "note": "Deletes all user chats, multi-statement"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "messages-get",
      "serviceId": "web",
      "method": "GET",
      "path": "/api/messages",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "point"
        },
        {
          "dataStoreId": "postgres",
          "pattern": "list"
        }
      ],
      "writes": [],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(chat)/api/messages/route.ts",
          "lines": "5-43",
          "note": "All chat messages unpaginated; public chats readable by others"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "models-get",
      "serviceId": "web",
      "method": "GET",
      "path": "/api/models",
      "kind": "api",
      "auth": "authenticated",
      "reads": [],
      "writes": [],
      "externalCallIds": [
        "ai-gateway-catalog"
      ],
      "work": "light",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(chat)/api/models/route.ts",
          "lines": "3-20",
          "note": "Cached 24h; gateway fetches revalidated daily"
        },
        {
          "file": "lib/ai/models.ts",
          "lines": "66-107",
          "note": "Per-model capability fetches"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "suggestions-get",
      "serviceId": "web",
      "method": "GET",
      "path": "/api/suggestions",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "list"
        }
      ],
      "writes": [],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(chat)/api/suggestions/route.ts",
          "lines": "5-37",
          "note": "Suggestions by document, unpaginated"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "vote-get",
      "serviceId": "web",
      "method": "GET",
      "path": "/api/vote",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "point"
        },
        {
          "dataStoreId": "postgres",
          "pattern": "list"
        }
      ],
      "writes": [],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(chat)/api/vote/route.ts",
          "lines": "12-41",
          "note": "Votes per chat, owner-checked"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "vote-patch",
      "serviceId": "web",
      "method": "PATCH",
      "path": "/api/vote",
      "kind": "api",
      "auth": "authenticated",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "point"
        }
      ],
      "writes": [
        {
          "dataStoreId": "postgres"
        }
      ],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(chat)/api/vote/route.ts",
          "lines": "43-81",
          "note": "Upserts vote after owner check"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "page-login",
      "serviceId": "web",
      "method": "GET",
      "path": "/login",
      "kind": "page",
      "auth": "public",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "rare",
      "evidence": [
        {
          "file": "app/(auth)/login/page.tsx",
          "lines": "12-62",
          "note": "Client form posting login action"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "page-register",
      "serviceId": "web",
      "method": "GET",
      "path": "/register",
      "kind": "page",
      "auth": "public",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "rare",
      "evidence": [
        {
          "file": "app/(auth)/register/page.tsx",
          "lines": "12-62",
          "note": "Client form posting register action"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "page-chat",
      "serviceId": "web",
      "method": "GET",
      "path": "/chat/[id]",
      "kind": "page",
      "auth": "authenticated",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(chat)/chat/[id]/page.tsx",
          "lines": "1-3",
          "note": "Page returns null; UI in layout/client"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "page-home",
      "serviceId": "web",
      "method": "GET",
      "path": "/",
      "kind": "page",
      "auth": "authenticated",
      "reads": [],
      "writes": [],
      "externalCallIds": [],
      "work": "light",
      "trafficHint": "normal",
      "evidence": [
        {
          "file": "app/(chat)/page.tsx",
          "lines": "1-3",
          "note": "Page returns null; UI in layout/client"
        }
      ],
      "confidence": "high"
    },
    {
      "id": "action-login",
      "serviceId": "web",
      "method": "POST",
      "path": "/login (server action)",
      "kind": "server-action",
      "auth": "public",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "point"
        }
      ],
      "writes": [],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "rare",
      "evidence": [
        {
          "file": "app/(auth)/actions.ts",
          "lines": "16-42",
          "note": "Credentials signIn; imported by login page"
        }
      ],
      "confidence": "medium"
    },
    {
      "id": "action-register",
      "serviceId": "web",
      "method": "POST",
      "path": "/register (server action)",
      "kind": "server-action",
      "auth": "public",
      "reads": [
        {
          "dataStoreId": "postgres",
          "pattern": "point"
        }
      ],
      "writes": [
        {
          "dataStoreId": "postgres"
        }
      ],
      "externalCallIds": [],
      "work": "db-bound",
      "trafficHint": "rare",
      "evidence": [
        {
          "file": "app/(auth)/actions.ts",
          "lines": "54-84",
          "note": "Creates user with sync bcrypt hash, then signs in"
        },
        {
          "file": "lib/db/utils.ts",
          "lines": "4-9",
          "note": "hashSync cost 10"
        }
      ],
      "confidence": "medium"
    }
  ],
  "dataStores": [
    {
      "id": "postgres",
      "kind": "postgres",
      "provider": "unknown (POSTGRES_URL)",
      "orm": "drizzle",
      "tableCount": 7,
      "connection": "pool",
      "evidence": [
        {
          "file": "lib/db/queries.ts",
          "lines": "36-37",
          "note": "Module-level postgres.js client"
        },
        {
          "file": "lib/db/schema.ts",
          "note": "User, Chat, Message_v2, Vote_v2, Document, Suggestion, Stream"
        },
        {
          "file": "drizzle.config.ts",
          "note": "Drizzle postgres dialect"
        }
      ]
    },
    {
      "id": "redis",
      "kind": "redis",
      "provider": "unknown (REDIS_URL)",
      "connection": "pool",
      "evidence": [
        {
          "file": "lib/ratelimit.ts",
          "lines": "9-20",
          "note": "Long-lived redis client for IP rate limit"
        },
        {
          "file": "app/(chat)/api/chat/route.ts",
          "lines": "405-424",
          "note": "Resumable stream storage, optional"
        }
      ]
    },
    {
      "id": "blob",
      "kind": "object-storage",
      "provider": "Vercel Blob",
      "connection": "http-api",
      "evidence": [
        {
          "file": "app/(chat)/api/files/upload/route.ts",
          "lines": "50-54",
          "note": "put() public blob"
        }
      ]
    }
  ],
  "jobs": [
    {
      "id": "inline-title-update",
      "trigger": "inline",
      "lossImpact": "low",
      "description": "Chat title DB update fired without await inside the stream execute callback",
      "evidence": [
        {
          "file": "app/(chat)/api/chat/route.ts",
          "lines": "338-346",
          "note": "updateChatTitleById not awaited"
        }
      ],
      "confidence": "medium"
    }
  ],
  "externals": [
    {
      "id": "ai-gateway",
      "category": "llm",
      "provider": "Vercel AI Gateway",
      "blocking": true,
      "evidence": [
        {
          "file": "lib/ai/providers.ts",
          "lines": "20-34",
          "note": "gateway.languageModel for chat and title"
        },
        {
          "file": "app/(chat)/api/chat/route.ts",
          "lines": "269-330",
          "note": "Streaming call in request path"
        }
      ]
    },
    {
      "id": "ai-gateway-catalog",
      "category": "other",
      "provider": "Vercel AI Gateway model catalog",
      "blocking": true,
      "evidence": [
        {
          "file": "lib/ai/models.ts",
          "lines": "66-107",
          "note": "Capability fetch, revalidate 24h"
        },
        {
          "file": "app/(chat)/api/chat/route.ts",
          "lines": "199-200",
          "note": "getCapabilities awaited in chat POST"
        }
      ]
    },
    {
      "id": "botid",
      "category": "other",
      "provider": "Vercel BotID",
      "blocking": true,
      "evidence": [
        {
          "file": "app/(chat)/api/chat/route.ts",
          "lines": "83-91",
          "note": "checkBotId awaited in chat POST"
        }
      ]
    },
    {
      "id": "open-meteo",
      "category": "other",
      "provider": "Open-Meteo",
      "blocking": true,
      "evidence": [
        {
          "file": "lib/ai/tools/get-weather.ts",
          "lines": "5-66",
          "note": "Geocode and forecast fetch inside tool"
        }
      ]
    },
    {
      "id": "vercel-blob",
      "category": "storage",
      "provider": "Vercel Blob",
      "blocking": true,
      "evidence": [
        {
          "file": "app/(chat)/api/files/upload/route.ts",
          "lines": "50-54",
          "note": "Awaited put in upload"
        }
      ]
    },
    {
      "id": "vercel-otel",
      "category": "analytics",
      "provider": "OpenTelemetry via @vercel/otel",
      "blocking": false,
      "evidence": [
        {
          "file": "instrumentation.ts",
          "lines": "1-8",
          "note": "registerOTel and AI SDK telemetry"
        }
      ]
    }
  ],
  "realtime": [
    {
      "kind": "sse",
      "provider": "AI SDK UI message stream with resumable-stream over Redis",
      "evidence": [
        {
          "file": "app/(chat)/api/chat/route.ts",
          "lines": "405-427",
          "note": "SSE response, resumable stream when REDIS_URL set"
        }
      ]
    }
  ],
  "warnings": [
    "No maxOutputTokens set on any LLM call; chat allows up to 5 steps, and tools make nested streamText calls with no cap.",
    "app/(auth)/auth.ts and the rest of lib/db/queries.ts were not shown; auth routes and DB patterns inferred.",
    "app/(chat)/api/document DELETE handler was truncated; details inferred from imports.",
    "Redis rate limit is production-only and silently skipped if Redis is unavailable.",
    "Uploaded blobs are stored with public access.",
    "Other server actions (app/(chat)/actions.ts, artifacts/actions.ts) not emitted as routes; client imports not shown."
  ],
  "schemaVersion": 1,
  "meta": {
    "source": "github",
    "repo": "https://github.com/vercel/ai-chatbot",
    "analyzedAt": "2026-10-27T21:15:09.662Z",
    "fileCount": 174,
    "extractorModel": "anthropic/claude-sonnet-5.5",
    "skeramVersion": "0.0.1",
    "commit": "c2f8235e1f3e",
    "framework": "next",
    "deployHint": "vercel"
  }
}