Skip to content

Project Structure

Cohera builds on the standard SvelteKit project structure, adding directories for configuration, database schemas, and backend code.

  • Directorymy-cohera-project/
    • Directorysrc/
      • Directorylib/
        • Directoryserver/
        • Directorycomponents/ Your custom components
      • Directoryroutes/ SvelteKit routes
    • 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

Database layer. The schema.ts file imports and re-exports Drizzle schemas from installed modules:

src/lib/server/db/schema.ts
export * from "@cohera/auth/db";
export * from "@cohera/posts/db";

The cohera module add command updates this file automatically.

Backend code. The trpc.ts file composes tRPC routers from installed modules:

src/lib/server/trpc.ts
import { authRouter } from "@cohera/auth/api";
import { postsRouter } from "@cohera/posts/api";
export const appRouter = t.router({
auth: authRouter,
posts: postsRouter,
});

Standard SvelteKit routes. Create pages here that use Cohera module components and data.

Configuration files for the platform and installed modules:

FilePurpose
cohera.config.tsPlatform-wide settings
auth.config.tsAuth module configuration

Each module’s configuration file is created when you install the module. See individual module documentation for configuration options.

When you install a module with cohera module add:

  1. The module package is added to package.json
  2. Database schema exports are added to src/lib/server/db/schema.ts
  3. tRPC router is added to src/lib/server/trpc.ts
  4. A configuration file is created in config/
  5. Database migrations run automatically

To undo, use cohera module remove.

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.