Cheat sheet · Specialise
GenAI app architecture cheat sheet (TypeScript + Node)
Opens with creditsA quick-revision book on how the pieces of a real GenAI app connect, with a Node backend: the request path, what each layer owns, where RAG, tools, memory, caching and guards sit, how to evaluate and trace it, and a project layout you can copy. It is about the shape of the system, not which model to buy.
Chapters
10 chapters · 58 concepts
1The request flowWhat happens between a user pressing Send and the answer appearing, and which part of the system owns each step.5 concepts
- 1Request flow end to endFrontend sends the message to your backend API.
- 2AI orchestratorThe code that turns one user message into model calls: it loads memory, rewrites the query, retrieves, builds the prompt, runs the tool loop and applies guards.
- 3Model client wrapperOne small module that every model call goes through.
- 4Data stores in a GenAI appUsually four: the main database (users, chats, messages), a vector index (often inside Postgres), object storage for uploads, and a cache such as Redis.
- 5Request path vs background jobsChat replies run in the request.
5 in this chapterOpen this chapter2Frontend and backend layersWhat the browser owns (chat, sign-in, uploads, streaming, history) and what the server owns before any model is called: identity, permissions, validation, business rules, limits and logs.10 concepts
- 1Chat UIMessage list, input box, stop button, retry, copy, citations shown as links and a thumbs up or down on each answer.
- 2Streaming to the browserThe backend sends tokens as they arrive, usually over server-sent events, and the UI appends them to the last message.
- 3File uploadsThe browser uploads to object storage (often with a short-lived signed URL), then tells the backend the file id so a worker can parse and index it.
- 4Auth and chat history in the UIThe frontend holds a session or token and loads past conversations from the backend, never from local storage alone.
- 5No model keys in the frontendThe browser never calls the model provider directly with your API key; every call goes through your backend.
- 6Authentication and authorisationAuthentication proves who the user is; authorisation decides which chats, documents and tools they may use.
- 7Request validationCheck message length, file ids, conversation ownership and allowed options with a schema before doing any work.
- 8Business logic outside the promptPlans, quotas, pricing, which documents a team owns and what an action may change are decided in normal code and data, then passed to the model as facts.
- 9Rate limits and quotasLimits per user and per IP on requests per minute, plus a daily token or cost budget per user or team.
- 10Structured loggingEvery request logs a request id, user id, route, status, latency, model, tokens and cost as structured fields, not free text.
10 in this chapterOpen this chapter- The RAG pipelineWhere retrieval sits in the system. The RAG cheat sheet covers each technique in depth; this chapter is about the moving parts and who runs them.5 conceptsOpens with credits
- Tools and the agent loopHow the orchestrator lets a model act: plan, choose a tool, run it, check the result and decide again, inside limits your code sets.6 conceptsOpens with credits
- Memory, caching, rewriting and routingThe parts that make a chat feel continuous, cheap and fast: what the app remembers, what it reuses and which model handles which request.6 conceptsOpens with credits
- Three guard layersChecks around the model in three places: on what the user sends, on the content the model reads, and on what the model returns.5 conceptsOpens with credits
- The evaluation folderEvals live in the repo next to the prompts they test. The AI evals cheat sheet covers metrics and tools; this is how they fit the project.4 conceptsOpens with credits
- ObservabilitySeeing what happened inside one request, what users thought of it and what it cost.4 conceptsOpens with credits
- A reference project layoutOne way to lay out the repo so each layer has a home. Rename freely; the point is that prompts, evals and agent instructions are files in Git.6 conceptsOpens with credits
- Production checklistWhat must be true before real users arrive: packaging, delivery, secrets, API security, monitoring and cost limits.7 conceptsOpens with credits
- 11Glossary, A to ZEvery concept in the sheet and the smaller terms it uses, in one list.64 terms
About this sheet
How a production GenAI app fits together: request flow, layers, RAG, agent loop, memory, caching, guards, evals, tracing, folder layout and launch checklist.
Related on Sefism
Picked from the other libraries by shared topics.
Roadmaps
See allBest practices
See all- Best Practices for Building LLM AppsHow to build LLM apps and agents that hold up in production: prompts, evals, prompt injection, tool permissions, cost, logging and privacy.
- Best Practices for AI Coding AssistantsHow to get reliable code from AI coding assistants and agents: instruction files, task prompts, verification, review, security, dependencies and session hygiene.
- Prompt Engineering Best PracticesHow to write prompts that work the same way on the hundredth input as on the first: clear instructions, structure, examples, reasoning, output control and testing.
Checklists
See all- RAG Production ChecklistA RAG production checklist: chunking, embeddings, hybrid search, reranking, per-user permissions, citations, evals, re-indexing and cost, with how to verify each check.
- LLM Evaluation ChecklistAn LLM evaluation checklist: success criteria, eval datasets, code and model graders, judge calibration, agent evals, safety tests and production monitoring, with how to verify each check.
- AI Feature Launch ChecklistAn AI feature launch checklist: use case fit, evals, UX for errors, disclosure, human override, abuse filters, rate limits, cost caps, prompt privacy, monitoring and rollback.
Project structures
See all- GenAI RAG app (FastAPI) project structureFor developers turning a "chat with your documents" demo into an app people can rely on. A FastAPI backend where every layer has a home: ingestion workers, retrieval, prompts as versioned files, model clients with fallbacks and cost caps, guards, evals that gate CI, and tracing, so a wrong answer can be traced to the step that caused it.
- AI agent with an MCP server project structureFor developers who want to give AI assistants safe access to their own data or API. A TypeScript MCP server built on the official SDK, organised by feature (tasks, projects) with each feature owning its tools, resources and prompts, served over stdio for local hosts and Streamable HTTP with OAuth for remote ones, plus a small agent and the evals that prove a model can use it.
- Python AI agent with LangGraph project structureFor Python developers moving from "call a model in a loop" to an agent that can pause, resume and be debugged. It starts from the official LangGraph template (langgraph.json, a src/agent package, unit and integration tests) and grows into a customer support agent with typed state, one file per node and tool, human approval before refunds, evals that score whole trajectories, tracing, auth and a deployable server image.
Career questions
See all- How do I start learning AI agents as a software engineer?Start with one LLM API and plain code: a loop that calls the model, lets it pick a tool, runs the tool and feeds the result back. Build one small agent that does a real task end to end, add evaluation and guardrails, and only then reach for a framework. Agents are software engineering first.
- Should I learn LangGraph, CrewAI or the OpenAI Agents SDK first, or build AI agents without a framework?Build one small agent without a framework first: the tool-calling loop is about fifty lines and every framework wraps it. Then learn one framework deeply, chosen by what your project needs: LangGraph for explicit state and approvals, the OpenAI Agents SDK for quick assistants with handoffs, the Claude Agent SDK for agents that work on files.
- What is MCP, and do I need to learn it?MCP, the Model Context Protocol, is an open standard for connecting AI applications to tools and data. You do not need to study it in depth, but if you build with LLMs, writing one small MCP server takes an afternoon and teaches you how agents really use tools. Learn the concepts; skip the hype.
Cheat sheets
See all- AI agents and MCP cheat sheetTool calling, MCP servers, evals.
- RAG cheat sheetRetrieval augmented generation end to end: chunking, embeddings, hybrid retrieval, reranking, grounded prompts, evaluation and failure modes.
- AI evals cheat sheetEvals for LLM apps and agents: golden datasets, metrics, LLM-as-judge and its biases, RAG and agent metrics, offline and online evals, CI, human review, tools.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
- 1:1 Mentorship
- Fresh Graduate Mentorship
- Career Guidance
Brand deals, promos and partnerships: tauseeffayyaz@gmail.com