An NLP Translation App built with FastAPI & React.js for the CodeAlpha AI Internship
π¨ Tech Stack Β· β¨ Features Β· π Getting Started Β· π Architecture Β· πΈ Screenshots Β· π§βπ» Author
The Language Translation Tool is a production-ready, full-stack AI Translation App that delivers instant translations across 100+ languages β powered by Google Translate through the deep-translator Python library. Designed as Task 1 for the CodeAlpha AI Internship, this project demonstrates how to architect a clean FastAPI React project with a modern glassmorphism UI, real-time text-to-speech playback, and seamless language swapping.
Whether you're building an NLP translation app, exploring FastAPI backend patterns, or learning how to integrate the Web Speech API into a React frontend, this repository serves as a comprehensive, production-quality reference.
π‘ Zero API keys required β the
deep-translatorlibrary connects to Google Translate directly, so you can clone and run the project immediately.
| Feature | Description |
|---|---|
| π 100+ Languages | Dynamic language dropdowns populated from the backend β supports every language Google Translate offers |
| β‘ Instant Translation | Real-time translation powered by deep-translator with GoogleTranslator β no API key required |
| π Swap Languages | One-click language swap with a smooth 180Β° rotation animation β text content swaps too |
| π¨ Glassmorphism UI | Stunning glass-effect design with backdrop-blur, translucent panels, and a deep purple gradient |
| π± Fully Responsive | Split-screen on desktop, stacked on mobile β works beautifully on every screen size |
| Feature | Description |
|---|---|
| π Text-to-Speech | Listen to both source and translated text via the browser's native Web Speech API with auto voice matching |
| π Copy to Clipboard | One-click copy of the translated text with a checkmark icon confirmation that auto-resets after 2 seconds |
| β¨οΈ Ctrl + Enter Shortcut | Press Ctrl + Enter (or β + Enter on Mac) in the textarea for instant translation |
| π’ Character Counter | Live character count with color-coded warnings (amber at 4,500+, red at 5,000 limit) |
| Subtle amber warning when translating empty text β no intrusive popups | |
| π Loading States | Animated pulsing spinner with "Translating..." text during API calls |
| π‘οΈ Error Handling | Graceful error display for network failures, same-language guards, and backend unavailability |
Make sure you have the following installed on your system:
- Python 3.10+ β Download Python
- Node.js 18+ β Download Node.js
- npm (comes with Node.js)
git clone https://github.com/qatre-ai/language-translation-tool.git
cd language-translation-tool# Navigate to the backend directory
cd backend
# Create a virtual environment (recommended)
python -m venv venv
# Activate the virtual environment
# On macOS/Linux:
source venv/bin/activate
# On Windows:
# venv\Scripts\activate
# Install Python dependencies
pip install -r requirements.txt
# Start the FastAPI server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000The backend API will be available at http://localhost:8000
π Interactive API docs available at http://localhost:8000/docs (Swagger UI)
Open a new terminal and run:
# Navigate to the frontend directory
cd frontend
# Install Node.js dependencies
npm install
# Start the Vite development server
npm run devThe app will open at http://localhost:5173 β the Vite dev server automatically proxies /api/* requests to the FastAPI backend.
- Type or paste text in the Source panel
- Select your source and target languages from the dropdowns
- Click Translate or press
Ctrl + Enter - Use π to listen, π to copy, and π to swap languages
language-translation-tool/
βββ π backend/ # FastAPI Python backend
β βββ π requirements.txt # Python dependencies
β βββ π app/
β βββ π __init__.py
β βββ π main.py # FastAPI app + CORS + health check
β βββ π models.py # Pydantic request/response schemas
β βββ π routes.py # /api/translate + /api/languages
β
βββ π frontend/ # React + Vite frontend
β βββ π index.html # HTML shell
β βββ π vite.config.js # Vite + Tailwind + API proxy
β βββ π package.json # Node.js dependencies
β βββ π src/
β βββ π main.jsx # React entry point
β βββ π index.css # Tailwind v4 import
β βββ π App.jsx # Root layout + TTS voice preload
β βββ π App.css # Custom animations
β βββ π components/
β β βββ π TranslationForm.jsx # Main orchestrator component
β β βββ π LanguageSelector.jsx # Dynamic language dropdown
β β βββ π TextPanel.jsx # Source/Target split panel
β β βββ π LoadingSpinner.jsx # Animated loading indicator
β βββ π services/
β βββ π api.js # API service (fetch, translate, cache)
β βββ π tts.js # Web Speech API wrapper
β
βββ π README.md # You are here! β¨
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Health check β returns API status and version |
GET |
/api/languages |
Returns all supported languages as {code: name} dictionary |
POST |
/api/translate |
Translates text β accepts {text, source_lang, target_lang} |
GET |
/docs |
Interactive Swagger UI documentation |
GET |
/redoc |
ReDoc API documentation |
curl -X POST http://localhost:8000/api/translate \
-H "Content-Type: application/json" \
-d '{"text": "Hello, world!", "source_lang": "en", "target_lang": "es"}'{
"translated_text": "Β‘Hola, mundo!",
"source_lang": "en",
"target_lang": "es",
"original_text": "Hello, world!"
}πΌοΈ Add your screenshots here! Replace the placeholders below with actual images.
| Split-Screen Layout | Mobile Responsive |
|---|---|
![]() |
![]() |
| Swap Animation | Copy Confirmation |
|---|---|
![]() |
![]() |
This AI Translation Tool uses a carefully crafted glassmorphism design system built on Tailwind CSS v4:
| Element | Style |
|---|---|
| Background | Deep gradient: from-indigo-950 via-purple-950 to-slate-900 |
| Glass Panels | bg-white/5 backdrop-blur-md border border-white/10 |
| Primary Button | Gradient: from-violet-600 to-fuchsia-600 with glow shadow |
| Accent Colors | Violet β Fuchsia β Pink gradient spectrum |
| Animations | Custom spin-180, pulse-ring, fade-in-up keyframes |
| Typography | Gradient text headers with bg-clip-text text-transparent |
Contributions, issues, and feature requests are welcome! Feel free to:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Please make sure to update tests as appropriate and follow the existing code style.
This project is licensed under the MIT License β see the LICENSE file for details.
- CodeAlpha β For the incredible AI Internship opportunity and the structured learning path that made this project possible. The internship program provides hands-on experience in AI and software engineering, and I'm grateful for the mentorship and community support.
- deep-translator β For providing a free, no-API-key-required translation library that makes building NLP translation apps accessible to everyone.
- FastAPI β For the elegant, high-performance Python web framework.
- React & Vite β For the blazing-fast frontend developer experience.
- Tailwind CSS β For making beautiful UIs achievable with utility classes.



