Anatomy of one human
Anatomy of one human
Before building anything, let's look at a whole "human" — one microservice — from head to toe. Every well-built service has the same body parts, whatever its job. Knowing the map lets you check any service for missing organs.
The parts, one by one
| Body part | Module | Its single responsibility | Chapter |
|---|---|---|---|
| Senses | Input adapters | Receive stimuli from the outside: requests, events, messages, files, timers | Senses |
| Skin | Contract and validation | Decide what may enter; reject malformed input early | Senses |
| Brain | Domain logic | Make decisions and apply business rules | Brain |
| Memory | Data store | Remember things reliably; nobody else reads it directly | Memory |
| Voice | Output adapters | Answer callers; announce what happened | Voice and hearing |
| Ears for others | Subscriptions | Listen to announcements from other humans | Voice and hearing |
| Hands | Integrations | Act on the outside world safely | Hands |
| Immune system | Security | Keep out what doesn't belong | Immune system |
| ID card | Service identity | Prove who this human is to the rest of the world | Immune system |
| Heart, pulse, diary | Observability | Show how the body is doing, record what happened | Heartbeat and health |
| DNA | Infrastructure as code | Build an identical body every time | CDK is DNA |
A healthy human, a checklist
When you design or review a microservice, walk down the body:
- Purpose — can you describe its one job in one sentence?
- Senses — which inputs does it accept? Are they documented?
- Skin — does it validate every input against a schema?
- Brain — is the logic separate from the plumbing (handlers, SDK calls)?
- Memory — does it own its data, with nobody else reading its database?
- Voice — does it publish events when something important happens?
- Hands — do outside calls have timeouts, retries and fallbacks?
- Immune system — least-privilege permissions, authentication, encryption?
- Heart — logs, metrics, traces, alarms?
- DNA — is the whole body defined in code and reproducible?
Key idea
A microservice is not "a Lambda function". It's a whole body: inputs, logic, data, outputs, security, health and the code that builds it. The rest of this section looks at each organ in detail.
How the body is laid out in code
services/
waiter/ ← one human
src/
senses/ ← Lambda handlers: API, events, queues (thin)
skin/ ← input schemas and validation
brain/ ← pure business logic (no AWS calls)
memory/ ← repository: reads/writes the service's table
voice/ ← event publishing
hands/ ← clients for other systems
infra/
waiter-dna.ts ← CDK construct: the body's DNA
test/
Names like senses/ and brain/ are deliberately playful for teaching — in a real codebase you might call them handlers/, domain/, repository/ and adapters/. The structure is what matters.