How swagath18/multilingual-content-translation-api works
Main Components
• Frontend (Presentation Layer):
• Component Label: "Streamlit Frontend (app.py)"
• Purpose: Provides the user interface for file uploads, language selection, and displaying translation results.
• Backend (Business Logic Layer):
• Component Label: "FastAPI Backend (backend/main.py)"
• Purpose: Handles API requests, processes file uploads, and orchestrates text extraction and translation.
• Services:
• Component Label: "Translation Service (backend/services/translation_service.py)"
• Purpose: Contains the translation logic using OpenAI's GPT API.
• Utilities:
• Component Labels:
▪ "Text Extraction Utils (backend/utils/text_extraction.py)"
▪ "Language Map Utils (backend/utils/language_map.py)"
• Purpose: Manage file parsing logic for PDF, PPT/PPTX, TXT, and HTML using libraries like PyPDF2, python-pptx, and BeautifulSoup.
• External Integration:
• Component Label: "OpenAI API (GPT-3/4)"
• Purpose: Provides AI translation services upon requests from the backend.
Relationships and Data Flow
• The user interacts with the Streamlit frontend.
• Inside the backend:
• The "Translation Service" sends requests to the "OpenAI API" to convert extracted text into the requested language.
• Finally, the translated text is passed back from the "Translation Service" to the "FastAPI Backend" and then returned to the "Streamlit Frontend" for display.
Architectural Patterns and Design Principles
• Separation of Concerns: The clear delimitation between the Streamlit frontend and FastAPI backend supports independent scalability and maintenance.
• Modularization: By having dedicated modules for translation (services) and text processing (utils), the design promotes reusability and ease of future enhancements.
• API-Centric Integration: The backend acts as an intermediary between the frontend and external OpenAI translation services, establishing a clean API layer.