|
1 | 1 | # InvokeAI Web UI |
2 | 2 |
|
| 3 | +<!-- @import "[TOC]" {cmd="toc" depthFrom=1 depthTo=6 orderedList=false} --> |
| 4 | + |
| 5 | +<!-- code_chunk_output --> |
| 6 | + |
3 | 7 | - [InvokeAI Web UI](#invokeai-web-ui) |
4 | | - - [Stack](#stack) |
| 8 | + - [Core Libraries](#core-libraries) |
| 9 | + - [Redux Toolkit](#redux-toolkit) |
| 10 | + - [Socket\.IO](#socketio) |
| 11 | + - [Chakra UI](#chakra-ui) |
| 12 | + - [KonvaJS](#konvajs) |
| 13 | + - [Vite](#vite) |
| 14 | + - [i18next & Weblate](#i18next--weblate) |
| 15 | + - [openapi-typescript](#openapi-typescript) |
| 16 | + - [Client Types Generation](#client-types-generation) |
| 17 | + - [Package Scripts](#package-scripts) |
5 | 18 | - [Contributing](#contributing) |
6 | 19 | - [Dev Environment](#dev-environment) |
| 20 | + - [VSCode Remote Dev](#vscode-remote-dev) |
7 | 21 | - [Production builds](#production-builds) |
8 | 22 |
|
9 | | -The UI is a fairly straightforward Typescript React app. The only really fancy stuff is the Unified Canvas. |
| 23 | +<!-- /code_chunk_output --> |
| 24 | + |
| 25 | +The UI is a fairly straightforward Typescript React app. |
| 26 | + |
| 27 | +## Core Libraries |
| 28 | + |
| 29 | +The app makes heavy use of a handful of libraries. |
| 30 | + |
| 31 | +### Redux Toolkit |
| 32 | + |
| 33 | +[Redux Toolkit](https://github.com/reduxjs/redux-toolkit) is used for state management and fetching/caching: |
| 34 | + |
| 35 | +- `RTK-Query` for data fetching and caching |
| 36 | +- `createAsyncThunk` for a couple other HTTP requests |
| 37 | +- `createEntityAdapter` to normalize things like images and models |
| 38 | +- `createListenerMiddleware` for async workflows |
| 39 | + |
| 40 | +We use [redux-remember](https://github.com/zewish/redux-remember) for persistence. |
| 41 | + |
| 42 | +### Socket\.IO |
| 43 | + |
| 44 | +[Socket\.IO](https://github.com/socketio/socket.io) is used for server-to-client events, like generation process and queue state changes. |
| 45 | + |
| 46 | +### Chakra UI |
| 47 | + |
| 48 | +[Chakra UI](https://github.com/chakra-ui/chakra-ui) is our primary UI library, but we also use a few components from [Mantine v6](https://v6.mantine.dev/). |
| 49 | + |
| 50 | +### KonvaJS |
| 51 | + |
| 52 | +[KonvaJS](https://github.com/konvajs/react-konva) powers the canvas. In the future, we'd like to explore [PixiJS](https://github.com/pixijs/pixijs) or WebGPU. |
| 53 | + |
| 54 | +### Vite |
| 55 | + |
| 56 | +[Vite](https://github.com/vitejs/vite) is our bundler. |
| 57 | + |
| 58 | +### i18next & Weblate |
| 59 | + |
| 60 | +We use [i18next](https://github.com/i18next/react-i18next) for localisation, but translation to languages other than English happens on our [Weblate](https://hosted.weblate.org/engage/invokeai/) project. **Only the English source strings should be changed on this repo.** |
| 61 | + |
| 62 | +### openapi-typescript |
| 63 | + |
| 64 | +[openapi-typescript](https://github.com/drwpow/openapi-typescript) is used to generate types from the server's OpenAPI schema. See TYPES_CODEGEN.md. |
10 | 65 |
|
11 | | -Code in `invokeai/frontend/web/` if you want to have a look. |
| 66 | +## Client Types Generation |
12 | 67 |
|
13 | | -## Stack |
| 68 | +We use [`openapi-typescript`](https://github.com/drwpow/openapi-typescript) to generate types from the app's OpenAPI schema. |
14 | 69 |
|
15 | | -State management is Redux via [Redux Toolkit](https://github.com/reduxjs/redux-toolkit). We lean heavily on RTK: |
16 | | -- `createAsyncThunk` for HTTP requests |
17 | | -- `createEntityAdapter` for fetching images and models |
18 | | -- `createListenerMiddleware` for workflows |
| 70 | +The generated types are written to `invokeai/frontend/web/src/services/api/schema.d.ts`. This file is committed to the repo. |
19 | 71 |
|
20 | | -The API client and associated types are generated from the OpenAPI schema. See API_CLIENT.md. |
| 72 | +The server must be started and available at <http://127.0.0.1:9090>. |
21 | 73 |
|
22 | | -Communication with server is a mix of HTTP and [socket.io](https://github.com/socketio/socket.io-client) (with a simple socket.io redux middleware to help). |
| 74 | +```sh |
| 75 | +# from the repo root, start the server |
| 76 | +python scripts/invokeai-web.py |
| 77 | +# from invokeai/frontend/web/, run the script |
| 78 | +yarn typegen |
| 79 | +``` |
23 | 80 |
|
24 | | -[Chakra-UI](https://github.com/chakra-ui/chakra-ui) for components and styling. |
| 81 | +## Package Scripts |
25 | 82 |
|
26 | | -[Konva](https://github.com/konvajs/react-konva) for the canvas, but we are pushing the limits of what is feasible with it (and HTML canvas in general). We plan to rebuild it with [PixiJS](https://github.com/pixijs/pixijs) to take advantage of WebGL's improved raster handling. |
| 83 | +See `package.json` for all scripts. |
27 | 84 |
|
28 | | -[Vite](https://vitejs.dev/) for bundling. |
| 85 | +Run with `yarn <script name>`. |
29 | 86 |
|
30 | | -Localisation is via [i18next](https://github.com/i18next/react-i18next), but translation happens on our [Weblate](https://hosted.weblate.org/engage/invokeai/) project. Only the English source strings should be changed on this repo. |
| 87 | +- `dev`: run the frontend in dev mode, enabling hot reloading |
| 88 | +- `build`: run all checks (madge, eslint, prettier, tsc) and then build the frontend |
| 89 | +- `typegen`: generate types from the OpenAPI schema (see [Client Types Generation](#client-types-generation)) |
| 90 | +- `lint:madge`: check frontend for circular dependencies |
| 91 | +- `lint:eslint`: check frontend for code quality |
| 92 | +- `lint:prettier`: check frontend for code formatting |
| 93 | +- `lint:tsc`: check frontend for type issues |
| 94 | +- `lint`: run all checks concurrently |
| 95 | +- `fix`: run `eslint` and `prettier`, fixing fixable issues |
31 | 96 |
|
32 | 97 | ## Contributing |
33 | 98 |
|
|
0 commit comments