How styletranslator/style-translator works
Style Translator is a React/FastAPI service that translates user text into a selected language and tone. The main workflow loads available styles, accepts text and translation options, routes short or long requests, and displays the result. Short translations produce multiple candidates and may use a Redis cache; long translations are chunked and can use a glossary for consistency. The README also documents Gemini as the translation engine and optional Redis-backed caching and rate limiting. Connections reflect shown calls or README statements; unsampled implementation details are not inferred.
Main entry points: App.jsx App state · translate.py Translation service · routes.py API routes · redis_client.py Redis client
Components 26
Translation interface
- App state
frontend/src/App.jsx - Translation hook
frontend/src/hooks/useTranslate.js - API client
frontend/src/api/client.js - Style carousel
frontend/src/components/StyleCarousel/StyleCarousel.jsx - Text input
frontend/src/components/InputPanel/InputPanel.jsx - Language selector
frontend/src/components/LangToggle/LangToggle.jsx - Result display
frontend/src/components/ResultPanel/ResultPanel.jsx - Candidate row
frontend/src/components/CandidateRow/CandidateRow.jsx - Style pill
frontend/src/components/Pill/Pill.jsx - Status badge
frontend/src/components/Badge/Badge.jsx
HTTP API
- FastAPI app
backend/main.py - API routes
backend/api/routes.py - Request schemas
backend/models/schemas.py - Error handling
backend/core/error_handlers.py - Domain errors
backend/core/exceptions.py
Translation workflow
- Translation service
backend/services/translate.py - Style prompts
backend/styles.py - Text chunking
backend/services/chunking.py
Integrations and state
- Gemini client
backend/clients/gemini.py - Google Gemini
- Translation cache
backend/clients/cache.py - Rate limiter
backend/clients/rate_limiter.py - Redis client
backend/clients/redis_client.py - Redis
- Runtime config
backend/core/config.py
Other components
- User
Connections 35
- User → App state: enters text
frontend/src/App.jsx - App state → Style carousel: renders
frontend/src/App.jsx - App state → Text input: renders
frontend/src/App.jsx - App state → Language selector: renders
frontend/src/App.jsx - App state → Result display: renders
frontend/src/App.jsx - App state → Style pill: renders
frontend/src/App.jsx - App state → Translation hook: uses
frontend/src/App.jsx - App state → API client: loads styles
frontend/src/App.jsx - Result display → Candidate row: renders
frontend/src/components/ResultPanel/ResultPanel.jsx - Text input → Status badge: renders
frontend/src/components/InputPanel/InputPanel.jsx - Result display → Style pill: renders
frontend/src/components/ResultPanel/ResultPanel.jsx - Translation hook → API client: requests translation
frontend/src/hooks/useTranslate.js - API client → API routes: HTTP requests
frontend/src/api/client.js - FastAPI app → API routes: registers routes
backend/main.py - FastAPI app → Error handling: registers handlers
backend/main.py - FastAPI app → Redis client: closes on shutdown
backend/main.py - API routes → Request schemas: validates and responds
backend/api/routes.py - API routes → Rate limiter: checks requests
backend/api/routes.py - API routes → Translation service: dispatches translation
backend/api/routes.py - API routes → Domain errors: raises limit error
backend/api/routes.py - Error handling → Domain errors: converts errors
backend/core/error_handlers.py - Translation service → Translation cache: reads and writes
backend/services/translate.py - Translation service → Gemini client: generates translations
backend/services/translate.py - Translation service → Text chunking: splits long text
backend/services/translate.py - Translation service → Style prompts: uses style definitions
backend/services/translate.py - Translation service → Request schemas: validates glossary
backend/services/translate.py - Gemini client → Google Gemini: calls model
README.md - Translation cache → Redis client: uses shared client
backend/clients/cache.py - Rate limiter → Redis client: uses shared client
backend/clients/rate_limiter.py - Redis client → Redis: connects
backend/clients/redis_client.py - Translation cache → Runtime config: reads settings
backend/clients/cache.py - Redis client → Runtime config: reads settings
backend/clients/redis_client.py - Rate limiter → Runtime config: reads settings
backend/clients/rate_limiter.py - Gemini client → Runtime config: reads settings
backend/clients/gemini.py - FastAPI app → Runtime config: configures CORS
backend/main.py