How simptom569/vento works
Purpose and Entrypoints
Vento is an async FastAPI backend for a secure messenger: authentication, private/group/secret/channel chats, encrypted messaging, channel posts, and calls. The production ASGI entrypoint is app/main.py; it builds the FastAPI app and installs Dishka DI. HTTP v1 boundaries are implemented in app/presentation/api/v1/routers/auth.py, app/presentation/api/v1/routers/chats.py, and app/presentation/api/v1/routers/messages.py.
Layered Composition
The repository follows Clean Architecture: presentation invokes application handlers; handlers depend on domain entities and abstract ports; infrastructure implements those ports. DI wiring is centralized in app/container.py, while framework-independent settings, request dependencies, and security are in app/core/config.py, app/core/dependencies.py, and app/core/security.py. This is the main boundary preventing FastAPI/SQLAlchemy concerns from entering business logic.
Domain Model and Policy
Core domain concepts are users/sessions, chats and memberships, messages, feed posts, and calls, represented separately from persistence in app/domain/entities/user.py, app/domain/entities/chat.py, and app/domain/entities/message.py. Repository contracts establish persistence boundaries in app/domain/ports/repositories/chat_repo.py, app/domain/ports/repositories/message_repo.py, and app/domain/ports/repositories/credentials_repo.py. A channel is a chat; a feed post is a message specialization, avoiding separate content pipelines.
Command and Query Flows
Mutations are single-purpose command handlers: auth lifecycle in app/application/commands/auth/login.py and app/application/commands/auth/refresh_token.py; membership/chat changes in app/application/commands/chats/create_channel.py; and message lifecycle in app/application/commands/messages/send_message.py. Read models are handled separately by query handlers such as app/application/queries/chats/get_user_chats.py, app/application/queries/messages/get_chat_messages.py, and app/application/queries/messages/get_channel_feed.py. Typical flow is request schema → router → injected handler → domain-port calls → response schema.
Persistence and Transaction Boundary
PostgreSQL 16 is accessed through async SQLAlchemy. ORM schema and domain mapping live in app/infrastructure/db/models/user.py, app/infrastructure/db/models/chat.py, and app/infrastructure/db/models/message.py; concrete repository adapters are in app/infrastructure/db/repositories/. The request-scoped async session is created from app/infrastructure/db/session.py, giving application handlers a unit-of-work-like database boundary. Alembic migration integration begins at alembic/env.py.
Security and Encrypted Content
Authentication uses RS256 JWT access tokens plus rotating, hashed refresh tokens; the implementation boundary is app/core/security.py with session/credential persistence through app/domain/ports/repositories/credentials_repo.py. Message content is designed as client-side E2E ciphertext: ordinary chats support per-device recipient payloads, while secret chats use a message-level encrypted blob. Server-side message operations and storage metadata are centered in app/domain/entities/message.py and app/infrastructure/db/models/message.py; plaintext encryption/decryption is not a backend responsibility.
External Runtime and Planned Integrations
The current concrete runtime is Python 3.14+, FastAPI/Uvicorn, Dishka, PostgreSQL/asyncpg, and Docker Compose (Dockerfile, docker-compose.yml). Redis, Kafka, push, object storage, and WebSocket integration directories exist but are placeholders: app/infrastructure/redis, app/infrastructure/kafka, app/infrastructure/storage, and app/presentation/websocket. The intended external services are Redis pub/sub/cache, Kafka events, MinIO S3-compatible attachments, FCM push, and LiveKit for calls; call application handlers currently start at app/application/commands/calls/initiate_call.py.
Main entry points: auth.py v1 routers · container.py DI container · message_repo.py Repository ports · login.py Auth commands
Components 19
HTTP API
- ASGI app
app/main.py - v1 routers · Auth, chat, and message endpoints.
app/presentation/api/v1/routers/auth.py
Application
- DI container
app/container.py - JWT security · RS256 access tokens and rotating hashed refresh tokens.
app/core/security.py - Auth commands
app/application/commands/auth/login.py - Chat commands
app/application/commands/chats/create_channel.py - Message commands
app/application/commands/messages/send_message.py - Chat queries
app/application/queries/chats/get_user_chats.py - Message/feed queries · Includes chat history and channel feed reads.
app/application/queries/messages/get_chat_messages.py - Call commands · Call initiation integration is planned.
app/application/commands/calls/initiate_call.py
Domain
- Messaging domain · Users, chats/memberships, messages, and feed posts.
app/domain/entities/message.py - Repository ports · Chat, message, and credential boundaries.
app/domain/ports/repositories/message_repo.py - Credentials port
app/domain/ports/repositories/credentials_repo.py
Infrastructure
- Async DB session
app/infrastructure/db/session.py - Repository adapters
app/infrastructure/db/repositories/message_repo.py - ORM and mapping · Maps domain messaging data to relational schema.
app/infrastructure/db/models/message.py - PostgreSQL 16
- Alembic migrations
alembic/env.py - Planned integrations · Redis, Kafka, storage, WebSocket, push, and LiveKit are not yet concrete.
app/infrastructure/redis
Connections 28
- ASGI app → v1 routers: mounts
- ASGI app → DI container: installs
- DI container → Auth commands: injects
- DI container → Chat commands: injects
- DI container → Message commands: injects
- DI container → Chat queries: injects
- DI container → Message/feed queries: injects
- v1 routers → Auth commands: commands
- v1 routers → Chat commands: commands
- v1 routers → Message commands: commands
- v1 routers → Chat queries: reads
- v1 routers → Message/feed queries: reads
- Auth commands → JWT security: issues tokens
- JWT security → Credentials port: uses
- Auth commands → Credentials port: persists sessions
- Chat commands → Messaging domain: applies policy
- Message commands → Messaging domain: stores ciphertext metadata
- Message/feed queries → Repository ports: queries
- Chat queries → Repository ports: queries
- Chat commands → Repository ports: persists
- Message commands → Repository ports: persists
- Repository ports → Repository adapters: implemented by
- Credentials port → Repository adapters: implemented by
- Repository adapters → Async DB session: uses
- Async DB session → ORM and mapping: loads/maps
- ORM and mapping → PostgreSQL 16: persists
- Alembic migrations → PostgreSQL 16: evolves schema
- Call commands → Planned integrations: intended integration