TG2WEB is an educational project, the main purpose of which is to pass the SSAD course and learn something new about Software Design. However, it can be used as a web-proxy for Telegram channels. This might be extremely useful since in many countries Telegram is banned. Another possible use case for this project is history indexation by search engines, since by default content in Telegram is not searchable by Google. If a content owner publishes his channels via our project it may attract more visitors through search engines, and as a result increase the number of visitors and possible revenue.
- Display and load new messages
- Make messages indexible
- Save history of searches and allow to sort them
- Inform user if content is loading
- Use REST-like URLs
- Must be convinient for mobile browsers
- Respond quickly
- Promptly load new messages
- Avoid authentification
- Be user friendly and do not require a lot installation details
Whole system consists of three parts:
- frontend. Implemented using React.js.
- web server. Implemented using Django framework (Python).
- sync worker. Works in background, communicates with Telegram API. Implemented using Python.
https://github.com/Zakhar02/SSAD_TG_To_Web/blob/master/mermaid-diagram-20210925232147.png
https://github.com/Zakhar02/SSAD_TG_To_Web/blob/master/mermaid-diagram-20210925232941.png
- Django - MVC framework, backend, has powerful patterns such as models and views.
- Crawler - deamon that checks new messages and stores them in DB, implements observer pattern.
A typical Django project that consists of "Tg_To_Web" folder that stores configuration settings, "backend" that is basically source code and a "frontend".
For now, the only way to use our App - you need to install Linux. Then:
- Install required packages using makefile
make install_all_deps
- Install Docker on your machine:
sudo snap install docker
Run Docker container with PostgreSQL in it:
make run_database
Running server:
make run_backend
Running frontend:
make run_frontend
Running sync worker requires to provide Telegram App Id and hash. Sync worker users Telegram accounts to access the API, thus it is necessary to provide account info, such as phone number and password (asked via prompt):
export TELEGRAM_APP_ID='your app id'
export TELEGRAM_API_HASH='your api hash'
export TELEGRAM_PHONE='+80000000000'
export TELEGRAM_DATA_CRYPT_KEY='Any data, used as cryptographic seed'
make run_sync
Killing Docker container (in case of troubles/restarts).
make kill_database
If getting an error 'listen tcp4 0.0.0.0:5432: bind: address already in use' get the list of processes acquiring this port and kill them
sudo ss -lptn 'sport = :5432'
sudo kill {process id}
If any change was applied to models.py files, run the following:
make migrate_db
When rebuilt frontend part, you should rebuild static files:
make rebuild