Architecture¶
System architecture and design decisions for the Huh platform.
Overview¶
Huh is a transcription and translation platform built with: - Frontend: Angular v20 (TypeScript) - Backend: Spring Boot (Kotlin) - Database: MongoDB - Storage: MinIO (S3-compatible object storage) - Message Queue: RabbitMQ - Transcription Service: Python (OpenAI Whisper) - Translation Service: LibreTranslate
System Components¶
Frontend (Angular)¶
- Standalone components architecture
- RxJS for state management
- WebSocket client for real-time updates
- JWT token storage and management
Backend (Spring Boot)¶
- REST API endpoints
- WebSocket server for real-time updates
- JWT authentication
- ACL service for fine-grained permissions
- Email notification service
Transcription Worker (Python)¶
- Consumes tasks from RabbitMQ
- Uses OpenAI Whisper for transcription
- Stores results in MongoDB
- Uploads files to MinIO
Infrastructure¶
- MongoDB: Document storage for transcriptions, users, ACL entries
- MinIO: Object storage for video/audio files
- RabbitMQ: Message queue for async transcription tasks
- LibreTranslate: Translation service API
Data Flow¶
Transcription Creation¶
- User uploads file via frontend
- Backend receives file, stores in MinIO
- Transcription record created in MongoDB
- ACL entry created (user becomes owner)
- Task sent to RabbitMQ
- Transcription worker processes task
- Results stored in MongoDB
- WebSocket notification sent to frontend
Video Streaming¶
- User requests video access token
- Backend generates short-lived token
- Token set as HTTP-only cookie
- Frontend requests video with cookie
- Backend validates token and streams video
Security Architecture¶
Authentication Flow¶
- User logs in with username/email and password
- Backend validates credentials
- JWT token generated with user roles
- Token sent to frontend
- Frontend includes token in Authorization header for API requests
Authorization Flow¶
- Request received with JWT token
- Token validated and user context loaded
- ACL service checks permissions
- Access granted or denied based on ACL entries
ACL Architecture¶
Components¶
- AclEntry: Individual permission grants
- AclObjectIdentity: Maps domain objects to ACL entries
- AclSid: Security identities (users and roles)
Permission Checking¶
- Check if user is admin (always granted)
- Look up object identity
- Retrieve ACL entries for object
- Check user-specific permissions
- Check role-based permissions
- Return access decision
Design Decisions¶
Why MongoDB for ACL?¶
- Flexible schema for ACL entries
- Efficient queries for permission checking
- Aligns with existing MongoDB usage
Why Cookie-Based Video Auth?¶
- HTTP-only cookies prevent JavaScript access
- Automatic cookie handling by browsers
- Better security than URL tokens
Why Stateless Sessions?¶
- Scalability (no session storage needed)
- JWT tokens contain all necessary information
- Works well with microservices architecture