A simple web UI for viewing telegram archives produced by Telegram export feature.
Demo is available here https://tgarchive-demo.undo.it/
TGArchive viewer consists of three components:
- Search index - Elasticsearch
- Backend - python app build with FastAPI
- Frontend - React+Material UI SPA
On first run one should index zip files from export. Only text content are indexed. All media (video, audio, photos) remains in zip files and served directly by backend app.
Prerequisites: docker
, docker-compose
, npm
.
Build frontend:
npm install
REACT_APP_API_ROOT=/api npm run build
Build docker images:
docker build --platform linux/amd64 -t tgarchive-backend -f backend.Dockerfile .
docker build --platform linux/amd64 -t tgarchive-frontend -f frontend.Dockerfile .
Download Telegram archives in zip format to ./zipfile directory. Index all directory or specific files (If you have an error on first run, wait for a couple of minutes and retry):
docker-compose run --rm backend python /opt/api/tg_build_index.py /data/zipfiles/ http://elasticsearch:9200
Otherwise, one could index archives from admin page (%base_url%/#/admin). For publicly available site protect admin page with nginx basic auth:
- generate password file:
htpasswd -c .htpasswd admin
- override nginx config in docker-compose.yml, add two files in
frontend
service section:
volumes:
- .htpasswd:/etc/nginx/.htpasswd
- ./nginx_production.conf:/etc/nginx/conf.d/default.conf
Otherwise, one could index specific archives like this:
docker-compose run --rm backend python /opt/api/tg_build_index.py /data/zipfiles/archive_1.zip http://elasticsearch:9200
Start docker-compose:
docker-compose up -d
For development purposes it is better to use such configuration:
- Run Elasticsearch and (optionaly) Kibana from docker-compose-dev.yml
- Run backend from cli:
ELASTICSEARCH_URL=http://localhost:9200/ uvicorn tgviewer:app --reload
- Run frontend from IDEA, passing in run
npm start
configuration env vars:REACT_APP_API_ROOT=http://localhost:8000