Routes Overview
164 route files in backend/src/routes/, organized by API path prefix. All routes use OpenAPIHono for automatic OpenAPI spec generation with Zod schema validation on inputs and outputs.
Route Organization
| Path Prefix | Route File(s) | Entity/Feature |
|---|---|---|
/api/auth | auth.ts, entra-auth.ts | Authentication, Azure Entra |
/api/users | users.ts | Users |
/api/buildings | buildings/ (directory) | Buildings, Building Components |
/api/projects | projects.ts | Projects |
/api/scenarios | nested under projects | Scenarios |
/api/contacts | contacts.ts | Contacts |
/api/companies | companies.ts | Companies |
/api/leads | leads.ts | Leads |
/api/quotes | quotes.ts | Quotes |
/api/invoices | invoices.ts | Invoices |
/api/products | products.ts | Products |
/api/funding-programs | funding-programs.ts | Funding Programs |
/api/funding-applications | funding-applications.ts | Funding Applications |
/api/document-obtaining | document-obtaining/ (directory) | Document Obtaining |
/api/document-requests | document-requests.ts | Documents |
/api/files | files/ (directory) | Files |
/api/workflow | workflow/ (directory) | Workflows |
/api/portal | portal/ (directory) | Portal |
/api/admin | admin/ (directory) | Admin Dashboard |
/api/hubspot | hubspot/ (directory) | HubSpot Integration |
/api/forms | forms.ts | Forms |
/api/appointments | appointments.ts | Appointments |
/api/departments | departments.ts | Departments |
/api/config | config/ (directory) | System configuration |
/api/health | health.ts | Health checks |
/api/feedback | feedback.ts | Feedback System |
/api/audit-log | audit-log.ts | Audit Logs |
/api/pdf | pdf/ (directory) | PDF Templates |
/api/notifications | notifications.ts | Notifications |
Route Pattern
const route = createRoute({
method: 'get',
path: '/api/buildings/:id',
request: { params: BuildingParamsSchema },
responses: { 200: { content: { 'application/json': { schema: BuildingResponseSchema } } } },
});
app.openapi(route, async (c) => {
const { buildings } = c.var.services; // Destructure from DI
const result = await buildings.getById(c.req.valid('param').id);
return c.json(result);
});Service Access Rule
Always destructure services from c.var.services — never alias:
// Correct
const { documentRequests, portal } = c.var.services;
// Wrong -- never alias
const requestService = c.var.services.documentRequests;See Service Layer Pattern, Dependency Injection.
Related
- Backend Architecture — Overall backend structure
- Services Overview — Business logic called by routes
- Backend Middleware — Middleware pipeline before routes
- Middleware Stack — Security and auth middleware order
- Validation Pattern — Zod schema validation on all inputs