- Overview
- Docker Setup
- Starting Docker
- Managing Services
- Troubleshooting
- Introduction Swagger
- How to Access End Points Using Swagger
- License
The Smart POS system leverages Docker Compose to manage and orchestrate multiple microservices alongside a MySQL database. This setup ensures a streamlined and modular architecture, facilitating ease of development, testing, and deployment.
The system is composed of the following services:
- MySQL Database: Manages the data for the Smart POS system.
- Admin Service: Handles administrative functions.
- Auth Service: Manages authentication and authorization.
- Cashier Service: Manages cashier-related operations.
- Customer Service: Handles customer interactions and functionalities.
The Docker Compose file defines the following configuration:
version: '3.8'services: db: image: mysql environment: MYSQL_ROOT_PASSWORD: password MYSQL_DATABASE: pointmaster ports: - "3308:3306" restart: always
admin-service: build: context: ./admin-service dockerfile: Dockerfile ports: - "3001:3001" environment: - ACCESS_TOKEN_SECRET=panadura - DB_HOST=db - DB_PORT=3306 - DB_USER=root - DB_PASSWORD=password - DB_NAME=pointmaster depends_on: - db restart: on-failure
auth-service: build: context: ./auth-service dockerfile: Dockerfile ports: - "3002:3002" environment: - ACCESS_TOKEN_SECRET=panadura - DB_HOST=db - DB_PORT=3306 - DB_USER=root - DB_PASSWORD=password - DB_NAME=pointmaster depends_on: - db restart: on-failure
cashier-service: build: context: ./cashier-service dockerfile: Dockerfile ports: - "3003:3003" environment: - ACCESS_TOKEN_SECRET=panadura - DB_HOST=db - DB_PORT=3306 - DB_USER=root - DB_PASSWORD=password - DB_NAME=pointmaster depends_on: - db restart: on-failure
customer-service: build: context: ./customer-service dockerfile: Dockerfile ports: - "3004:3004" environment: - ACCESS_TOKEN_SECRET=panadura - DB_HOST=db - DB_PORT=3306 - DB_USER=root - DB_PASSWORD=password - DB_NAME=pointmaster depends_on: - db restart: on-failure
Follow these steps to get Docker up and running:
- Install Docker: Download Docker Desktop from Docker's official website and follow the installation instructions for your operating system.
- Install Docker Compose: Docker Compose is bundled with Docker Desktop. If you're using a different installation, follow the instructions at Docker Compose Installation.
- Verify Installation: Open a terminal and check the installation by running:
docker --version docker-compose --version - Start Docker: Launch Docker Desktop to start the Docker engine.
To manage the services, use Docker Compose commands:
- Start Services: To start all services, run:
docker-compose up - Rebuild Services: If you make changes to the services, rebuild them with:
docker-compose up --build - Restart Services: To restart all services, use:
docker-compose restart - Stop Services: To stop all services, run:
docker-compose down
When all services are running it will be shown like this:
If you encounter issues:
- Check Logs: View logs for a specific service to diagnose problems:
docker-compose logs [service-name] - Verify Configuration: Ensure your
docker-compose.ymlfile is correctly configured and all necessary environment variables are set. - Restart Docker: Sometimes, restarting Docker Desktop can resolve issues.
Swagger is a powerful tool for designing, building, documenting, and consuming RESTful APIs. It provides a standardized way to describe your API's endpoints, methods, and data models. With Swagger, you can generate interactive API documentation that allows developers to understand and test the API directly from the documentation.
Key benefits of using Swagger include:
- Interactive Documentation: Users can interact with the API directly from the documentation, making it easier to understand and test the API.
- Code Generation: Swagger can generate client libraries, server stubs, and API documentation in various programming languages.
- Standardized API Description: Swagger uses a standardized format (OpenAPI Specification) to describe APIs, making it easier to share and understand API specifications.
For more information, visit the Swagger official website.
Swagger provides an interactive interface to explore and interact with your API endpoints. Here’s how you can use Swagger to access and test your API endpoints:
- Open the Swagger UI: Navigate to the URL where Swagger UI is hosted. This is typically served from the
/api-docspath of your application. For example:http://localhost:3002/api-docs - Explore the API Documentation: The Swagger UI will display a list of available API endpoints organized by their categories. You can expand each category to view the detailed documentation of the endpoints, including descriptions, request parameters, and response formats.
- Interact with Endpoints: To test an endpoint, follow these steps:
- Select the endpoint you want to test from the list.
- Click on the endpoint to expand it and view its details.
- Enter any required parameters or request body in the provided fields.
- Click the Execute button to send the request to the server.
- View Response: After executing the request, Swagger UI will display the response from the server, including the status code, response headers, and the response body. This allows you to verify that the endpoint behaves as expected.
Using Swagger UI makes it easy to understand and test your API endpoints interactively, helping you ensure that your API works correctly and is well-documented.
This project is licensed under the MIT License. See the LICENSE file for more details.


