Giter Site home page Giter Site logo

analytics-publisher's Introduction

analytics-publisher

The app consists of API service, which provides information about football clubs, and telegram bot.

API service

  • API service has endpoints:

    1. GET /clubs (information about clubs)
    2. GET /clubs/{club_id} (information about each club)
    3. POST /clubs (creates a club)
    4. endpoints to export information into the telegram bot.
  • The data about club are stored in PostgreSQL, the data about pages' views are stored in MongoDB (inc. time, user IP).

  • There are cron jobs, implemented with using Celery, which export data about pages' views to .csv file and to plots in .png format.

  • The are three types of plots:

    1. with bars, which shows total views of clubs during the specific period of time,
    2. lineplot, which shows dynamics of views during the specific period of time,
    3. displot, which shows distribution of data.
  • All the files are saved to Google Disk.

Telegram bot

  • In the bot with /start you will have several buttons:
    • buttons for getting plots,
    • buttons for getting information, using a source Api-Football.
  • First you'll receive the id of Celery task, which is responsible for plot building.
  • You can check the status of the task by sending task ID to the bot. The bot will return you on of several possibilities (PENDING, STARTED, SUCCESS).
  • If the task status is SUCCESS, you can receive the plot from bot by sending the command /result.
  • The bot asks for the data from API service. Information about tasks' statuses is stored in Redis database (which is used as backend in Celery app).

App structure

Links

This project was built using these tools:

Tool Description
FastAPI "Web framework for building APIs with Python"
Python Telegram Bot "This library provides a pure Python, asynchronous interface for the Telegram Bot API"
Celery "A task queue with focus on real-time processing, while also supporting task scheduling"
PostgreSQL "An open source object-relational database system"
SQLAlchemy "The Python SQL toolkit and Object Relational Mapper"
MongoDB "A NoSQL database program"
Redis "The open source, in-memory data store"
seaborn "A Python data visualization library based on matplotlib"
poetry "Python dependency management and packaging made easy"

Installation

Copy a project

$ git clone [email protected]:Dddarknight/analytics-publisher.git
$ cd analytics-publisher

Set up environment variables

$ touch .env

# You have to fill .env file. See .env.example.
# You will have to:
# 1) fill username and password fields for PostgreSQL, RabbitMQ. If you don't have these credentials, please follow the instructions in the official documentation.
# 2) make a telegram bot and put its token to a TG_API_TOKEN variable.
# 3) register on Api-Football and put api-token to a API_FOOTBALL variable.

Set up the environment

$ pip install poetry
$ make install

Launch API server

$ make run

Launch a bot

$ make bot_

Launch Celery


# Launch Celery scheduled tasks
$ celery -A api_app.celery_tasks beat --loglevel=info

# Launch the Celery worker (it's also necessary for the bot)
$ celery -A api_app.celery_tasks worker --loglevel=info --pool solo

License

GNU GPLv3

analytics-publisher's People

Contributors

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