|
| 1 | +# Keip Canvas UI Overview |
| 2 | + |
| 3 | +The UI is built around a canvas that allows you to drag, drop, and |
| 4 | +connect [EIP](https://www.enterpriseintegrationpatterns.com/patterns/messaging/) nodes to create integration flows. |
| 5 | +In addition to being a design and documentation tool, the UI allows you to configure the behavior of the individual EIP |
| 6 | +nodes, thus providing the ability to generate deployable integration flow artifacts (e.g. XML). |
| 7 | + |
| 8 | +## Requirements |
| 9 | + |
| 10 | +For local development, the following must be installed: |
| 11 | + |
| 12 | +- Node.js v20 |
| 13 | +- npm v10 (other package managers should work as well) |
| 14 | + |
| 15 | +[Volta](https://volta.sh/) is recommended for setting up your JS environment. |
| 16 | + |
| 17 | +### Run the dev server |
| 18 | + |
| 19 | +Clone the repository: |
| 20 | + |
| 21 | +```shell |
| 22 | +git clone https://github.com/OctoConsulting/keip-canvas.git && cd keip-canvas/ui |
| 23 | +``` |
| 24 | + |
| 25 | +Install dependencies: |
| 26 | + |
| 27 | +```shell |
| 28 | +npm install |
| 29 | +``` |
| 30 | + |
| 31 | +Run the development web server: |
| 32 | + |
| 33 | +```shell |
| 34 | +npm run dev |
| 35 | +``` |
| 36 | + |
| 37 | +## Dependencies |
| 38 | + |
| 39 | +The UI is mostly written in Typescript and relies heavily on the following libraries: |
| 40 | + |
| 41 | +- [React](https://react.dev/): main UI library |
| 42 | +- [React Flow](https://reactflow.dev/): powers the interactive flow canvas |
| 43 | +- [Zustand](https://github.com/pmndrs/zustand): state-management |
| 44 | +- [Carbon Design System](https://carbondesignsystem.com/): React component library |
| 45 | +- [Vite](https://vite.dev/): build tooling |
| 46 | + |
| 47 | +## Structure |
| 48 | + |
| 49 | +The source code is spread across multiple modules, some important ones are highlighted below: |
| 50 | + |
| 51 | +### api |
| 52 | + |
| 53 | +Defines the types and interfaces used across the UI components. Notably, the `api/generated` subdirectory contains |
| 54 | +code generated from the [EIP Json schemas](../schemas/README.md). To use updated source schemas, |
| 55 | +the [code-generation script](./genApiFromSchema.js) must be updated to point to the desired schema versions. |
| 56 | +The API files can then be generated by running `npm run codegen`. |
| 57 | +In this specific case, the generated files should be checked into version control to avoid the need to constantly |
| 58 | +rebuild them. |
| 59 | + |
| 60 | +### assets |
| 61 | + |
| 62 | +Holds static assets such as the EIP icon SVGs. |
| 63 | + |
| 64 | +### components |
| 65 | + |
| 66 | +Contains all the UI's React components. Developers will likely spend the majority of their time working in here. |
| 67 | + |
| 68 | +### json |
| 69 | + |
| 70 | +Stores the [EIP Component Definition](../schemas/model/json/eipComponentDef.schema.json) JSON, which populates the |
| 71 | +catalog of EIP nodes that a user is able to drag and drop onto the canvas. |
| 72 | + |
| 73 | +### singletons |
| 74 | + |
| 75 | +Initializes singleton instances that are required across the application, most notable is the `store` module. |
| 76 | +The `store` module manages the React application's global state, through the use of a Zustand store. |
| 77 | +The module does not provide direct access to the app store, rather several use-case/event specific custom hooks are |
| 78 | +exported for use by components. This helps us keep stateful business logic encapsulated inside the store. |
| 79 | + |
| 80 | +## Formatting and Linting |
| 81 | + |
| 82 | +Formatting and linting is handled by [Prettier](https://prettier.io/) and [ESLint](https://eslint.org/) respectively. |
| 83 | + |
| 84 | +Formatting commands: |
| 85 | + |
| 86 | +```shell |
| 87 | +# check only |
| 88 | +npm run check-format |
| 89 | + |
| 90 | +# apply formatting |
| 91 | +npm run format |
| 92 | +``` |
| 93 | + |
| 94 | +Run linter: |
| 95 | + |
| 96 | +```shell |
| 97 | +npm run lint |
| 98 | +``` |
| 99 | + |
| 100 | +Rules are configured in: |
| 101 | + |
| 102 | +- Prettier: [.prettierrc.json](./.prettierrc.json) |
| 103 | +- ESLint: [.eslintrc.cjs](./.eslintrc.cjs) |
| 104 | + |
| 105 | +Consult your IDE's documentation on how to integrate these rules. |
0 commit comments