
Designing an Enterprise Monorepo with a Shared UI Core and Plop CLI Generators
Designing an Enterprise Monorepo with a Shared UI Core and Plop CLI Generators
When developing an ecosystem of internal corporate applications, one of the most persistent bottlenecks is development fragmentation. Every department needs a dedicated tool, but building each app as an isolated repository inevitably leads to diverging dependencies, duplicated components, and inconsistent user experiences.
To solve this at CITIC Dicastal, I architected a unified frontend monorepo using pnpm workspaces paired with a standalone @shared core library and automated Plop CLI code generators.
Here is how the architecture is designed and the engineering principles behind it.
1. The Multi-App Dilemma in Enterprise Environments
In a rapidly growing digital ecosystem, teams typically face three major challenges:
- Design Token Drift: Buttons, data tables, and modal dialogs look and behave slightly differently across apps.
- Setup Friction: Bootstrapping a new project (configuring Redux, TypeScript, routing, internationalization, and build pipelines) takes days.
- Dependency Hell: Upgrading a critical security package requires manual pull requests across dozens of repositories.
2. Monorepo Structure with pnpm Workspaces
We structured the workspace to separate reusable foundation logic from application-specific code:
root/
├── apps/
│ ├── ITMS/ # IT Operations & Management Suite
│ ├── HRIS/ # Enterprise Workforce Platform
│ ├── DSA/ # Digital Signage Network
│ └── WFX/ # Industrial Logistics & Scanning
├── packages/
│ └── shared/ # Enterprise UI, State & Utilities (@shared)
├── internals/
│ ├── generators/ # Plop templates for apps & modules
│ └── scripts/ # Custom workspace tools (focus.js)
├── pnpm-workspace.yaml
└── package.json
By utilizing pnpm workspaces, all applications share a single lockfile and link to packages/shared using "workspace:*". When a utility function or design token is updated in @shared, changes reflect immediately across all running apps during local development.
3. Engineering the Enterprise @shared Package
The shared library is bundled using tsup to emit both modern ESM (.mjs) and CommonJS (.js) modules alongside full TypeScript declarations (.d.ts).
Key modules packaged within @shared:
- Enterprise Design System: Pre-styled Material UI (MUI) wrappers, customized theme tokens, and high-performance MUI X DataGrid Premium configurations for complex tabular data.
- Dynamic State Management: Pre-configured Redux Toolkit with dynamic Redux-Saga injectors (
redux-injectors), allowing apps to inject sagas and reducers asynchronously without bloating the global store. - Real-Time Communication: Pre-authenticated SignalR client wrappers for pushing instant updates from the .NET backend.
- Virtualization & Layouts: Virtualized lists (
react-window), responsive splitters, and i18n localization providers pre-wired for French, English, and Arabic.
4. Automating Scaffolding with Plop CLI
To eliminate days of manual bootstrapping whenever a new corporate tool is requested, we built automated generators using Plop.js.
Running a single command:
pnpm generate:app
Prompts the developer for the application name and port, then automatically:
- Scaffolds a complete React 18 + TypeScript application in
apps/<AppName>. - Pre-wires routing, layout shells, and theme providers from
@shared. - Registers workspace scripts (
dev:<app>,build:<app>) in the rootpackage.json. - Configures Vite / Webpack build pipelines and GitLab CI deployment configs.
A new, production-ready enterprise app is created in under 10 seconds.
5. Lightweight Local Development with focus.js
Large monorepos can suffer from memory bloat in IDEs if all projects are indexed simultaneously. We introduced a custom focus.js utility script that allows engineers to "focus" on a single application. The script dynamically generates localized VS Code workspace configurations, keeping memory usage minimal and developer feedback loops instantaneous.
Key Takeaways
- Invest in the Foundation Early: A robust shared library cuts development time for future features in half.
- Automate Boilerplate: CLI generators guarantee consistent architecture and eliminate onboarding friction.
- Monorepos Require Tooling: Workspace scripts and focus utilities keep developer machines fast and builds reproducible.

About the Author
Ayoub Bourhfella is a Full-Stack Web & Mobile Developer on the Digitalization Team at CITIC Dicastal, 1st Place Champion at EnergySkills RSK 2025, and 2nd Place Winner at the AFZIA Digital Competition. Specializes in .NET, React TypeScript monorepos, and cloud infrastructure.