A Modelence project follows a well-organized structure that clearly separates client and server code, making it easy to build full-stack applications with TypeScript.
index.html - The main HTML template for your application. You typically don’t need to modify this file unless you want to add meta tags, external scripts, or customize the root template.
index.tsx - The React application entry point. This is where you initialize your client-side app using renderApp() and configure providers.
import { renderApp } from 'modelence/client';import routes from './routes';import './index.css';renderApp({ routes,});
index.css - Global CSS styles for your application. This file typically includes Tailwind CSS imports and any global style customizations.
routes.ts - Client-side routing configuration that maps URL paths to React components.
import { createBrowserRouter } from 'react-router-dom';import Home from './pages/Home';import About from './pages/About';export default createBrowserRouter([ { path: '/', element: <Home /> }, { path: '/about', element: <About /> },]);
The recommended approach is to organize server code into modules - self-contained units of functionality:
src/server/├── migrations/ # (Optional) App migration scripts│ ├── index.ts # Exports the ordered migrations array│ └── ... # One file per migration handler├── todo/│ ├── index.ts # Module definition│ ├── db.ts # Database stores│ └── utils.ts # Module utilities├── users/│ ├── index.ts│ └── db.ts└── app.ts # Main server file
Each module typically contains:
Module definition - Queries, mutations, and configuration
Database stores - MongoDB collection definitions
Business logic - Domain-specific utilities and helpers
For data evolution over time, keep app-level migration scripts under
src/server/migrations/ — one file per handler, with index.ts exporting the
ordered array passed to startApp({ migrations }). See
Migrations for the full layout.
Grouping code by modules (domains/features) rather than by type (controllers, models, etc.) makes your codebase more maintainable and easier to understand as it grows.
TypeScript configuration for your project. Modelence sets up appropriate defaults for both client and server code with path aliases and module resolution.