Feature #31769
open
Improvement #31248: New Theme based Nextjs application dev analysis
implement support multiple clients (e.g., `book-sulthan`, `client-b`) from a single codebase.
Added by Sachin Suresh 4 months ago.
Updated 3 months ago.
Due date:
12/31/2025 (about 3 months late)
- Status changed from Assigned to In Progress
- Multi-Client Architecture
- Overview
This document outlines the architecture enabling CaxEngine to support multiple clients (e.g., `book-sulthan`, `client-b`) from a single codebase.
- 1. Dynamic Code Resolution
Instead of hardcoding client paths, the project uses a dynamic alias strategy.
- Alias: `@/client-views`
- Resolution: Maps to `src/components/client/<active-client>`
- Mechanism:
* `next.config.mjs` reads the active client config at build time.
* It updates the Webpack resolution for `@/client-views`.
* It creates a global `process.env.CLIENT` variable (optional but good for debugging).
- 2. Configuration (`client.config.json`)
The active client is determined by `client.config.json` located in the project root.
```json
{
"client": "book-sulthan"
}
```
This file is the Source of Truth for the `set-client.js` script, though `next.config.mjs` can also fall back to `process.env.CLIENT` if set.
- 3. Client Switching Script (`set-client.js`)
A Node.js utility script is used to switch contexts. It performs three atomic updates to ensure the environment is consistent:
1. `client.config.json`: Updates the JSON value.
2. `tsconfig.json`: Updates the `paths` mapping for `@/client-views/*` so IntelliSense works.
3. `.vscode/launch.json`: Updates the `CLIENT` environment variable in debug configurations so VS Code debugging targets the correct client.
Usage:
```bash
node set-client.js <client-name>
```
- 4. Directory Structure
- `src/components/core`: Shared business logic (Headless).
- `src/components/client/`: Container for all client implementations.
* `book-sulthan/`: Default client.
* `client-b/`: Secondary client.
* `...`: Future clients.
- 5. Build & Dev Scripts
`package.json` includes convenience scripts using `cross-env` to set the environment variable explicitly, which overrides `client.config.json` inside `next.config.mjs` (if configured to do so, though currently `client.config.json` is primary).
- `npm run dev:book-sulthan`
- `npm run build:client-b`
need to implement pages and layout inside client folder
- Status changed from In Progress to On hold
- Status changed from On hold to In Progress
the pages router issues fixed
cache issue fixed
updated custom config files for each client
- Due date changed from 12/30/2025 to 12/31/2025
- Status changed from In Progress to On hold
- % Done changed from 0 to 80
Also available in: Atom
PDF