The model can output anything. Your parser must handle repeated paths (last wins), path traversal attempts (reject silently), unclosed fences (discard), and parse failures that must not roll back an already-saved message. This post builds the full parse → normalize → upsert pipeline with intentional two-layer error isolation.
[Read More]
Build your own X: A minimal AI app builder — Part 4: Streaming end to end — SSE, tee(), and concurrent persistence
You need two consumers of the same HTTP response stream: one for the browser so text appears token by token, one for the server so the full reply gets saved. ReadableStream.tee() splits one stream into two without buffering the whole thing. This post builds POST /api/chat around that trick plus...
[Read More]
Build your own X: A minimal AI app builder — Part 3: The LLM contract — system prompt, Message model, and history trimming
The system prompt is not documentation—it is the schema that your parser reads. This post builds the Message table, validates POST bodies so you never trust the client for chat history, designs the file fence contract, and trims long histories before they overflow the context window.
[Read More]
Build your own X: A minimal AI app builder — Part 2: Files as source of truth, atomic project creation, and template seeding
Every feature in this app—the AI context, the workbench, the preview—reads from the same FileEntry table in SQLite. This post explains why that single-source design matters, how to seed a full Vite + React template atomically in one transaction, and one bundler gotcha that silently breaks Prisma interactive transactions.
[Read More]
Build your own X: A minimal AI app builder — Part 1: What you are really building (and why the obvious approach breaks)
Before you write a line of code, you need to understand the four non-trivial problems hiding inside "chat → edit files → preview". This post maps the full architecture, explains where naive implementations fail, and gets the Next.js + Prisma skeleton running so you have something to build on.
[Read More]
Hệ thống mạng giả lập trong MIT 6.5840: Xây dựng labrpc từ đầu
Bài viết này phân tích hệ thống mạng giả lập (labrpc) được dùng để kiểm thử Raft trong MIT 6.5840. Thay vì socket TCP thật, hệ thống sử dụng Go channel để mô phỏng mạng, hỗ trợ giả lập mất gói tin, trễ, và phân vùng mạng — tất cả...
[Read More]
MIT 6.5840 Simulated Network: Building labrpc from Scratch
This post walks through the simulated network stack (labrpc) used to test Raft in MIT 6.5840. Instead of real TCP sockets, it uses Go channels to emulate the network—with packet loss, delay, and partitions—all inside a single process.
[Read More]
Lab 3B khóa MIT 6.5840: Xây dựng thuật toán đồng thuận Raft - Phần 2: Sao chép Log
Bài viết thứ tư trong chuỗi bài về hệ thống phân tán qua các bài lab của khóa học MIT 6.5840. Phần này trình bày cách triển khai cơ chế sao chép log trong thuật toán Raft — bước chuyển từ "chọn được leader" sang "đồng thuận thực sự về...
[Read More]
MIT 6.5840 Lab 3B: Building Raft Consensus — Part 2: Log Replication
The fourth post in the MIT 6.5840 distributed systems series. This post covers the implementation of log replication in Raft — the step that transforms "we elected a leader" into "we genuinely agree on a sequence of commands."
[Read More]
Lab 3A khóa MIT 6.5840: Xây dựng thuật toán đồng thuận Raft - Phần 1: Bầu cử Leader
Bài viết thứ ba trong chuỗi bài về hệ thống phân tán qua các bài lab của khóa học MIT 6.5840. Phần này trình bày cách triển khai cơ chế bầu cử leader trong thuật toán Raft — nền tảng cho một hệ thống phân tán có khả năng chịu...
[Read More]