Did you know that GitHub supports table of contents by default 🤔
This is an API for the search service in the InNoHassle ecosystem. The search should be carried out on services relevant to Innopolis University students (moodle, EduWiki, Campus Life, etc.). The search expects to use AI to accept free-form queries from users in addition to just service keywords.
- Python 3.11 & Poetry
- FastAPI & Pydantic
- Database and ORM: MongoDB, Beanie
- Formatting and linting: Ruff, pre-commit
- Deployment: Docker, Docker Compose, GitHub Actions
-
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 database settings for docker-compose container in
.env
file:хcp .env.example .env
-
Start all services:
docker compose up
Now you can find API docs on http://localhost:8004/docs. Good job!
-
Install Python 3.11
-
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
-
Check that your
settings.yaml
looks like:$schema: "./settings.schema.yaml" api_settings: db_url: "mongodb://mongoadmin:secret@localhost:27017/db?authSource=admin" minio: access_key: "minioadmin" secret_key: "password"
-
Set up a MongoDB and Minio instances.
- Set up database settings for docker-compose container
in
.env
file:хcp .env.example .env
- Run the database instance:
docker compose up -d db minio
- Make sure to set up the actual database connection in
settings.yaml
.
- Set up database settings for docker-compose container
in
-
Choose the way to run models: either use Infinity or local models.
- If you want to use local models, just not set
infinity_url
insettings.yaml
- If you want to use Infinity, set
infinity_url
insettings.yaml
to the url of deployed Infinity engine. You can run Infinity engine locally:Or use deployed Infinity engine provided by someone else.uv run --no-project --with "infinity_emb[all]" --with "transformers<4.49" infinity_emb v2 --model-id jinaai/jina-embeddings-v3 --model-id jinaai/jina-reranker-v2-base-multilingual
- If you want to use local models, just not set
-
Run ml client
poetry run python -m src.ml_service
-
Run the ASGI server
poetry run python -m src.api
Check API docs on http://127.0.0.1:8001/docs
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.
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 co 8761 okie 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.
For testing we use pytest
.
- To run tests enter in your terminal:
poetry run pytest tests
- To generate test coverage report run:
You can change coverage ignored folders/files in
poetry run pytest --cov-config=.coveragerc --cov=src/ tests/
.coveragerc
.
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.