|
| 1 | +# Web Architecture |
| 2 | + |
| 3 | +## Monorepo Structure |
| 4 | + |
| 5 | +The DiracX-Web repository 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. |
| 6 | + |
| 7 | +```mermaid |
| 8 | +--- |
| 9 | +config: |
| 10 | + layout: elk |
| 11 | +--- |
| 12 | +flowchart TD |
| 13 | + subgraph monorepo["Monorepo"] |
| 14 | + components["diracx-web-components"] |
| 15 | + web["diracx-web"] |
| 16 | + extensions["extensions (gubbins)"] |
| 17 | + end |
| 18 | + web -. uses .-> components |
| 19 | + extensions -. uses .-> components |
| 20 | + components -- published on --> npm["npm registry"] |
| 21 | + community["Community extensions"] -. uses .-> npm |
| 22 | +``` |
| 23 | + |
| 24 | +## Packages |
| 25 | + |
| 26 | +### diracx-web-components |
| 27 | + |
| 28 | +- **Purpose**: Reusable React component library. |
| 29 | +- **Build tool**: [tsup](https://tsup.egoist.dev/) for TypeScript compilation. |
| 30 | +- **Design system**: [Material-UI (MUI)](https://mui.com/). |
| 31 | +- **Documentation**: [Storybook](https://storybook.js.org/). |
| 32 | +- **Testing**: [Jest](https://jestjs.io/) + [React Testing Library](https://testing-library.com/docs/react-testing-library/intro/). |
| 33 | +- **Exports**: Components, contexts, hooks, and types as separate modules. |
| 34 | + |
| 35 | +### diracx-web |
| 36 | + |
| 37 | +- **Purpose**: Vanilla DiracX web interface. |
| 38 | +- **Framework**: [Next.js 15](https://nextjs.org/) with App Router. |
| 39 | +- **Output**: Static export (`output: "export"`). |
| 40 | +- **Authentication**: [@axa-fr/react-oidc](https://github.com/AxaFrance/oidc-client). |
| 41 | +- **Testing**: [Cypress](https://www.cypress.io/) for end-to-end tests. |
| 42 | +- **Serving**: Nginx in production (Docker image). |
| 43 | + |
| 44 | +### extensions (gubbins) |
| 45 | + |
| 46 | +- **Purpose**: Reference example of a custom DiracX web extension. |
| 47 | +- **Framework**: Next.js, same setup as `diracx-web`. |
| 48 | +- **Demonstrates**: How to extend the application list, add custom components, and deploy as a standalone project. |
| 49 | + |
| 50 | +## Key Directories |
| 51 | + |
| 52 | +| Path | Description | |
| 53 | +|---|---| |
| 54 | +| `packages/diracx-web-components/src/components/` | Reusable UI components | |
| 55 | +| `packages/diracx-web-components/src/contexts/` | React contexts for state management | |
| 56 | +| `packages/diracx-web-components/src/hooks/` | Custom React hooks | |
| 57 | +| `packages/diracx-web-components/src/types/` | TypeScript type definitions | |
| 58 | +| `packages/diracx-web/src/app/` | Next.js App Router pages and layouts | |
| 59 | +| `packages/extensions/src/` | Extension source (gubbins example) | |
| 60 | + |
| 61 | +## Routing |
| 62 | + |
| 63 | +DiracX-Web uses [Next.js folder-based routing](https://nextjs.org/docs/app/building-your-application/routing): |
| 64 | + |
| 65 | +- `src/app/(dashboard)/` — Main dashboard (parentheses are ignored in the route, so this is the root URL). |
| 66 | +- `src/app/auth/` — Authentication pages, served at `/auth`. |
| 67 | +- `page.tsx` files define the UI for a route. |
| 68 | +- `layout.tsx` files define shared UI for a segment and its children. |
| 69 | + |
| 70 | +## State Management |
| 71 | + |
| 72 | +- **Application state**: Managed via React Context (`ApplicationProvider`). |
| 73 | +- **Session storage**: Each application instance writes its state to `<appId>_State` for share/import functionality. |
| 74 | +- **URL encoding**: Dashboard layout is encoded in the URL for sharing. |
0 commit comments