Monorepo for the glowjob project.
/
├── apps
│ ├── api # Spring boot api
│ └── web # React web app powered by vite
└── libs
├── ui # Common UI components, hooks and utils
├── theme # Centralized Chakra-UI theme for all components
└── openapi # OpenAPI schema for API and auto-generated client services and typescript models
The front-end http client is auto-generated from the API OpenAPI schema using openapi-codegen. The codegen is run in 3 different situations :
- Each time a
.java
file is modified and saved in theapi
app source code. - Each time the
web
app is build. - On demand with the
nx run openapi:generate
command.
This ensures that the client is always up to date with the API.
The output of the codegen is located in libs/openapi/src/generated
and the openapi specification is located in libs/openapi/src/openapi.yaml
.
Concretly, the codegen generates :
apiSchemas.ts
: all the typescript models synced on the request input and response data output of the api controllers.apiComponents.ts
:@tanstack/query
(previouslyreact-query
) hooks for each API endpoint their associated fetch functions for classic async/await calls.apiFetcher.ts
: thefetcher
function used by@tanstack/query
to make the actual http calls, which is completely customizable and won't be overwritten by the codegen.
In addition to classic nx
generators commands, the project have additionnal commands to help with development by generating different type of files:
pnpm g:web
: Generate files forapps/web
. It can generate following types of files dynamically:component
: Generate a component.page
: Generate a page.
pnpm g:ui
: Generate files forlibs/ui
. It can generate following types of files dynamically:component
: Generate a component with a storybook story.
- Node.js (>=20)
- Install Node dependencies
npm install --legacy-peer-deps
- Install
nx
globallynpm install -g nx
- Install Java dependencies
mvn -f apps/api/pom.xml dependency:resolve
Launch the Docker Compose stack used by the API
docker compose -f infra/docker/compose.yml up -d
mvn -f apps/api/pom.xml spring-boot:run
Be sure to launch the API before generating the definitions
mvn -f apps/api/pom.xml springdoc-openapi:generate
nx run web:dev
nx run web:build
nx run web:preview
nx run openapi:generate