Architecture

How VitNode combines TanStack Start for UI and isomorphic routing with Hono for API authorization and database access.

VitNode separates concerns between two core layers:

  1. TanStack Start: Frontend UI, SSR, isomorphic routing, and client caching.
  2. Hono API: Backend routing, session management, staff permissions, and database operations.

System Boundaries

ResponsibilityTanStack Start (Web App)Hono (API)
RoutingPage URLs, dynamic parameters, nested layoutsREST/RPC endpoints under /api/*
Data FetchingRoute loaders and createIsomorphicFnQuery execution via Drizzle ORM
State & CacheTanStack Query client cacheRedis domain cache & database storage
Security BoundaryUI guards (redirecting unauthenticated users)Enforces authentication, permissions, CSRF, and rate limits

Security Boundary

Route guards (beforeLoad) enhance UX by redirecting visitors early, but the Hono API is the true security boundary. All private endpoints strictly verify cookies and permissions on every request.


End-to-End Request Flow

When a user visits a page (e.g. /blog):

PhaseRuntimeAction
1. RequestBrowserVisitor navigates to /blog
2. RoutingServer (SSR) / BrowserTanStack Router matches route and executes loader
3. Query WarmingServer / Browsercontext.queryClient.ensureQueryData executes isomorphic fetcher
4. RPC CallServer / Browserfetcher (server) or fetcherClient (browser) calls Hono endpoint
5. API MiddlewareServer (Hono)Verifies session cookie, applies rate limits, injects c.get(db)
6. Handler & DatabaseServer (Hono)Handler validates input and queries PostgreSQL via Drizzle
7. ResponseServer / BrowserJSON data hydrates TanStack Query cache and paints component

Plugin System Architecture

VitNode is built around modular plugins located in plugins/*:

  • Independent Packages: Plugins compile to their own dist/ with isolated dependencies.
  • Unified Manifest: Routes, AdminCP navigation, and database models are registered declaratively.
  • Zero Overhead: Inactive plugins contribute no code or overhead to production bundles.

Learn More