-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from fbraem/feature/c
FastAPI frontend release
- Loading branch information
Showing
565 changed files
with
20,978 additions
and
19,488 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,18 +17,18 @@ jobs: | |
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.10"] | ||
python-version: ["3.12"] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/checkout@v4 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install Poetry | ||
run: pip install poetry | ||
- name: Install dependencies | ||
working-directory: backend/src | ||
run: poetry install | ||
working-directory: backend | ||
run: poetry install --with dev,docs | ||
- name: Start MySQL | ||
run: | | ||
sudo systemctl enable mysql.service | ||
|
@@ -48,6 +48,32 @@ jobs: | |
KWAI_EMAIL_PASSWORD: ${{ secrets.KWAI_EMAIL_PASSWORD }} | ||
run: | | ||
cat <<EOF > .kwai.toml | ||
[frontend] | ||
test = true | ||
path = "" | ||
root_app = "portal" | ||
[frontend.apps.portal] | ||
base="/apps/portal" | ||
base_dev="http://localhost:3000" | ||
entries="/src/index.ts" | ||
[frontend.apps.author] | ||
base="/apps/author" | ||
base_dev="http://localhost:3001" | ||
entries="/src/index.ts" | ||
[frontend.apps.auth] | ||
base="/apps/auth" | ||
base_dev="http://localhost:3002" | ||
entries="/src/index.ts" | ||
[frontend.apps.coach] | ||
base="/apps/coach" | ||
base_dev="http://localhost:3003" | ||
entries="/src/index.ts" | ||
[frontend.apps.club] | ||
base="/apps/club" | ||
base_dev="http://localhost:3004" | ||
entries="/src/index.ts" | ||
[files] | ||
path = "/var/tmp/kwai" | ||
[security] | ||
jwt_secret="$KWAI_JWT_SECRET" | ||
jwt_refresh_secret="$KWAI_JWT_SECRET" | ||
|
@@ -87,18 +113,18 @@ jobs: | |
DBMATE_WAIT_TIMEOUT: "30s" | ||
run: ./dbmate up | ||
- name: Test with pytest | ||
working-directory: backend/src | ||
working-directory: backend | ||
env: | ||
KWAI_SETTINGS_FILE: ${{github.workspace}}/.kwai.toml | ||
run: poetry run pytest --cov=kwai --cov-report html | ||
- name: Generate coverage badge | ||
working-directory: backend/src | ||
working-directory: backend | ||
run: poetry run coverage-badge -o ./htmlcov/coverage.svg | ||
- name: Remove .gitignore from coverage report | ||
run: rm backend/src/htmlcov/.gitignore | ||
run: rm backend/htmlcov/.gitignore | ||
- name: Deploy coverage to github pages | ||
uses: JamesIves/[email protected] | ||
with: | ||
branch: gh-pages | ||
target-folder: coverage | ||
folder: backend/src/htmlcov | ||
folder: backend/htmlcov |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Mirror to Codeberg | ||
|
||
on: | ||
push: | ||
branches: ["**"] | ||
tags: ["**"] | ||
release: | ||
types: ["published"] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
mirror: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: "Checkout" | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: "Mirror to codeberg" | ||
uses: cssnr/mirror-repository-action@master | ||
with: | ||
host: https://codeberg.org | ||
owner: zumuta | ||
repo: kwai | ||
username: ${{ secrets.CODEBERG_USER }} | ||
password: ${{ secrets.CODEBERG_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
version: '3' | ||
|
||
tasks: | ||
# build documentation | ||
build_doc: | ||
desc: Build the documentation | ||
dir: backend | ||
cmds: | ||
- poetry run mkdocs build -f ../mkdocs.yml | ||
|
||
serve_doc: | ||
desc: Build the documentation and run the webserver | ||
dir: backend | ||
cmds: | ||
- poetry run mkdocs serve -f ../mkdocs.yml | ||
|
||
includes: | ||
frontend: | ||
taskfile: ./frontend/Taskfile.yml | ||
dir: ./frontend |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,57 @@ | ||
# Auth API's | ||
## ::: kwai.api.v1.auth.endpoints.login | ||
selection: | ||
members: no | ||
|
||
### ::: kwai.api.v1.auth.endpoints.login.login | ||
### ::: kwai.api.v1.auth.endpoints.login.logout | ||
### ::: kwai.api.v1.auth.endpoints.login.recover_user | ||
### ::: kwai.api.v1.auth.endpoints.login.renew_access_token | ||
### ::: kwai.api.v1.auth.endpoints.login.reset_password | ||
All API's used for authentication, authorization, users, ... | ||
|
||
# Auth Responses | ||
## /api/v1/auth | ||
|
||
### ::: kwai.api.v1.auth.endpoints.login.TokenSchema | ||
### Requests | ||
|
||
::: kwai.api.v1.auth.endpoints.login.renew_access_token | ||
options: | ||
heading_level: 4 | ||
|
||
::: kwai.api.v1.auth.endpoints.login.login | ||
options: | ||
heading_level: 4 | ||
|
||
::: kwai.api.v1.auth.endpoints.login.logout | ||
options: | ||
heading_level: 4 | ||
|
||
::: kwai.api.v1.auth.endpoints.login.recover_user | ||
options: | ||
heading_level: 4 | ||
|
||
::: kwai.api.v1.auth.endpoints.login.reset_password | ||
options: | ||
heading_level: 4 | ||
|
||
::: kwai.api.v1.auth.endpoints.user.get | ||
options: | ||
heading_level: 4 | ||
|
||
### Responses | ||
|
||
#### ::: kwai.api.v1.auth.endpoints.login.TokenSchema | ||
options: | ||
show_root_toc_entry: false | ||
|
||
## /api/v1/auth/users | ||
|
||
### Requests | ||
|
||
::: kwai.api.v1.auth.endpoints.user_invitations.create_user_invitation | ||
options: | ||
heading_level: 4 | ||
|
||
::: kwai.api.v1.auth.endpoints.user_invitations.delete_user_invitation | ||
options: | ||
heading_level: 4 | ||
|
||
::: kwai.api.v1.auth.endpoints.user_invitations.get_user_invitations | ||
options: | ||
heading_level: 4 | ||
|
||
::: kwai.api.v1.auth.endpoints.user_invitations.get_user_invitation | ||
options: | ||
heading_level: 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# API | ||
|
||
## [Authentication](./api_auth.md) | ||
|
||
All API's related to authentication. | ||
|
||
!!! Note | ||
|
||
Use [swagger](https://swagger.io/) UI from [FastAPI](https://fastapi.tiangolo.com) to get a list of | ||
all available api's. | ||
|
||
When the Kwai api backend is running in test mode, point your browser | ||
to `http://localhost:<port>/api/docs`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Architecture | ||
============ | ||
|
||
Kwai tries to follow the [clean architecture](http://cleancoder.com) principles. The [frontend]() is already a | ||
separated layer. The backend code is using the domain driven design (DDD) for modeling the software. | ||
|
||
One of the rules of clean architecture is that when you don't own or control something, then keep it on the | ||
outside of your design or wrap it. This means for example, that the domain code isn't allowed to contain FastAPI code | ||
or database related code. The code for the API is on the outside because it's the entry point of a call to the system. | ||
Presenters are used to transform domain objects into JSON:API documents. The repository pattern keeps the | ||
database code on the outside. And interfaces are used to protect the inside from the outside. | ||
|
||
The [pendulum](https://pendulum.eustace.io/) library is used for processing dates and timestamps. Because kwai doesn't | ||
own this code, the pendulum code is wrapped into value objects (Timestamp, Date, ...). If the pendulum package is | ||
outdated, we only need to change these value objects. | ||
|
||
> This is also the reason why [Pydantic](https://docs.pydantic.dev/latest/) isn't used for entities or value objects. | ||
> Pydantic is great for validation and serialization, but we don't want Pydantic to become a dependency of the kwai | ||
> domain. | ||
Dependency injection containers are only used on the outside. There should not be any magic code in the domain. | ||
So, dependency injection containers can only be used in the API entry code, the CLI entry code, ... From there on, | ||
the dependency should be passed as an argument (and passing it down should be done using an interface). | ||
|
||
Actors | ||
====== | ||
|
||
Who are the actors in our application? | ||
|
||
Visitor | ||
------- | ||
|
||
A visitor is a person that visits our website. He/She does not have any permissions and is | ||
not known in the system. | ||
|
||
Member | ||
------ | ||
|
||
A member is a person that is a member of the club. | ||
|
||
Coach | ||
----- | ||
|
||
A coach is a member of the club. A coach can create/view/update/delete trainings. A coach can also registers | ||
participants for a training. When participants are registered, a training can't be deleted anymore. | ||
|
||
````mermaid | ||
sequenceDiagram | ||
actor Coach | ||
Coach->>Trainings: View | ||
Coach->>Trainings: Create | ||
Coach->>Trainings: Update | ||
Coach->>Trainings: Delete | ||
Coach->>Trainings: Register participants | ||
```` | ||
|
||
Admin | ||
----- | ||
|
||
An administrator is a person that manages the website. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,28 @@ | ||
# Command Line Interface | ||
A command line interface (CLI) is provided to help managing the kwai system. To run the cli, use the kwai_cli.py | ||
A command line interface (CLI) is provided to help managing the kwai system. To run the cli, use the kwai_cli.py | ||
script: | ||
|
||
`kwai_cli.py --help` | ||
|
||
::: kwai.cli.bus | ||
::: kwai.cli.commands.bus | ||
options: | ||
show_root_full_path: False | ||
show_signature: False | ||
members: | ||
- show | ||
- test | ||
|
||
::: kwai.cli.db | ||
::: kwai.cli.commands.db | ||
options: | ||
show_root_full_path: False | ||
show_signature: False | ||
members: | ||
- show | ||
- test | ||
|
||
::: kwai.cli.identity | ||
::: kwai.cli.commands.identity | ||
options: | ||
show_root_full_path: False | ||
show_signature: False | ||
members: | ||
- create | ||
|
Oops, something went wrong.