Skip to content

wahajnintyeight/project-phoenix-v2

Repository files navigation

Project Phoenix V2

Project Phoenix V2 is a comprehensive solution designed to streamline operations and enhance functionality for modern web applications. With a focus on scalability and performance, this project aims to provide a robust framework for building and deploying services efficiently.

About This Version

The V1 of this project was developed using Node.js, focusing on providing a solid foundation for web applications. In this new iteration, Project Phoenix V2, I've transitioned to using Go. This move aims to offer better stability and a significant increase in performance, addressing the evolving needs of modern web services and applications.

Features

  • API Gateway Integration: Simplifies interaction between client applications and backend services through a unified entry point.
  • Scalable Architecture: Designed to support scaling operations, ensuring high availability and resilience.
  • Customizable Modules: Includes a set of modules that can be tailored to meet specific requirements, enhancing flexibility and efficiency.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Project Phoenix V2 Documentation

This document provides an overview of the LocationService component within Project Phoenix V2, including setup instructions, service architecture, and usage.

Service Overview

The LocationService is designed to manage geolocation tracking within Project Phoenix. It subscribes to specific topics through a message broker (RabbitMQ) to handle start and stop tracking events.

Architecture

The service is built on the Go-Micro framework, leveraging the power of microservices for scalable, distributed applications. RabbitMQ is used as the message broker for event-driven communication between services.

API Gateway Service

The API Gateway Service acts as the entry point for all client requests to the backend services. It routes requests to the appropriate service, handles sessions, and provides an additional layer of security through middleware.

Setting Up the API Gateway Service

Configure and run the API Gateway Service to manage incoming requests and route them to the correct backend services.

Configuration

Ensure RabbitMQ is running and accessible. Configure the .env file with the correct RabbitMQ connection parameters:

RABBITMQ_HOST=localhost
RABBITMQ_PORT=5672
RABBITMQ_USERNAME=user
RABBITMQ_PASSWORD=pass

Running the Service

Navigate to the project directory and execute:

go run main.go --service-name api-gateway --port 8981

Registering Routes and Middleware

The API Gateway Service uses the Gorilla Mux router to define HTTP routes. Middleware can be applied to routes for session management, authentication, and logging.

Example Route Registration

api.router.HandleFunc("/api/path", handlerFunction).Methods("GET")

Middleware is applied to routes to handle cross-cutting concerns:

api.router.Use(authMiddleware)

Service Communication

The API Gateway communicates with backend services through RabbitMQ for message-based communication, facilitating asynchronous processing and decoupling of services.

Docker Commands for API Gateway

To containerize the API Gateway Service, use the provided Docker commands to build images, run containers, and view logs.

Building Docker Images

docker build -t api-gateway .

Running the API Gateway Container

docker run -d -p 8981:8981 api-gateway

Key Features

  • Unified entry point for backend services, simplifying client interactions.
  • Session management capabilities to maintain user state across requests.
  • Modular middleware integration for authentication, logging, and request validation.
  • Flexible routing to support various backend services dynamically.

Setup and Configuration

Prerequisites

  • Go (1.x or later)
  • Docker (for RabbitMQ container)
  • RabbitMQ (standalone or via Docker)

Installation

Follow these steps to get the LocationService running:

  1. Clone the Project Phoenix repository: git clone https://github.com/wahajnintyeight/project-phoenix-v2.git
  2. Navigate to the project directory: cd project-phoenix-v2
  3. Build and run the service: go run main.go --service-name location-service --port 8982

Service Usage

The LocationService subscribes to 'start-tracking' and 'stop-tracking' topics. It processes incoming messages to manage tracking operations for users or devices.

Prerequisites

What things you need to install the software and how to install them:

  • Go (version 1.x or later)

Installing

A step-by-step series of examples that tell you how to get a development environment running:

  1. Clone the Repository git clone https://github.com/wahajnintyeight/project-phoenix-v2.git
  2. Navigate to the Project Directory cd project-phoenix-v2
  3. Run the Application go run main.go --service-name api-gateway --port 8981

Docker Commands

Below are some useful Docker commands for managing the containers associated with Project Phoenix V2.

Building and Running Containers

To build the Docker images and run the containers in detached mode, use the following command:

docker compose up --build -d

Stopping All Containers

To stop all running containers:

sudo docker stop $(sudo docker ps -a -q)

Removing All Containers

To remove all containers, ensuring you can rebuild and start fresh, use:

sudo docker rm $(sudo docker ps -a -q)

Viewing Logs of a Container

To follow the logs of a specific container, which is useful for debugging and monitoring the application's output:

sudo docker logs --follow containername

Other Useful Docker Commands

  • List All Containers: docker ps -a
  • List Running Containers: docker ps
  • Access Container Shell: docker exec -it containername /bin/sh
  • Build Docker Images: docker build -t imagename .
  • Removing Docker Images: docker rmi imagename
  • Viewing Docker Images: docker images

Running the Tests

Explain how to run the automated tests for this system:

go test ./...

Built With

  • Go - The programming language used
  • Docker - Containerization platform (optional)

About

This is the V2 of Project Phoenix written purely in Go.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published