Backend Java proxy server for Nerd Translator android app to connect it with Google Cloud APIs.
To utilize this backend Java Spring Boot proxy server for communication between your Android application and Google Cloud APIs, follow these steps:
-
Download Source Code: Clone or download the source code repository to your local machine.
$ git clone https://github.com/vamelchenia/translate-api-bridge.git
-
Sensitive Properties File: Create a file named
sensitive.properties
in the root of the project. Add your Google Cloud credentials to this file. The credentials should be provided by Google Cloud.Example of
sensitive.properties
:TYPE = your_property PROJECT_ID = your_property PRIVATE_KEY_ID = your_property PRIVATE_KEY = your_property CLIENT_EMAIL = your_property CLIENT_ID = your_property AUTH_URI = your_property TOKEN_URI = your_property AUTH_PROVIDER_X509_CERT_URL = your_property CLIENT_X509_CERT_URL = your_property UNIVERSE_DOMAIN = your_property
Replace
your_property
with the actual values provided by Google Cloud. -
Build and Run: Use your preferred Java build tool to build the project. For instance, with Maven:
$ mvn clean install
After a successful build, you can run the application:
$ java -jar target/translate-api-bridge.jar
-
Integration with Android App: In your Android application, configure the API endpoints to communicate with the deployed backend server. The available endpoints are documented using SpringDoc for easy reference.
-
Endpoint 1 - [POST] Post text to receive it's translation:
- Path:
/translation/{originalLanguage}/{targetLanguage}
- Description: Post a text to translate with original language and target language codes as parameters and get translation with additional data as audio and part of speech if provided as response.
- Request:
- Method: POST
- Path Variable:
originalLanguage
(String) - Original language code to translate fromtargetLanguage
(String) - Target language code to translate to
- Parameters:
originalText
(JSON -> RequestData) - Original language text that should be translated
- Response:
- HttpStatus with Translation data in JSON format
- Path:
-
Endpoint 2 - [GET] Get supported languages:
- Path:
/translation/languages
- Description: Get a map of all supported languages with their codes.
- Request:
- Method: GET
- Response:
- HttpStatus with supported languages data in JSON format
- Path:
Ensure that your Android application makes requests to these endpoints using the appropriate HTTP methods and includes any required parameters in the request body or as path variables. The detailed documentation provided by SpringDoc makes it easy to integrate and interact with the backend API seamlessly.
You can try all endpoint out using Springdoc UI after copy and run the application:
http://your-host:your-port/swagger-ui/index.html
Users should replace
your-host
with their host address andyour-port
with their port number. For instance:http://localhost:8083/swagger-ui/index.html
In this example, localhost is the host, and 8083 is the port. Each user can substitute these values with their own, depending on how they have configured their server.
-
-
Note: Ensure that the backend server is running and accessible from your Android application. You may need to adjust firewall settings or deploy the backend to a publicly accessible server.
Now, your Android application should be able to communicate seamlessly with Google Cloud APIs through the Java Spring Boot proxy server.
To install and run the project, Java v17+ is required.
-
Create a fork of the Translate API bridge repository. Click on the Fork symbol at the top right corner.
-
Clone your new fork of the repository in the terminal/CLI on your computer with the following command:
git clone https://github.com/<your-github-username>/translate-api-bridge.git
- Navigate to the newly created project directory:
cd translate-api-bridge
- Create a new local branch:
git checkout -b YourBranchName
-
Make your changes to the source code.
-
Stage your changes and commit:
git add <file/folder>
git commit -m "A message describing your changes"
- Push your local commits to the remote repository:
git push origin YourBranchName
9. Create a Pull request by switching to the Pull requests tab and clicking on New pull request button.
- Valeriia Amelchenia — Senior Software QA Engineer, founder of the project
- Artem Prokhorov — Back-End Engineer
- Evgeny Savonkin — Back-End Engineer