Skip to content

PointMaster-POS/server

Repository files navigation

Smart POS Server Configuration

Table of Contents

Overview

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.

Docker Setup

Services

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.

Configuration

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

Starting Docker

Follow these steps to get Docker up and running:

  1. Install Docker: Download Docker Desktop from Docker's official website and follow the installation instructions for your operating system.
  2. Install Docker Compose: Docker Compose is bundled with Docker Desktop. If you're using a different installation, follow the instructions at Docker Compose Installation.
  3. Verify Installation: Open a terminal and check the installation by running:
    docker --version
    docker-compose --version
  4. Start Docker: Launch Docker Desktop to start the Docker engine.

Managing Services

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:

Screenshot 2024-09-15 at 17 43 44
Screenshot 2024-09-15 at 17 45 46

Troubleshooting

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.yml file is correctly configured and all necessary environment variables are set.
  • Restart Docker: Sometimes, restarting Docker Desktop can resolve issues.

Introduction to Swagger

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.

Accessing Endpoints Using Swagger

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:

  1. Open the Swagger UI: Navigate to the URL where Swagger UI is hosted. This is typically served from the /api-docs path of your application. For example:
    http://localhost:3002/api-docs
  2. Screenshot 2024-09-15 at 18 00 18
  3. 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.
  4. 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.
  5. 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.

License

This project is licensed under the MIT License. See the LICENSE file for more details.

About

The project server uses a microservices architecture with NGINX as an API gateway, routing requests to independent services (auth, cashier, customer, admin), ensuring scalability, load balancing, and modular deployment.

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors