Giter VIP home page Giter VIP logo

cheapskate's Introduction

cheapskate - telegram bot and API for financial control

Ruff Actions status

Information

Description

Telegram bot and REST API for convenient control of your expenses and obtaining convenient statistics on spending.

Features

  • REST API with swagger documentation, allows to connect backend to your custom interface like mobile apps, sites, etc;
  • Telegram bot that provides a convenient interface for managing expenses;
  • Ability to add categories of expenses, which will be displayed as a keyboard in the bot when adding expenses;
  • Ability to add and remove expenses by category from the list of previously added ones;
  • Various options to get statistics on spending (today's spending, remaining money for the month, statistics by month and years, etc.);
  • Authentication system;
  • Error handling and logging;
  • Asynchronous interaction between telegram bot and API.

Author

Ilya Malashenko (github: melax08, telegram: @ScreamOFF)

System requirements

  • Python 3.11;
  • Docker (19.03.0+) with docker compose for easy run.

Tech stack

Python FastAPI Python-telegram-bot Postgres SQLAlchemy Poetry Docker

Installation and start

Via docker
Clone the repo and change directory to it:
git clone https://github.com/melax08/cheapskate.git && cd cheapskate

Create an .env file in the src directory and add the necessary environment variables to it (check src/.env.example for necessary variables.)

mv src/.env.example src/.env
vi src/.env

Run docker compose to create docker containers:

docker compose up -d

or

docker-compose up -d

Settings and documentation

Settings

Bot constants available in directory: src/bot/constants/

API constants and some bot constants you can configure in .env file (see example in src/.env.example file).

Common constants for bot and API you can find in src/utils/constants.py and src/utils/configs.py.

Telegram commands and usage

Only Telegram users whose IDs are listed in the ALLOWED_TELEGRAM_IDS (check the .env.example file for details) environment variable have access to the bot. If there is no ID in this environment variable, then all users have access to the bot (not recommended).

Create categories and expense management

First, you need to create spending categories so that you can add expenses to them in the future.

To do this, send the /add_category command to the bot and follow the instructions.

add_category.png

Once at least one category has been created, you can add expenses. To do this, send the bot the amount of money that was spent, and then select the category to which the spending belongs.

add_expense.png

added_expense.png

If an expense was added by mistake, or the wrong category was selected, you can click on the delete expense button.

delete_expense.png

Obtaining spending statistics

There are several commands that allow you to get a variety of spending statistics.

/money_left - shows statistics on spending for the current month, including statistics on spending categories and the balance of funds until the end of the month.

money_left.png

/today - shows the amount of money spent today, including information by spending category

today.png

/statistics - allows you to view spending statistics for a specific month of a specific year.

statistic_choose.png

statistic_chosen.png

API documentation

If you run API locally by using uvicorn, you can get access to the swagger documentation of the API.

If you run API by command (before run this command, you need to install virtual environment for python3 and needed dependencies):

cd cheapskate/src && uvicorn api:app

Documentation will be available on URL: http://127.0.0.1:8000/docs

For developers

Before starting development and creating new commits, apply git hooks by running the command:

pre-commit install

Now, when creating a new commit, the following will be automatically launched:

You can manage the pre-commit hooks in a file: .pre-commit-config.yaml

cheapskate's People

Contributors

melax08 avatar

Stargazers

Aleksandr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.