ToolStackAI
A full-stack AI workspace that keeps chat, document retrieval, and debugging in one place. The client streams model output over SSE; the API handles retrieval, tool orchestration, and isolated diagnostic runs.
- Design & full-stack implementation
- Personal project
- 2026
Scope
- LLM response streaming
- RAG document retrieval
- Vector search & embeddings
- AI debugging assistant
- Tool calling & orchestration
- Encrypted API key storage
Problem
LLM chat, codebase document search, and debugging helpers usually live in separate tools. Moving context between them is manual, and the reasoning behind a result is easy to lose.
Approach
A Next.js and React client talks to an Express API. Chat responses stream over Server-Sent Events. Documents are chunked, embedded, and stored in PostgreSQL with pgvector. The debugging assistant runs diagnostics through an isolated runner instead of executing against application data.
Architecture
The API gateway routes chat, ingestion, retrieval, and debug requests to separate services. A background worker handles document chunking and embedding so uploads do not block the request path. PostgreSQL with pgvector stores documents, chunks, embeddings, and application records; Prisma is the data layer. Docker packages the services for local and deployed environments.
- Next.js App Router
- React 19
- SSE stream client
- Express 5
- JWT auth
- Zod validation
- Tool orchestration
- NVIDIA NIM
- RAG pipeline
- pgvector retrieval
- Debug runner
- PostgreSQL
- Prisma
- Background worker
- Docker
Key decisions
SSE over WebSockets for chat streams
After a prompt is sent, the data flow is server-to-client only. SSE keeps the connection lifecycle simpler than a bidirectional socket and is enough for token streaming.
PostgreSQL + pgvector instead of a separate vector database
Keeping embeddings beside application data means one transactional store and one backup path. At this scale, that is a better operational tradeoff than adding another database.
Move ingestion out of the request path
Chunking and embedding are slow, bursty operations. A background worker keeps uploads responsive and makes retries possible without holding an HTTP request open.
Isolate diagnostic execution
The debugging assistant runs in a separate runner schema with restricted inputs, so a diagnostic run cannot read or mutate application records.
Encrypt API keys at rest
Provider keys are stored with AES-256-GCM rather than plaintext, and request payloads are validated with Zod before they reach service logic.
Challenges & solutions
Document ingestion made the API feel unresponsive.
Moved chunking and embedding to a worker with batched embedding calls and explicit job states.
Serverless connection limits caused pool exhaustion.
Reused a cached Prisma client and bounded the connection pool instead of opening a client per invocation.
Streaming failures were hard to distinguish from slow responses.
Defined explicit SSE event types for token, done, and error, then handled each state in the client.
Debug runs needed to be useful without being dangerous.
Kept execution in an isolated runner schema with restricted inputs and no access to application tables.
Outcomes
- Streaming responses render incrementally instead of waiting for the full completion.
- Retrieval returns relevant chunks from the user's own document corpus.
- Diagnostic runs are isolated from application data.
- API keys are encrypted at rest and request payloads are validated.
- Reduced text-processing overhead by 40% (documented in resume).
Stack
- React 19
- Next.js
- TypeScript
- Express 5
- Node.js
- PostgreSQL
- pgvector
- Prisma
- NVIDIA NIM
- Tailwind CSS
- JWT
- Zod
- Docker
- SSE