This project is a simple, action-based microservice API application built using Laravel, optimized for workload efficiency, leveraging Laravel Octane. This application handles specific POST and GET requests, process tasks asynchronously, and is developed using Test-Driven Development (TDD) with Pest. It is containerized and runnable via Docker using Laravel Sail (for dev purposes).
To learn more about the application's functionalities, do check out the wiki I crafted for this application.
The installation process for this project has been simplified through the use of a Makefile
.
All you need do is run a single make
command and this project will be setup on your computer.
Before you proceed, ensure Docker is installed on your computer. If not, follow this step below:
Install Docker: Install Docker on your PC/Laptop by following the instructions on the official Docker website.
Once Docker is installed, follow these steps:
-
Clone the Repository: Clone this repository to your local machine:
git clone git@github.com:ThatLadyDev/microservices-api.git
-
Set Up the Application: Run the following command to set up the application:
make setup:app
This command automates the setup process for your application, including pulling necessary Docker images, creating containers, setting up Composer, installing dependencies, generating encryption keys, configuring Supervisor, and setting up the database.
-
Access the Application: If all services and containers are created successfully, you can interact with the API using your preferred API testing tool, such as Postman etc.
Use the following base URL to send requests to the API:
You should see this below on successful installation:
- Description: Retrieves the mock results associated with a Job ID
- Usage: Send a GET request to this endpoint to retrieve mock results.
- Parameter:
{joId}
- Specifies the Job ID used to fetch mock results. - Response: A JSON array containing the mock results.
- Description: Creates a new task, adds a mock result action to a queue for asynchronous processing, returns a Job ID, and stores the Job in a database.
- Usage: Send a POST request to this endpoint with the necessary input data to create a new task.
- Input: The request body should contain the necessary data to create a new task.
- Response: If successful, returns a successful JSON response.
- The
make setup:app
command simplifies the setup process of this application on your local environment. It automates the following steps:- Pulls Required Docker Images: Fetches necessary Docker images for PostgreSQL, Redis, and Laravel Sail.
- Creates Essential Containers: Initializes PostgreSQL, Redis, and Laravel Sail containers.
- Sets Up Composer: Prepares Composer for dependency management.
- Installs Dependencies: Executes composer install to install project dependencies.
- Generates Encryption Key: Creates a unique encryption key for your Laravel application.
- Configures Supervisor: Sets up Supervisor to manage critical processes.
- Database Setup: Initializes the application's database, creating required tables.
- The
.env
file must have the folloiwng key variablesAPP_PORT=6745
APP_URL=http://localhost:6745
REDIS_HOST=redis
OCTANE_SERVER=swoole
Run php pest tests
make run-test
Start running the application
make start
Stop the application containers
make stop
- DB Service: Postgres
- Queue Service: Redis
- Tools
- Swoole
- Redis
- Laravel Actions Package
- Laravel Octane
- Laravel Sail
- PHP Pest
- Principles
- TDD
- DDD
Stress testing was not worked on, I faced issues with pest php's stress test plugin,
it refused to download the k6 file needed to run stress tests locally.
Instance 1