CodeVetter · Repo Unpack · Data flow
withastro/astro
Configuration enters through CLI flags and executable project config, then becomes validated settings and generated manifests. Build environments discover routes and client assets before emitting deployment output. Requests use a manifest plus isolated FetchState to move through middleware, action or page dispatch, and provider finalization. Content loaders transform source records into scoped mutable stores; serialized snapshots become generated runtime modules and read-only query sources.
- resolveConfig() resolves the root, loads project config, merges inline configuration with higher priority, and validates the merged result before returning userConfig and astroConfig.
- Config discovery checks astro.config.mjs, .js, .ts, and .mts; loadConfig() delegates executable configuration loading to loadConfigWithVite().
- Integration setup mutates renderer, script, injected-route, watch-file, toolbar, client-directive, and middleware settings through named hook callbacks.
- DefaultFetchHandler.fetch() combines a Request, render options, and explicit or ambient manifest into FetchState, then delegates to handleRequest().
- FetchState initializes locals, URL, cookies, client address, and timing; forwarded headers are applied only with configured allowedDomains and for non-prerendered routes.
- The request handler registers session/cache providers, runs middleware around actions and pages, applies i18n processing, finalizes providers, and prepares the outgoing response.
- Action request input is parsed according to Content-Type and manifest.actionBodySizeLimit, then bound to an ActionAPIContext before invoking the resolved handler.
- ContentLayer supplies each loader a scoped store, metadata store, schema parser, Markdown renderer, digest generator, watcher, and entry-type map.
- MutableDataStore.set() updates collection maps and schedules saving; writeToDisk() serializes in-process writes, invokes the writer, and notifies listeners only when persisted data changed.
- Runtime content loading imports astro:data-layer-content, handles Map, flattened-array, or chunk-manifest representations, wraps the immutable store in InMemorySource, and exposes queries through globalDataStore.