Skip to content

Architecture Overview

Every Velox TS application is built from procedures — type-safe functions that define your business logic once and expose it through multiple protocols and frontiers simultaneously. Your architecture is shaped by two independent choices: how clients talk to your API, and how (or whether) you deliver a frontend.

At the heart of Velox TS is the procedure — a type-safe function that can be exposed as both tRPC and REST:

import { resourceSchema, resource } from '@veloxts/router';
// Define resource schema with field visibility
const UserSchema = resourceSchema()
.public('id', z.string())
.public('name', z.string())
.authenticated('email', z.string())
.build();
const getUser = procedure()
.input(z.object({ id: z.string() }))
.query(async ({ input, ctx }) => {
const user = await ctx.db.user.findUniqueOrThrow({
where: { id: input.id }
});
return resource(user, UserSchema.public);
});

This single definition generates:

  • tRPC endpoint — Full type inference for TypeScript clients
  • REST endpointGET /api/users/:id for any HTTP client
  • Context-dependent outputs — Different fields based on user access level

Because the same procedures power every architecture, your choices come down to two questions.

These options are non-exclusive. A single set of procedures can expose tRPC endpoints, REST endpoints, or both at the same time. You don’t have to pick one — and in fact, serving both protocols from the same procedures is the default.

ProtocolBest forLearn more
tRPCTypeScript clients, full type inferencetRPC API
RESTNon-TS clients, mobile apps, public APIs, OpenAPIREST API
BothDifferent consumers with different needs (the default)Hybrid

This choice is mutually exclusive — pick one project shape when you scaffold your application.

FrontendProject shapeProcess modelLearn more
Vite SPAMonorepo with apps/api + apps/webTwo processesSPA + Backend
RSC (Vinxi)Single package, file-based routingOne processFull-stack RSC
  • Building a backend for a TypeScript SPA? Use --default or --trpc
  • Building a full web app with SSR? Use --rsc or --rsc-auth
  • Need authentication? Use --auth or --rsc-auth
  • All your consumers are TypeScript? Use --trpc
  • Need OpenAPI docs or non-TS clients? Use --default or --auth
LayerTechnology
HTTP ServerFastify
RPCtRPC
ValidationZod
ORMPrisma
Full-stackVinxi + React 19