Aller au contenu

Application Entry Point

Location: modules/application/app/

Overview

modules/application/app is the root entry point of the deployed application. It is not a reusable platform module — it is the wiring layer that imports all platform and business modules and hands them to the application shell provided by @platform/core.

It has no reusable exports. Nothing should import from it.

Structure

modules/application/app/
└── src/
    ├── client/
    │   ├── App.tsx          # Root React component — wires modules into Application
    │   ├── index.tsx        # Vite entry point (ReactDOM.createRoot)
    │   ├── index.html       # HTML template
    │   └── i18n.ts          # Configured i18next instance
    └── server/
        └── index.ts         # Express server entry point — imports all server modules

Client

App.tsx creates the Application shell from @platform/core/client and passes it the full list of modules:

import { Application } from '@platform/core/client'
import { MetalturaModule } from '@platform/metaltura/client'
import { ConsoleModule } from '@platform/console/client'
// ... other modules

export function App() {
  return (
    <Application
      name='Plateforme'
      logo='/logo.png'
      i18n={i18n}
      modules={[
        MetalturaModule,
        ConsoleModule,
        // ...
      ]}
    />
  )
}

Each entry in modules is a ModuleProps object (defined in @platform/core/client):

type ModuleProps = {
  name: string
  title: TranslationText
  buttons?: ApplicationSideBarButtonProps[]
  route?: RouteObject
}

Server

server/index.ts is the Express entry point. It imports the server initializers from every platform and application module that needs server-side registration:

import '@platform/socket/server'    // registers Socket.io
import '@platform/schema/server'    // registers pub/sub services
import '@platform/doc/server'       // connects MongoDB
import '@platform/metaltura/server' // registers metaltura socket service
// ... other server modules

Server modules register themselves as side effects when imported — no explicit function call is needed.

How to Add a New Application Module

  1. Create modules/application/<name>/ with the standard three-context layout.
  2. Implement server-side services/publications (optional).
  3. Export a ModuleProps object from the client context.
  4. Add the server import to modules/application/app/src/server/index.ts.
  5. Add the ModuleProps to the modules array in App.tsx.

See project-structure.md for the three-context module layout.