You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-14Lines changed: 26 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,10 +40,8 @@ Also, includes a Render.com `render.yaml` and a working Django `production.py` s
40
40
- State management and backend integration
41
41
-`axios` for performing asynchronous calls
42
42
-`cookie` for easy integration with Django using the `csrftoken` cookie
43
-
-`@reduxjs/toolkit` for easy state management across the application with the whole toolkit including devtools for inspecting and debugging Redux via browser and ability to run thunks for interacting with the Redux store through asynchronous logic
44
-
-`connected-react-router` for integrating Redux with React Router
43
+
-`openapi-ts` for generating TypeScript client API code from the backend OpenAPI schema
45
44
-`history` for providing browser history to Connected React Router
46
-
-`react-redux` for integrating React with Redux
47
45
- Utilities
48
46
-`lodash` for general utility functions
49
47
-`classnames` for easy working with complex CSS class names on components
@@ -143,13 +141,6 @@ After completing ALL of the above, remove this `Project bootstrap` section from
143
141
144
142
### If you are not using Docker:
145
143
146
-
#### Setup and run the frontend app
147
-
148
-
- Open a new command line window and go to the project's directory
149
-
- `npm install`
150
-
- `npm run dev`
151
-
- This is used to serve the frontend assets to be consumed by [django-webpack-loader](https://github.com/django-webpack/django-webpack-loader) and not to run the React application as usual, so don't worry if you try to check what's running on port 3000 and see an error on your browser
152
-
153
144
#### Setup the backend app
154
145
155
146
- Open the `backend/.env` file on a text editor and do one of the following:
@@ -169,9 +160,18 @@ After completing ALL of the above, remove this `Project bootstrap` section from
169
160
- Run the migrations:
170
161
`poetry run python manage.py migrate`
171
162
- Generate the OpenAPI schema:
172
-
`poetry run python manage.py spectacular --color --file schema.yml`
163
+
`poetry run python manage.py spectacular --color --file schema.yml`
173
164
- Run the project:
174
165
`poetry run python manage.py runserver`
166
+
167
+
#### Setup and run the frontend app
168
+
169
+
- Open a new command line window and go to the project's directory
170
+
- `npm install`
171
+
- `npm run openapi-ts`
172
+
- This is used to generate the TypeScript client API code from the backend OpenAPI schema
173
+
- `npm run dev`
174
+
- This is used to serve the frontend assets to be consumed by [django-webpack-loader](https://github.com/django-webpack/django-webpack-loader) and not to run the React application as usual, so don't worry if you try to check what's running on port 3000 and see an error on your browser
175
175
- Open a browser and go to `http://localhost:8000` to see the project running
176
176
177
177
#### Setup Celery
@@ -204,19 +204,31 @@ Will run django tests using `--keepdb` and `--parallel`. You may pass a path to
204
204
205
205
To add a new **backend** dependency, run `poetry add {dependency}`. If the dependency should be only available for development user append `-G dev` to the command.
206
206
207
-
### API Schema
207
+
### API Schema and Client generation
208
208
209
-
We use the DRF-Spectacular tool to generate an OpenAPI schema from our Django Rest Framework API. The OpenAPI schema serves as the backbone for generating client code, creating comprehensive API documentation, and more.
209
+
We use the [`DRF-Spectacular`](https://drf-spectacular.readthedocs.io/en/latest/readme.html) tool to generate an OpenAPI schema from our Django Rest Framework API. The OpenAPI schema serves as the backbone for generating client code, creating comprehensive API documentation, and more.
210
210
211
211
The API documentation pages are accessible at `http://localhost:8000/api/schema/swagger-ui/` or `http://localhost:8000/api/schema/redoc/`.
212
212
213
213
> [!IMPORTANT]
214
214
> Anytime a view is created, updated, or removed, the schema must be updated to reflect the changes. Failing to do so can lead to outdated client code or documentation.
215
-
>
215
+
>
216
216
> To update the schema, run:
217
217
> - If you are using Docker: `make docker_backend_update_schema`
218
218
> - If you are not using Docker: `poetry run python manage.py spectacular --color --file schema.yml`
219
219
220
+
We use the [`openapi-ts`](https://heyapi.vercel.app/openapi-ts/get-started.html) tool to generate TypeScript client code from the OpenAPI schema. The generated client code is used to interact with the API in a type-safe manner.
221
+
222
+
> [!IMPORTANT]
223
+
> Anytime the API schema is updated, the client code must be regenerated to reflect the changes. Failing to do so can lead to type errors in the client code.
224
+
>
225
+
> To update the client code, run:
226
+
> - If you are using Docker: `make docker_frontend_update_api`
227
+
> - If you are not using Docker: `npm run openapi-ts`
228
+
229
+
> [!NOTE]
230
+
> If `pre-commit` is properly enabled, it will automatically update both schema and client before each commit whenever necessary.
231
+
220
232
## Github Actions
221
233
222
234
To enable Continuous Integration through Github Actions, we provide a `proj_main.yml` file. To connect it to Github you need to rename it to `main.yml` and move it to the `.github/workflows/` directory.
0 commit comments