Project Structure
Cohera builds on the standard SvelteKit project structure, adding directories for configuration, database schemas, and backend code.
Overview
Section titled “Overview”Directorymy-cohera-project/
Directoryconfig/
- cohera.config.ts Platform configuration
- auth.config.ts Auth module configuration
Directorystatic/ Static assets
- …
- package.json
- svelte.config.js
- vite.config.ts
- drizzle.config.ts
Key Directories
Section titled “Key Directories”src/lib/server/db/
Section titled “src/lib/server/db/”Database layer. The schema.ts file imports and re-exports Drizzle schemas from installed modules:
export * from "@cohera/auth/db";export * from "@cohera/posts/db";The cohera module add command updates this file automatically.
src/lib/server/
Section titled “src/lib/server/”Backend code. The trpc.ts file composes tRPC routers from installed modules:
import { authRouter } from "@cohera/auth/api";import { postsRouter } from "@cohera/posts/api";
export const appRouter = t.router({ auth: authRouter, posts: postsRouter,});src/routes/
Section titled “src/routes/”Standard SvelteKit routes. Create pages here that use Cohera module components and data.
config/
Section titled “config/”Configuration files for the platform and installed modules:
| File | Purpose |
|---|---|
cohera.config.ts | Platform-wide settings |
auth.config.ts | Auth module configuration |
Each module’s configuration file is created when you install the module. See individual module documentation for configuration options.
Module Integration
Section titled “Module Integration”When you install a module with cohera module add:
- The module package is added to
package.json - Database schema exports are added to
src/lib/server/db/schema.ts - tRPC router is added to
src/lib/server/trpc.ts - A configuration file is created in
config/ - Database migrations run automatically
To undo, use cohera module remove.
Custom Code
Section titled “Custom Code”Add your own code alongside module code:
- Components:
src/lib/components/for Svelte components - Routes:
src/routes/for pages and API routes - Server utilities:
src/lib/server/for backend helpers - Shared types:
src/lib/types/for TypeScript types
Cohera modules use the @cohera/ namespace, so your code won’t conflict.
See Also
Section titled “See Also”- Architecture for how the layers work together
- CLI Reference for available commands