# Data flow — fastify/fastify

> Canonical page: https://codevetter.com/unpack/fastify/data-flow

# Data flow — fastify/fastify

Scanned commit 19d5be0daf1c0daace758efe3ea788f924ca1224 (2026-09-29). Generated by codevetter codevetter 1.15.0 on 2026-10-02.

Source inspection; upstream code and tests were not executed.

Route definitions become contexts whose hooks and compiled schemas are finalized during boot. Incoming transport objects become scoped Request and Reply objects before entering the hook and parsing pipeline. Validation can transform request parts, and handler results enter the reply serializer and output hooks. State is predominantly instance and route state; documented persistence crosses into separately registered database clients.
- Route options populate Context with a bound handler, schema, configuration, compiler overrides, body limit, and handler timeout. — [lib/route.js#L328-354](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/route.js#L328-L354)
- router.on stores routeHandler and Context together; preReady subsequently binds inherited and route-local hooks. — [lib/route.js#L359-360](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/route.js#L359-L360) [lib/route.js#L388-395](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/route.js#L388-L395)
- routeHandler derives a request ID and logger, then creates context.Request and context.Reply from raw transport objects and router outputs. — [lib/route.js#L460-480](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/route.js#L460-L480) [lib/route.js#L526-529](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/route.js#L526-L529)
- runPreParsing initially stores request.raw as the payload stream and passes through a preParsing runner before handleRequest. — [lib/route.js#L651-665](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/route.js#L651-L665)
- For body-bearing methods, handleRequest chooses a parser using Content-Type; invalid media types produce 415. — [lib/handle-request.js#L39-82](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/handle-request.js#L39-L82)
- rawBody accumulates buffers, enforces received and encoded byte limits, checks declared content length, and decodes or copies once before parser invocation. — [lib/content-type-parser.js#L268-286](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/content-type-parser.js#L268-L286) [lib/content-type-parser.js#L302-323](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/content-type-parser.js#L302-L323)
- Successful parsing assigns request.body and proceeds to handler; parsing failure marks the reply as an error and requests connection closure. — [lib/content-type-parser.js#L230-242](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/content-type-parser.js#L230-L242)
- validateParam passes parentData to Ajv-compatible validators and permits synchronous custom results to replace a request part through value. — [lib/validation.js#L286-326](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/validation.js#L286-L326)
- preSerializationHookEnd chooses reply-specific, instance-default, or schema-based serialization, then enters onSendHook. — [lib/reply.js#L534-555](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/lib/reply.js#L534-L555)
- The documented Redis persistence path reads req.body.key/value, calls the plugin-provided redis.set, and replies from its completion callback. — [docs/Guides/Database.md#L81-98](https://github.com/fastify/fastify/blob/19d5be0daf1c0daace758efe3ea788f924ca1224/docs/Guides/Database.md#L81-L98)

Every claim links to its cited files at the pinned commit. Citations identify source evidence; they do not establish runtime correctness. Independent CodeVetter scan — not reviewed by upstream maintainers.

## Public product links

- [CodeVetter](https://codevetter.com/)
- [Download](https://codevetter.com/download)
- [Documentation](https://codevetter.com/docs/)
- [Source](https://github.com/Codevetter/codevetter)
