No description
- Python 99.3%
- Dockerfile 0.7%
|
|
||
|---|---|---|
| .forgejo | ||
| app | ||
| tests | ||
| .env.example | ||
| .gitignore | ||
| docker-compose.yml | ||
| Dockerfile | ||
| pyproject.toml | ||
| README.md | ||
Chat Backend
FastAPI backend for a Telegram-like chat app with direct messages, groups, and channels.
Features
- Direct messages — 1:1 conversations between users
- Groups — multi-user chats where all members can post
- Channels — broadcast rooms; only owners/admins post, subscribers read
- JWT authentication
- PostgreSQL + async SQLAlchemy
Quick start
# Start PostgreSQL and API
docker compose up --build
# API docs: http://localhost:8000/docs
Local development with uv
docker compose up db db-init -d
uv sync --dev
export DATABASE_URL=postgresql+asyncpg://chat:chat@localhost:5432/chat
export TEST_DATABASE_URL=postgresql+asyncpg://chat:chat@localhost:5432/chat_test
uv run uvicorn app.main:app --reload
Tests
docker compose up db db-init -d
uv run pytest tests/unit -v
uv run pytest tests/e2e -v
API overview
| Method | Path | Description |
|---|---|---|
| POST | /api/auth/register |
Register user |
| POST | /api/auth/login |
Login (OAuth2 form) |
| GET | /api/auth/me |
Current user |
| POST | /api/conversations/dm/{user_id} |
Start or get DM |
| POST | /api/conversations |
Create group or channel |
| GET | /api/conversations |
List user's conversations |
| POST | /api/conversations/{id}/messages |
Send message |
| GET | /api/conversations/{id}/messages |
List messages |