Skip to content

one-zero-eight/music-room

Repository files navigation

InNoHassle Music room

GitHub Actions pre-commit

Lines of Code Bugs Vulnerabilities

Table of contents

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

About

This is the API for music room service in InNoHassle ecosystem.

Features

  • 🎵 Booking Music room
  • 📅 Schedule of Music room
  • 🔒 Roles and permissions

Technologies

Development

Getting started

  1. Install Python 3.12

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

  6. Set up a PostgreSQL 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, for example:
      db_url: postgresql+asyncpg://postgres:postgres@localhost:5433/postgres
    Using pgAdmin
    • Connect to the PostgreSQL server using pgAdmin
    • Set up a new database in the server: Edit > New Object > New database
    • Use the database name in settings.yaml file, for example innohassle-events:
      db_url: postgresql+asyncpg://postgres:your_password@localhost:5432/innohassle-events
  7. Compile translation (.po) files:

    poetry run pybabel compile -d locales -D messages

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.

Run for development [API]

  1. Install dependencies for api if needed:
    poetry install
  2. Run the database if you have not done it yet
  3. Upgrade the database schema using alembic:
    poetry run alembic upgrade head
  4. 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!

Run for development [Bot]

  1. Install dependencies for bot if needed:
    poetry install
  2. Run the API service or configure the bot to work with the real(production) API.
  3. Run the Redis server if needed:
    docker compose up -d redis
  4. Run the bot:
     poetry run python -m src.bot

Localization

Aiogram:

  1. Extract messages:
    poetry run pybabel extract -k __ --input-dirs=. -o locales/messages.pot
  2. Initialize languages:
    poetry run pybabel init -i locales/messages.pot -d locales -D messages -l en
    poetry run pybabel init -i locales/messages.pot -d locales -D messages -l ru
  3. Translate messages in created .po files
  4. Compile translations:
    poetry run pybabel compile -d locales -D messages

Aiogram dialog:

Add translations identifiers (strings inside I18Format) and their translations to .ftl files

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.