This project makes use of @nesterow/xmod
module system. The import is allised to @xmod
This document provides an overview of the frontend architecture for this project.
The frontend is a Preact application built with Vite and Deno. It follows a modular architecture, where features are organized into self-contained modules. This approach promotes code reusability, maintainability, and scalability.
A typical module has the following structure:
mod.ts: The entry point of the module. It exports the module definition.store.ts: The state management for the module, using@preact/signals.- Components (e.g.,
MyComponent.tsx): Preact components related to the module.
To create a new module, follow these steps:
- Create a new directory in the project directory.
- Create a
mod.tsfile that exports a module definition. - Create a
store.tsfile to manage the module's state. - Create the necessary components for the module.
Modules can interact with each other through the store instance.
The application uses @preact/signals for state management. The state is
organized by modules, and each module has its own store.ts file.
The store.ts file exports the following functions:
state(): A function that returns the initial state of the module.persist(): A function that returns the state that should be persisted tolocalStorage.mutate(): A function that mutates the state based on a command.
The application state is accessible through the app.state property in the
application context.
The project follows a consistent codestyle to ensure readability and maintainability.
- Typing: The code is written in TypeScript.
- Naming Conventions:
- Components are named in
PascalCase. - Files are named in
PascalCasefor components andkebab-casefor other files. - Variables and functions are named in
camelCase.
- Components are named in
- Component Structure:
- Components are defined in their own files.
- The component file should be located in the module's directory.
- The component file should export the component as the default export.
- Imports:
- Imports are organized by modules.
- Absolute imports are used for modules (
@/module_name/...). - Relative imports are used within a module.
END OF DOCS