Parallel Translator is a web application built with Java and Spring Boot for translating a set of words into another language using a third-party translation service MyMemory API. Each word is translated in separate threads with a maximum of 10 concurrent threads. The application also logs translation requests to a PostgreSQL database.
- Java 17
- Spring Boot 3.3.2
- PostgreSQL 16
- JDBC
- RestTemplate
- Docker
- HTML + JS
- Java 17
- Maven
- Docker and Docker Compose
-
Clone the repository:
git clone https://github.com/AlexanderGarifullin/ParallelTranslator.git cd ParallelTranslator
-
Build the project using Maven:
./mvnw clean package
-
Run the application using Docker Compose:
docker-compose build --no-cache docker-compose up
-
Shut down the application:
docker-compose down
Once the application is running, it will be accessible at http://localhost:8080/api/translate.
Here is a screenshot of the main page of the web application:
If you navigate to a non-existent page, you will see a custom error page. For example, try visiting http://localhost:8080/nonexistent.
- Endpoint:
/api/translate
- Method: POST
- Request Body:
{ "text": "your text here", "sourceLang": "en", "targetLang": "es" }
- Response:
"your translated text here"
-
Send a translation request:
curl -X POST -H "Content-Type: application/json" -d '{"text": "hello world", "sourceLang": "en", "targetLang": "es"}' http://localhost:8080/api/translate
-
Response:
"hola mundo"
You can view the PostgreSQL database this way:
-
Access the PostgreSQL container:
docker exec -it postgres psql -U postgres -d TranslatorDB
-
List all entries in
api_translation_requests_logs
:SELECT * FROM api_translation_requests_logs;
-
Exit the PostgreSQL command line:
\q
To view the Javadoc documentation:
-
Generate Javadoc:
Run the following Maven command to generate the Javadoc:
./mvnw javadoc:javadoc
-
Navigate to the Javadoc directory:
The Javadoc will be generated in the
target/site/apidocs
directory.
This project is licensed under the MIT License. See the LICENSE file for details.
- The application is designed to handle translation of individual words concurrently using up to 10 threads.
- All translation requests are logged into the
api_translation_requests_logs
table with the following structure:id
(integer, primary key)client_ip
(varchar(45), not null)text
(text, not null)translated_text
(text, not null)created_at
(timestamp, default current timestamp)
For any issues or questions, please open an issue on GitHub or contact me.
© 2024 Alexander Garifullin. All rights reserved.