A Telegram message logging system. A Python bot captures messages from Telegram chats and stores them in PostgreSQL. A REST API and MVC web frontend provide access to the logged data.
| Component | Tech | Description |
|---|---|---|
| FoolOfRESTAPI | ASP.NET Core 9, EF Core, Npgsql | REST API for querying logged data |
| FoolOfRESTWeb | ASP.NET Core 9 MVC, Tailwind CSS | Web interface for browsing chats and users |
| TelegramLogger | Python 3.11, python-telegram-bot, psycopg3 | Telegram bot that logs all messages to the database. Runs as a subprocess inside the API container |
| PostgreSQL 16 | — | Stores users, chats, and messages |
The API generates a random key on startup and shares it with the web frontend for internal authentication. All API endpoints require this key via the APIKEY header.
- Docker and Docker Compose
- A Telegram bot token — create one via @BotFather and add it to a group or use it in private chats
Uses a pre-configured PostgreSQL instance with hardcoded credentials. All connection strings are injected automatically.
TOKEN=your_telegram_bot_token docker compose -f docker-compose.test.yml upOr set TOKEN in a .env file and run:
docker compose -f docker-compose.test.yml up-
Copy the example environment file and fill in your values:
cp .env.backend.example .env
Variable Description DB_USERPostgreSQL username DB_PASSWORDPostgreSQL password POSTGRES_CONNECTION_STRINGNpgsql connection string for the API (e.g. Host=db;Database=logger;Username=USER;Password=PASS)CONNECTION_STRINGlibpq connection string for the bot (e.g. host=db port=5432 dbname=logger user=USER password=PASS)TOKENTelegram bot token APIKEYShared secret between the API and Web containers (any random string) -
Start all services:
docker compose up
| Service | URL | Notes |
|---|---|---|
| Web frontend | http://localhost:5002 | Browse chats and users |
| REST API | http://localhost:5001 | Requires APIKEY header |
| PostgreSQL (test) | localhost:5431 | Credentials: postgres / testdb |
| PostgreSQL (prod) | localhost:5433 | Credentials from .env |
Requires a running PostgreSQL instance. Configure the connection string in FoolOfRESTAPI/appsettings.Development.json:
{
"ConnectionStrings": {
"Docker": "Host=localhost;Port=5431;Database=logger;Username=postgres;Password=testdb"
}
}Start both .NET projects (the API automatically launches the Python bot as a subprocess):
./run_project.shFor Python bot setup (token, virtual environment), see TelegramLogger/Config.md.
All endpoints require an APIKEY header matching the key generated by the API on startup.
| Method | Path | Description |
|---|---|---|
| GET | /users/ |
All users |
| GET | /users/{id} |
User by ID |
| GET | /chats |
All chats |
| GET | /chats/{id} |
Chat by ID |
| GET | /messages/ |
All messages |
| GET | /messages/{id} |
Message by ID |
| GET | /usermessages/{userid} |
Messages from a user |
| GET | /chatmessages/{chatid} |
Messages in a chat |
| GET | /chatusers/{chatid} |
Users in a chat |