How mercan/youtube-subtitles works
Main Components
a) Client Layer:
• External HTTP clients (browsers, curl, etc.)
• Incoming REST requests
b) API Layer:
• Main HTTP Server (cmd/server)
• Router component (internal/api/routes)
• Controllers (internal/api/controllers)
c) Core Service Layer:
• Subtitle Processing Services (internal/helpers)
• Validation Services (internal/validators)
• Utility Services (internal/utils)
d) External Services:
• YouTube API/Service (for fetching video subtitles)
┌─────────────┐
• Client │
• ┘
• ↓
┌─────────────┐
• API Layer │
• ┘
• ↓
┌─────────────┐
• Services │
• ┘
• ↓
┌─────────────┐
• YouTube │
• ┘
Detailed Component Breakdown
• Blue rectangles for client-facing components
• Green rectangles for API layer components
• Yellow rectangles for service layer components
• Gray rectangles for external services
1. Client → Router (/subtitles endpoint)
2. Router → SubtitleController
3. SubtitleController → YouTubeURLValidator
4. SubtitleController → GetSubtitles Helper
5. GetSubtitles Helper → YouTube API
6. GetSubtitles Helper → FilterSubtitles Helper
7. SubtitleController → Response Utility
Technical Details
Component Details:
• Server: Go HTTP Server (cmd/server/main.go)
• Router: Custom router implementation (internal/api/routes)
• Validators: YouTube URL validation
• Helpers: Subtitle download, filtering, and processing
• Response: Standardized JSON response handling
Implementation Notes
• Keep the main flow in the center
• Related components together
• Use consistent spacing and alignment
• Version/environment information
This architecture represents a clean, modular design that separates concerns between API handling, business logic, and external service interaction, making it easy to maintain and extend the system in the future.