This extension builds upon the earlier Maani project available on my GitHub page, introducing additional features, such as an API for Google search and the retrieval of images based on user-provided queries, along with the ability to save the results.
This guide offers comprehensive instructions for running the Maani Google Search Project locally. The project is organized into three key components: Database, Store, and Retrieval. The Store component encompasses backend and admin servers, while the Retrieval component functions as an API gateway. The project primarily focuses on facilitating the uploading and downloading of various file types, alongside providing an API for Google search and image retrieval based on user queries, with the option to save the results.
This Go project follows a microservices architecture, featuring two main components:
-
Store Microservice: Responsible for managing admin-related endpoints and a backend connected to the database.
-
Retrieval Microservice: Handles user authentication and serves as a gateway for the Store Microservice.
The communication between microservices is facilitated through HTTP requests, promoting efficient interaction. The project relies on PostgreSQL as its chosen database.
The microservices communicate with each other using HTTP requests, and the project utilizes PostgreSQL as the database.
-
Clone the Project:
git clone https://github.com/lebleuciel/maani
-
Navigate to the Project Directory:
cd maani
To build images from the Docker files and start containers, use the following command:
make runThis command initializes three images:
- Database: A container for our PostgreSQL Database.
- Store: Contains two servers—one for the backend on port 9000 and another for admin on port 9001.
- Retrieval: Acts as an API gateway on port 8000.
To generate users in the database, run the following command:
make seed-dataThis command creates two users:
-
Admin User:
- Email: admin@example.com
- Password: password
- Access Type: Admin
-
Regular User:
- Email: customer@example.com
- Password: password
- Access Type: User
In the Maani project, the helper part within the packages directory is dedicated to providing additional functionalities and various utilities. These utilities are designed to enhance the overall capabilities of the project.
The helper part encompasses several utilities that cater to different aspects of the Maani project forexample working with filesystem inorder to read and store input files.
To interact with the program, you can choose between two options: Postman and Swagger.
To generate Swagger documentation, use the following command:
make gateway-apiExecuting this command serves the Swagger documentation, providing an interactive interface to explore and interact with the APIs.
Upon login, you will receive an authentication token. Use this token in the Bearer section for authorization in subsequent requests.
For Postman users, a convenient script has been provided to automate token handling. You can download the Postman workspace from the following link and add it to your workspaces:
Postman doc: https://documenter.getpostman.com/view/13169243/2s9YeG5rNc
This workspace includes predefined settings for handling tokens, eliminating the need for manual entry during login.
If you prefer exploring the project through Go documentation, use the following command to serve Go documentation:
make godocFeel free to choose the method that best suits your workflow, whether it's interacting with APIs through Swagger, utilizing Postman for streamlined testing, or exploring detailed Go documentation.