Did you know that GitHub supports table of contents by default 🤔
This is the API for search service in InNoHassle ecosystem.
- WIP
- Python 3.12 & Poetry
- FastAPI & Pydantic
- Database and ORM: MongoDB, Beanie
- Formatting and linting: Ruff, pre-commit
- Deployment: Docker, Docker Compose, GitHub Actions
-
Install Python 3.12
-
Install Poetry
-
Install project dependencies with Poetry.
poetry install
-
Set up pre-commit hooks:
poetry run pre-commit install --install-hooks -t pre-commit -t commit-msg
-
Set up project settings file (check settings.schema.yaml for more info).
cp settings.example.yaml settings.yaml
Edit
settings.yaml
according to your needs. -
Set up a MongoDB database instance.
Using docker container
-
Set up database settings for docker-compose container in
.env
file:хcp .env.example .env
-
Run the database instance:
docker compose up -d db
-
Make sure to set up the actual database connection in
settings.yaml
.
-
Set up PyCharm integrations
- Ruff (plugin).
It will lint and format your code.
Make sure to enable
Use ruff format
option in plugin settings. - Pydantic (plugin). It will fix PyCharm issues with type-hinting.
- Conventional commits (plugin). It will help you to write conventional commits.
-
Install dependencies for api if needed:
poetry install --with api
-
Run the database if you have not done it yet
-
Run the ASGI server
poetry run python -m src.api
OR using uvicorn directly
poetry run uvicorn src.api.app:app --use-colors --proxy-headers --forwarded-allow-ips=* --port=8001
Now the API is running on http://localhost:8001. Good job!
We use our own IAM service for
authentication - InNoHassle Accounts.
To authenticate the user, you need to pass the Authorization
header with the Bearer: <jwt_token>
.
How to get token:
- First of all, go to innohassle.ru and log in if you are not logged in (or register). That will add cookie with account secret needed for the next step.
- Go to Accounts API and execute the
the method
GET /tokens/generate-my-token
, copy the token from the response. - Go to the Swagger of API you want to authenticate and click on the
Authorize
button in the top right corner, paste the token in theValue
field and clickAuthorize
. Now you can use protected endpoints from the Swagger.
We use Docker with Docker Compose plugin to run the website on servers.
- Copy the file with environment variables:
cp .env.example .env
- Change environment variables in the
.env
file - Copy the file with settings:
cp settings.example.yaml settings.yaml
- Change settings in the
settings.yaml
file according to your needs (check settings.schema.yaml for more info) - Install Docker with Docker Compose
- Build a Docker image:
docker compose build --pull
- Run the container:
docker compose up --detach
- Check the logs:
docker compose logs -f
We are open to contributions of any kind. You can help us with code, bugs, design, documentation, media, new ideas, etc. If you are interested in contributing, please read our contribution guide.