Did you know that GitHub supports table of contents by default π€
This is the API for accounts service in InNoHassle ecosystem.
- π§βπ§ User Management
- π Authenticate with Innopolis SSO
- π± Connect Telegram account
- βΉοΈ Get user info
- π‘οΈ Tokens
- π Generate JWT tokens for other services in the ecosystem
- β Check token validity with public key
- Python 3.12+ & uv
- FastAPI & Pydantic
- Database and ORM: MongoDB, Beanie
- Formatting and linting: Ruff, pre-commit
- Deployment: Docker, Docker Compose, GitHub Actions
For other services in the InNoHassle ecosystem that need to interact with the Accounts API or with tokens from Accounts API, you can copy the SDK file from inh_accounts_sdk.py. This file is self-contained and can be used independently.
The SDK provides:
InNoHassleAccountsclass for API interactions- JWT token decoding and validation
- User retrieval by ID, email, or Telegram ID
- Pydantic schemas for user data
Note
The SDK file is designed to be copied into other projects.
- Install uv and Docker
- Install dependencies:
uv sync
- Prepare for development (read logs in the terminal):
uv run -m src.prepare
Follow the provided instructions (if needed).
- Start development server:
uv run -m src.api --reload
Follow the provided instructions (if needed).
- Open in the browser: http://localhost:8002.
The api will be reloaded when you edit the code
Important
For endpoints requiring authorization click "Authorize" button in Swagger UI
Tip
Edit settings.yaml according to your needs, you can view schema in
config_schema.py and in settings.schema.yaml
Set up PyCharm integrations
- Run configurations (docs).
Right-click the
__main__.pyfile in the project explorer, selectRun '__main__'from the context menu. - Ruff (plugin).
It will lint and format your code. Make sure to enable
Use ruff formatoption 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 Docker with Docker Compose plugin to run the service on servers.
- Copy the file with environment variables:
cp .example.env .env - Change environment variables in the
.envfile - Copy the file with settings:
cp settings.example.yaml settings.yaml - Change settings in the
settings.yamlfile according to your needs (check settings.schema.yaml for more info) - Install Docker with Docker Compose
- Run the containers:
docker compose up --build --wait - Check the logs:
docker compose logs -f
Check https://github.com/one-zero-eight/fastapi-template for updates once in a while.
- Run
uv sync --upgradeto update uv.lock file and install the latest versions of the dependencies. - Run
uv tree --outdated --depth=1will show what package versions are installed and what are the latest versions. - Run
uv run pre-commit autoupdate
Also, Dependabot will help you to keep your dependencies up-to-date, see dependabot.yaml.
- Dump:
docker compose exec db sh -c 'mongodump "mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@127.0.0.1:27017/db?authSource=admin" --db=db --out=dump/'
- Restore:
docker compose exec db sh -c 'mongorestore "mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@127.0.0.1:27017/db?authSource=admin" --drop /dump/db'
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.