|
| 1 | +# Web Architecture |
| 2 | + |
| 3 | +DiracX Web is organized as a monorepo using [npm workspaces](https://docs.npmjs.com/cli/v10/using-npm/workspaces). Local packages are resolved from their workspace versions rather than the npm registry. |
| 4 | + |
| 5 | +```mermaid |
| 6 | +--- |
| 7 | +config: |
| 8 | + layout: elk |
| 9 | +--- |
| 10 | +flowchart TD |
| 11 | + subgraph monorepo["Monorepo"] |
| 12 | + components["diracx-web-components"] |
| 13 | + web["diracx-web"] |
| 14 | + extensions["extensions (gubbins)"] |
| 15 | + end |
| 16 | + web -. uses .-> components |
| 17 | + extensions -. uses .-> components |
| 18 | + components -- published on --> npm["npm registry"] |
| 19 | + community["Community extensions"] -. uses .-> npm |
| 20 | +``` |
| 21 | + |
| 22 | +## Packages |
| 23 | + |
| 24 | +### diracx-web-components |
| 25 | + |
| 26 | +The shared component library, published to npm as `@dirac-grid/diracx-web-components`. It provides: |
| 27 | + |
| 28 | +- **UI components** — Reusable React components built with [Material UI (MUI)](https://mui.com/) |
| 29 | +- **Contexts** — React context providers for state management (authentication, application list, theme) |
| 30 | +- **Hooks** — Custom React hooks encapsulating reusable logic |
| 31 | +- **Types** — TypeScript type definitions |
| 32 | + |
| 33 | +Built with [tsup](https://tsup.egoist.dev/) for fast TypeScript compilation. Outputs to `dist/` with ESM and type declarations. Documented with [Storybook](https://storybook.js.org/), published at [diracgrid.github.io/diracx-web](https://diracgrid.github.io/diracx-web/). Tested with [Jest](https://jestjs.io/) + [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/). |
| 34 | + |
| 35 | +### diracx-web |
| 36 | + |
| 37 | +The vanilla DiracX web interface: |
| 38 | + |
| 39 | +- **Framework**: [Next.js 15](https://nextjs.org/) with App Router |
| 40 | +- **Output**: Static export (`output: "export"`) |
| 41 | +- **Authentication**: [@axa-fr/react-oidc](https://github.com/AxaFrance/oidc-client) |
| 42 | +- **Testing**: [Cypress](https://www.cypress.io/) for end-to-end tests |
| 43 | +- **Serving**: Nginx in production (Docker image) |
| 44 | + |
| 45 | +### extensions (gubbins) |
| 46 | + |
| 47 | +Reference example of a custom DiracX web extension. Demonstrates how to extend the application list, add custom components, and deploy as a standalone project. Same Next.js setup as `diracx-web`. |
| 48 | + |
| 49 | +## Key directories |
| 50 | + |
| 51 | +| Path | Description | |
| 52 | +|---|---| |
| 53 | +| `packages/diracx-web-components/src/components/` | Reusable UI components | |
| 54 | +| `packages/diracx-web-components/src/contexts/` | React contexts for state management | |
| 55 | +| `packages/diracx-web-components/src/hooks/` | Custom React hooks | |
| 56 | +| `packages/diracx-web-components/src/types/` | TypeScript type definitions | |
| 57 | +| `packages/diracx-web/src/app/` | Next.js App Router pages and layouts | |
| 58 | +| `packages/extensions/src/` | Extension source (gubbins example) | |
| 59 | + |
| 60 | +## Build pipeline |
| 61 | + |
| 62 | +- **Component library**: `tsup` compiles TypeScript to `dist/` with ESM and type declarations. |
| 63 | +- **Next.js app**: `next build` exports static HTML/JS/CSS via `output: "export"`. |
| 64 | +- **Development**: `npm run dev` starts Next.js in dev mode. The `transpilePackages` config in `next.config.js` allows Next.js to watch and rebuild changes in `diracx-web-components` source directly — no manual rebuild needed. |
| 65 | +- **Production / extensions**: Components are consumed from the published `@dirac-grid/diracx-web-components` npm package. |
| 66 | + |
| 67 | +## Routing |
| 68 | + |
| 69 | +DiracX Web uses [Next.js folder-based routing](https://nextjs.org/docs/app/building-your-application/routing): |
| 70 | + |
| 71 | +- `src/app/(dashboard)/` — Main dashboard (parentheses are ignored in the route, so this is the root URL). |
| 72 | +- `src/app/auth/` — Authentication pages, served at `/auth`. |
| 73 | +- `page.tsx` files define the UI for a route. |
| 74 | +- `layout.tsx` files define shared UI for a segment and its children. |
| 75 | + |
| 76 | +## State management |
| 77 | + |
| 78 | +- **Application state**: Managed via React Context (`ApplicationProvider`). |
| 79 | +- **Session storage**: Each application instance writes its state to `<appId>_State` for share/import functionality. |
| 80 | +- **URL encoding**: Dashboard layout is encoded in the URL for sharing. |
| 81 | + |
| 82 | +## Design system |
| 83 | + |
| 84 | +DiracX Web uses [Material UI (MUI)](https://mui.com/) as its design system. Components should follow MUI patterns and use the MUI theme for consistent styling. |
0 commit comments