📂 Project Structure (Folders/Files)
tg-task-manager-bot/ ├── app.js # Main Express app ├── bot/ # Telegram bot logic, commands ├── config/ # Config management ├── database/ # Supabase models/tables ├── middleware/ # Express middleware ├── routes/ # API, webhook, project routes ├── public/index.html # [This doc] ├── tests/ # Automated/test scripts ├── utils/ # Logger, errorHandler, ...
🚀 Quickstart Example
fetch('/api/v1/users/12345/tasks').then(r=>r.json()).then(data => console.log(data.tasks));
🔌 REST API Endpoints
/api/v1/users − User tasks/statistics
GET
List tasks by user, optionally by status.
Create a new task.
Get stats of a user.
/api/v1/users/:telegramId/tasks?status=<status>List tasks by user, optionally by status.
fetch('/api/v1/users/12345/tasks?status=pending')
.then(r=>r.json())
.then(data => data.tasks)
POST /api/v1/users/:telegramId/tasks Create a new task.
fetch('/api/v1/users/12345/tasks', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ title: 'New Task', description: 'Details', priority: 'medium', dueDate: 'YYYY-MM-DD' })
})
.then(r=>r.json())
.then(data => data.task)
GET /api/v1/users/:telegramId/statsGet stats of a user.
/api/v1/tasks − CRUD & Queries
PUT
Update an existing task.
Delete a task by id.
/api/v1/tasks/:taskIdUpdate an existing task.
fetch('/api/v1/tasks/123', {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ status: 'completed' })
})
.then(r=>r.json())
.then(data => data.task)
DELETE /api/v1/tasks/:taskIdDelete a task by id.
fetch('/api/v1/tasks/123', { method: 'DELETE' })
.then(r=>r.json())
/api/project − Project Management
POST
GET
GET
PUT
/api/project/create - Create projectGET
/api/project/:id - Fetch project by idGET
/api/project/team/:team_id - List projects for a teamPUT
/api/project/:id - Update project/api/team − Team Endpoints
GET
PUT
/api/team/:teamId - Info, users, tasksPUT
/api/team/:teamId - Edit team info/api/user − User CRUD
GET
POST
PUT
DELETE
/api/user/:userIdOrUserNamePOST
/api/userPUT
/api/user/:userIdDELETE
/api/user/:telegramId/api/webhook − Webhook Endpoints
POST
POST
DELETE
/api/webhook/telegram - Telegram webhook receivePOST
/api/webhook/set - Set webhook URLDELETE
/api/webhook - Delete webhookSee more in routes/ and database/tables/
See code for advanced filters, stats endpoints and database join logic.
🗃️ Data Models (Simplified)
| User | Task | Project | Team |
|---|---|---|---|
|
id (UUID/int) user_name first_name last_name language_code avatar_url premium |
id (int) title description status priority due_date created_by assigned_to project_id |
id (int/UUID) name name_code description team_id |
id (int/UUID) name description |
See database/tables/ JS for full structures and more advanced query params.
💡 Tips & Resources
- Endpoints return JSON with
application/jsonContent-Type - See README.md for setup, commands, and CLI tips
- Source: routes/ and database/tables/