How bassel20/multilingual_review_analyzer works
Project Type & Purpose
• Full-stack web application for multilingual feedback collection, translation, and sentiment analysis.
• Frontend: React SPA with Recharts for data visualization.
• Backend: Python FastAPI providing RESTful endpoints.
• Persistence: PostgreSQL via SQLAlchemy ORM.
• External AI Service: Google Gemini Flash for language detection, translation, and sentiment.
File Structure
• Top-level directories:
– backend/ – FastAPI application (main.py, crud.py, models.py, schemas.py, gemini_client.py, database.py, services.py).
– frontend/ – React application (public/index.html, src/components, src/services/api.js).
• Deployment files:
– docker-compose.yml orchestrates three containers: frontend, backend, database.
– Dockerfile in each service for container builds.
• Architectural cues:
– Layered separation (presentation, application logic, persistence)
– Clear API boundary between frontend and backend
– Dedicated module for external-service integration (gemini_client).
README for Additional Insights
• Detailed API routes (/api/feedback, /api/translate, /api/stats, /health).
• Data model: feedback table schema with text, language code, translation, sentiment, timestamp.
• Environment variables and build/run instructions.
Main Components & Their Roles
a. User Browser: Hosts the React SPA; interacts via HTTP.
b. Frontend Container: Serves static assets or runs dev server on port 3000; contains UI components (Dashboard, FeedbackForm, FeedbackList) and API client (Axios).
c. Backend Container: FastAPI app on port 8000; modules include:
– API router (main.py)
– Database layer (database.py, models.py, crud.py)
– Gemini integration (gemini_client.py, services.py)
– Validation schemas (schemas.py)
d. Database Container: PostgreSQL on port 5432; stores feedback records.
e. External Service: Google Gemini API (HTTPS) for language detection, translation, and sentiment analysis.
Relationships & Data Flow
1. Feedback submission:
User → Frontend (POST /api/feedback) → Backend
→ gemini_client calls Google Gemini → receives language/translation/sentiment
→ crud persists record in PostgreSQL
→ Backend responds → Frontend updates UI.
2. Analytics retrieval:
Frontend (GET /api/stats) → Backend aggregates via SQLAlchemy → PostgreSQL → returns counts → Recharts renders charts.
3. Feedback listing/filtering:
Frontend (GET /api/feedback?language=…&sentiment=…) → Backend → Database → UI.
4. Health checks:
Monitoring system calls GET /health → Backend checks DB and Gemini connectivity → reports status.
Architectural Patterns & Principles
• Three-tier architecture (Presentation, Application, Data).
• Separation of concerns: UI, API, persistence, external-service client.
• Containerization via Docker Compose for environment parity.
• Stateless services: each HTTP request is handled independently.
• Abstraction of external dependencies behind a client module.
Essential Elements
• Clear labels: container names, ports (3000, 8000, 5432), service names.
• Optional: monitoring/health-check flow to show system observability.