Logo Lanfrica

JUNOLA/bassa_api

Domain:

natural language processing

Record type:

softwaremodel
Creator:
JUN
Host:
# Tradika by JintαΊ½liaS # πŸš€ French ↔ Bassa Translation API ## πŸ“Œ Overview This project provides a REST API powered by **FastAPI** for translating text between **French** and **Bassa** (a Bantu language spoken in Africa). The translation model is a custom-trained **MarianMT** model hosted on **Google Drive** and loaded dynamically at runtime. It can be integrated into **Flutter mobile** and **web** apps via HTTP requests. --- ## 🧱 System Architecture ``` Flutter App (mobile/web) ↓ [ HTTP POST Request ] ↓ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ FastAPI Server β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ↓ [ Load MarianMT model ] ↓ [ Tokenizer + Inference ] ↓ [ JSON Response with Translation ] ``` --- ## πŸ“‚ Project Structure ``` bassa_translate_api/ β”œβ”€β”€ main.py # FastAPI backend β”œβ”€β”€ utils.py # Downloads model from Google Drive β”œβ”€β”€ requirements.txt # Python dependencies β”œβ”€β”€ start.sh # Render startup script └── model/ # Directory for downloaded model ``` --- ## βš™οΈ Local Development Setup ```bash git clone github.com cd bassa_translate_api pip install -r requirements.txt uvicorn main:app --reload ``` API available at: `127.0.0.1` --- ## πŸ” API Endpoints ### `POST /translate` **Description:** Translates text from French ↔ Bassa. **Request (JSON):** ```json { "text": "Bonjour, comment vas-tu ?", "direction": "Fr β†’ Bs" } ``` **Response (JSON):** ```json { "translation": "MbΙ”tΙ”, wa kΙ›?" } ``` **Valid `direction` values:** * `"Fr β†’ Bs"` (French to Bassa) * `"Bs β†’ Fr"` (Bassa to French) --- ## πŸ“± Flutter Integration (Mobile & Web) ### Add `http` package ```yaml dependencies: http: ^0.13.5 ``` ### Sample Code ```dart import 'dart:convert'; import 'package:http/http.dart' as http; Future translateText(String text, String direction) async { final url = Uri.parse("your-api-url.onrender.com"); final response = await http.post( url, headers: …