-
Notifications
You must be signed in to change notification settings - Fork 0
Modules
PolyMPR is designed with a modulith architecture to ensure flexibility, scalability, and ease of maintenance. Each module is a self-contained unit that can be added, removed, or updated independently. π¦
Creating modules in PolyMPR is straightforward, thanks to its well-defined structure and conventions. Below, you'll find everything you need to know to build and integrate your own modules into the platform.
Each module must be placed inside the routes/(apps)/ folder and follow the
structure outlined below. This ensures consistency and makes it easier to
maintain and extend the platform.
.
βββ api/ # API endpoints for the module
βββ (_components)/ # Shared components used within the module
βββ (_islands)/ # Interactive islands (client-side components)
βββ partials/ # Reusable partial templates
β βββ index.tsx # Entry point for partials
βββ (_props)/
β βββ props.ts # Module-specific props
βββ index.tsx # Main entry point for the module
βββ types.d.ts # TypeScript type definitions for the module
Hereβs a breakdown of each folder and its purpose:
-
api/:- Contains API endpoints specific to the module.
- Each file in this folder represents a route handler for the module.
- Example:
api/users.tsfor handling user-related API requests.
-
(_components)/:- Houses shared React components used within the module.
- These components are reusable and can be imported into other parts of the module.
- Example: A
UserCard.tsxcomponent for displaying user information.
-
(_islands)/:- Contains interactive client-side components (islands) for the module.
- Islands are hydrated on the client side and enable interactivity.
- Example: A
SearchBar.tsxcomponent with dynamic search functionality.
-
partials/:- Stores reusable partial templates for rendering specific parts of the UI.
- The
index.tsxfile serves as the entry point for partials. - Example: A
Header.tsxpartial for rendering the module's header.
-
(_props)/:- Defines the properties of the module.
- The CLI creates this file.
-
index.tsx:- The main entry point for the module.
- The CLI creates this file.
-
types.d.ts:- Contains TypeScript type definitions specific to the module.
- This file ensures type safety and consistency across the module.
- Example: Defining types for API responses or component props.
To create a new module, you can use the CLI:
pmpr module create <module-name-kebab-case>It will create all the required files for a module.
Hereβs an example of how a users/ module might look:
users/
βββ api/
β βββ users.ts # API endpoints for user management
βββ (_components)/
β βββ UserCard.tsx # Component for displaying user info
βββ (_islands)/
β βββ SearchBar.tsx # Interactive search bar component
βββ partials/
β βββ index.tsx # Entry point for partials
βββ (_props)/
β βββ props.ts # Module-specific props
βββ index.tsx # Main entry point for the module
βββ types.d.ts # TypeScript type definitions
Now that you know how to create modules, you can start building and customizing PolyMPR to meet your organization's needs. Check out the following resources to continue your journey:
- Tutorials: Step-by-step guides to help you get the most out of PolyMPR. π
- CLI Documentation: Dive into the technical details of PolyMPR's CLI. π
- FAQs: Find answers to common questions about PolyMPR. β
- Release Notes: Stay up-to-date with the latest features and improvements. π°
Thank you for installing PolyMPR! If you have any questions or need further assistance, feel free to reach out to the community or consult the FAQs. Happy coding! π»β¨
PolyMPR is open-source and released under the MIT License π