Architecture Overview
VeloxTS is designed to be flexible. You choose the architecture that fits your needs.
The Core Abstraction: Procedures
Section titled “The Core Abstraction: Procedures”At the heart of VeloxTS is the procedure - a type-safe function that can be exposed as both tRPC and REST:
const getUser = procedure() .input(z.object({ id: z.string() })) .output(UserSchema) .query(async ({ input, ctx }) => { return ctx.db.user.findUniqueOrThrow({ where: { id: input.id } }); });This single definition generates:
- tRPC endpoint - Full type inference for TypeScript clients
- REST endpoint -
GET /api/users/:idfor any HTTP client
Architectural Patterns
Section titled “Architectural Patterns”1. REST API
Section titled “1. REST API”External-facing API with automatic OpenAPI generation.
Client (any) → REST → VeloxTS → Database2. tRPC API
Section titled “2. tRPC API”Maximum type safety for TypeScript clients.
TypeScript Client → tRPC → VeloxTS → Database3. SPA + Backend
Section titled “3. SPA + Backend”Separate frontend, type-safe communication.
React SPA → tRPC Client → VeloxTS API → Database4. Full-stack RSC
Section titled “4. Full-stack RSC”Unified codebase with React Server Components.
Browser → Vinxi → RSC → Server Actions → VeloxTS → Database5. Hybrid
Section titled “5. Hybrid”Combine patterns - tRPC for internal, REST for external.
Mobile App → REST ↘ VeloxTS → DatabaseWeb App → tRPC ↗Technology Stack
Section titled “Technology Stack”| Layer | Technology |
|---|---|
| HTTP Server | Fastify |
| RPC | tRPC |
| Validation | Zod |
| ORM | Prisma |
| Full-stack | Vinxi + React 19 |
Next Steps
Section titled “Next Steps”Choose your architecture:
- REST API - External clients
- tRPC API - TypeScript clients
- SPA + Backend - Separate frontend
- Full-stack RSC - Unified codebase