Module Anatomy
A standard module follows a strict directory structure to ensure the build system can discover its features.
Directory Structure
Section titled “Directory Structure”modules/{name}/├── api.yaml # API definitions (OpenAPI)├── models.yaml # Database schema extensions├── package.json # Dependency management├── src/│ ├── actions/ # Business logic controllers│ ├── agent/ # Background job processors│ ├── components/ # Internal React components│ ├── emails/ # Transactional email templates│ ├── pages/ # Astro/API routes│ ├── registry/ # UI Injection points│ ├── services/ # Domain logic & DB access│ └── styles/ # Tailwind CSS layers└── styles.css # Module-specific stylesMiddleware and Security
Section titled “Middleware and Security”Export a default object from src/middleware.ts to define security logic:
export default { publicRoutes: ['/login'], onRequest: async (context, next) => { // Custom logic return next(); },};Cross-Module Events
Section titled “Cross-Module Events”Use the Hook System to decouple features.
- Listen:
HookSystem.on('user.registered', callback) - Dispatch:
HookSystem.dispatch('user.registered', data)