Skip to main content

Blog System Tutorial — Overview

Goal: Give you a complete picture of what you will build and how the 12 steps fit together before you write a single line of code.

Files touched: (none — overview only)

Concepts: Domain-Driven Design with Webda, multi-protocol server (REST + GraphQL + gRPC).

What we'll build​

By the end of this tutorial you will have a production-shaped blog API exposing the same domain through three protocols simultaneously on a single TLS port:

ProtocolEntry pointDescription
RESThttps://localhost:18080/Auto-generated CRUD routes for every model
GraphQLhttps://localhost:18080/graphqlAuto-generated schema with queries and mutations
gRPClocalhost:18080 (H2)Auto-generated proto service, usable with grpcurl

The domain is a classic blog with a social layer:

User ──< Post ──< Comment
╲
╲──< PostTag >── Tag (many-to-many via join table)

User ──< UserFollow >── User (self-referential follower graph)

Final API surface (REST excerpt)​

MethodPathDescription
GET / POST/usersList / create users
GET / PUT / PATCH / DELETE/users/:uuidSingle-user CRUD
GET / POST/postsList / create posts
GET / PUT / PATCH / DELETE/posts/:slugSingle-post CRUD (custom PK)
PUT/posts/:slug/publishPublish action
GET / POST/commentsList / create comments
GET / POST/tagsList / create tags
POST / DELETE/posts/:slug/tags/:tagSlugTag a post
GET/versionApp version

GraphQL and gRPC mirror every CRUD operation and every custom @Operation.

Prerequisites​

  • Node.js ≥ 22.0.0 (node -v)
  • pnpm ≥ 9 (pnpm -v) — install with npm i -g pnpm
  • curl (for REST verification steps)
  • jq (optional, for pretty-printing JSON)
  • grpcurl (page 10 only — brew install grpcurl)
  • Docker is not required

The 12-step plan​

PageWhat you do
01 — SetupBootstrap an empty Webda project
02 — User modelFirst model, auto-REST, JSDoc validation
03 — Post modelCustom primary key (slug), BelongTo relation
04 — Comment modelNested ownership, Contains relation
05 — Tag + PostTagManyToMany via composite-key join table
06 — UserFollowSelf-referential composite-key model
07 — Service layer@Bean, dependency injection, @Operation
08 — REST tourWalk every endpoint from rest.sh
09 — GraphQLAdd @webda/graphql, run queries and mutations
10 — gRPCAdd @webda/grpc, call with grpcurl
11 — Next stepsAuth, persistent stores, deployment, observability

Quick clone — I just want to browse the finished code​

If you'd rather explore the finished implementation without following the steps:

git clone https://github.com/loopingz/webda.io.git
cd webda.io/sample-apps/blog-system
pnpm install
pnpm run build
pnpm run debug # starts on https://localhost:18080

The reference implementation lives at sample-apps/blog-system/src/ in the monorepo. Every code block in this tutorial is derived from that source.

What's next​

→ 01 Setup