8000 GitHub - one-zero-eight/search: InNoHassle Search API backend
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

one-zero-eight/search

Repository files navigation

InNoHassle Search

GitHub Actions pre-commit

Table of contents

Did you know that GitHub supports table of contents by default 🤔

About

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.

Technologies

Run with Docker

  1. 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.

  2. Set up database settings for docker-compose container in .env file:х

    cp .env.example .env
  3. Start all services:

    docker compose up

Now you can find API docs on http://localhost:8004/docs. Good job!

Development

Run locally [API]

  1. Install Python 3.11

  2. Install Poetry

  3. Install project dependencies with Poetry.

    poetry install
  4. Set up pre-commit hooks:

    poetry run pre-commit install --install-hooks -t pre-commit -t commit-msg
  5. 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"
  6. 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.
  7. Choose the way to run models: either use Infinity or local models.

    1. If you want to use local models, just not set infinity_url in settings.yaml
    2. If you want to use Infinity, set infinity_url in settings.yaml to the url of deployed Infinity engine. You can run Infinity engine locally:
      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
      Or use deployed Infinity engine provided by someone else.
  8. Run ml client

    poetry run python -m src.ml_service
  9. 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

  1. Ruff (plugin). It will lint and format your code. Make sure to enable Use ruff format option in plugin settings.
  2. Pydantic (plugin). It will fix PyCharm issues with type-hinting.
  3. Conventional commits (plugin). It will help you to write conventional commits.

Authentication

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:

  1. 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.
  2. Go to Accounts API and execute the the method GET /tokens/generate-my-token, copy the token from the response.
  3. 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 the Value field and click Authorize. Now you can use protected endpoints from the Swagger.

Testing

For testing we use pytest.

  • To run tests enter in your terminal:
    poetry run pytest tests
    
  • To generate test coverage report run:
    poetry run pytest  --cov-config=.coveragerc --cov=src/ tests/
    
    You can change coverage ignored folders/files in .coveragerc.

Deployment

We use Docker with Docker Compose plugin to run the website on servers.

  1. Copy the file with environment variables: cp .env.example .env
  2. Change environment variables in the .env file
  3. Copy the file with settings: cp settings.example.yaml settings.yaml
  4. Change settings in the settings.yaml file according to your needs (check settings.schema.yaml for more info)
  5. Install Docker with Docker Compose
  6. Build a Docker image: docker compose build --pull
  7. Run the container: docker compose up --detach
  8. Check the logs: docker compose logs -f

Contributing

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.

About

InNoHassle Search API backend

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors 11

0