Skip to content

Ysen1903/Translator_backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Translator Backend

A robust backend API for a translation application, built with FastAPI, PostgreSQL, and Hugging Face Inference API.

Features

  • Authentication: Secure user registration and login using JWT (JSON Web Tokens).
  • Translation: Translate text between English and French using state-of-the-art models hosted on Hugging Face.
    • French to English (Helsinki-NLP/opus-mt-fr-en)
    • English to French (Helsinki-NLP/opus-mt-en-fr)
  • Database: PostgreSQL integration with SQLAlchemy ORM.
  • Security: Password hashing with Bcrypt, environment variable configuration.

Tech Stack

  • Framework: FastAPI
  • Database: PostgreSQL
  • ORM: SQLAlchemy
  • Authentication: Python-Jose, Passlib (Bcrypt)
  • AI/ML: Hugging Face Inference API

Setup & Installation

  1. Clone the repository:

    git clone https://github.com/Ysen0603/Translator_backend.git
    cd Translator_backend
  2. Create a virtual environment:

    python -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Configure Environment Variables: Create a .env file in the root directory and add the following:

    DATABASE_URL=postgresql://user:password@localhost/dbname
    SECRET_KEY=your_secure_secret_key
    HUGGINGFACE_API_KEY=your_huggingface_api_key
  5. Run the application:

    uvicorn main:app --reload

API Documentation

Once the server is running, you can access the interactive API documentation at:

  • Swagger UI: http://localhost:8000/docs
  • ReDoc: http://localhost:8000/redoc

API Endpoints

Authentication

  • POST /api/v1/auth/register: Register a new user.
  • POST /api/v1/auth/login: Login and get an access token.

Translation

  • POST /api/v1/translation/: Translate text (Requires Authentication).
    • Body: {"text": "Hello", "source_lang": "en", "target_lang": "fr"}

About

A robust backend API for a translation application, built with FastAPI, PostgreSQL, and Hugging Face Inference API.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors