The BuzzTrip backend is a Convex deployment that exposes fully-typed queries and mutations for every map and user operation in the platform. All schema definitions are validated with Zod at runtime viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/jacobsamo/buzztrip/llms.txt
Use this file to discover all available pages before exploring further.
convex-helpers, so the same schemas that define the database tables are also used to validate inputs to every function. The @buzztrip/backend package bundles the generated API types, data model types, Zod schemas, and helper utilities so any app in the monorepo can import exactly what it needs without depending on the raw Convex internals.
Package exports
The@buzztrip/backend package exposes the following entry points:
Generated Convex API types — the
api object used to reference queries and mutations in client and server code. Import this wherever you call useQuery, useMutation, fetchQuery, or preloadQuery.Generated data model types — includes
Doc<'tableName'> and Id<'tableName'> helpers for every table in the schema. Use these when you want the full Convex document type (with _id and _creationTime) rather than the Zod-inferred type.Zod validation schemas for all entities: maps, markers, collections, paths, places, labels, routes, users, and map views. Both the base schemas (for inserts) and the edit schemas (all fields optional) are exported.
TypeScript type exports inferred from the Zod schemas —
Map, Marker, Collection, Place, Path, Route, User, and all their New* / Combined* variants. Import these when you need types without the full Zod runtime.Utility functions shared across the monorepo. Includes the RBAC
canPerformAction helper and the rolePermissions map.ID generation utilities for creating document IDs outside of a Convex mutation context.
Calling Convex functions
Convex functions can be called from server components, server actions, and client components. The calling pattern differs slightly depending on the rendering context.From a Next.js server component
UsefetchQuery for one-shot data fetching, or preloadQuery to stream data into a client component using the Preloaded pattern.
convexNextjsOptions() injects the authenticated session token from Clerk so that server-side Convex calls respect the same auth rules as client calls. Always pass options to fetchQuery and preloadQuery for authenticated requests.From a client component
Use theuseQuery and useMutation React hooks from convex/react. These hooks integrate with the Convex WebSocket transport and automatically re-render the component whenever the underlying data changes — no polling required.
Function naming convention
Convex uses file-based routing: the path of a file insideconvex/ maps directly to its API reference on the api object. The table below shows the pattern:
| File path | API reference prefix |
|---|---|
convex/maps/index.ts | api.maps.index |
convex/maps/markers.ts | api.maps.markers |
convex/maps/collections.ts | api.maps.collections |
convex/users.ts | api.users |
convex/places/index.ts | api.places.index |
export const getMap = ... from convex/maps/index.ts is called as api.maps.index.getMap.
Authentication
All user-facing Convex functions in BuzzTrip are wrapped with eitherauthedQuery or authedMutation, both defined in convex/helpers.ts. These wrappers:
- Retrieve the Clerk identity from
ctx.auth.getUserIdentity() - Look up the corresponding
usersdocument byclerkUserId - Inject the full user document as
ctx.user - Throw an
"Unauthorized"error if no valid identity is found
Real-time subscriptions
One of Convex’s key features is thatuseQuery hooks are live queries — the Convex server pushes updates to all connected clients the moment any mutation changes data that the query depends on. This means:
- No manual polling or cache invalidation needed
- Collaborative edits (multiple users on the same map) are reflected instantly for all participants
- Optimistic UI can be layered on top using
useMutation’s built-in optimistic update API
Explore the backend
Schema
All database tables, fields, indexes, and TypeScript types.
Maps API
Queries and mutations for maps, markers, and collections.
Users API
User profile management and Clerk integration.
Places API
Shared places database, reviews, and photos.
Environment Variables
Required Convex and Clerk configuration variables.
Webhooks
Clerk and Svix webhook handlers for user sync.