Skip to content

This project demonstrates a Google Pub/Sub architecture using Node.js (Express),React, Spring Boot, and FastAPI๐Ÿš€. All services are containerized ๐Ÿณ and deployed on Google Cloud Run โ˜๏ธ. CI/CD is automated with GitHub Actions ๐Ÿค–. The system enables seamless message publishing and subscribing between services ๐Ÿ’ฌ๐Ÿ””๐Ÿ’ป.

Notifications You must be signed in to change notification settings

moshdev2213/lets-pubsub

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

15 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ฆ Google Pub/Sub Project

gcp_pub_sub

This project demonstrates a Google Pub/Sub integration using a small microservices architecture (note : may not include best-practices, built in order to learn googel-pub/sub service). It includes multiple services written in different languagesโ€”Node.js (Express), FastAPI, and Spring Bootโ€”all containerized and stored in Google Artifact Registry (GAR). Continuous integration and deployment (CI/CD) are handled via GitHub Actions.


๐Ÿ“œ Overview

The project contains the following services:

  1. Client Application (React)
  2. Order Service (Node.js - Express)
  3. Notification Service (Spring Boot)
  4. Billing Service (FastAPI)

๐ŸŒ Pub/Sub Architecture Flow:

  1. The Client App triggers a message to be published by invoking an endpoint in the Order Service.
  2. The Order Service (Node.js - Express) publishes the message to a Google Pub/Sub topic.
  3. Two services are subscribed to this topic:
    • Notification Service (Spring Boot)
    • Billing Service (FastAPI)

The two subscribers handle the messages by performing different actions based on the published data.


๐Ÿ› ๏ธ Services Details

Service Technology Description Deployed URL
Client App React Frontend application that triggers messages to be published. Client App
Order Service Node.js (Express) Handles requests from the client and publishes messages to Google Pub/Sub. Order Service
Notification Service Spring Boot Subscribes to the Google Pub/Sub topic and processes notification events. Notification Service
Billing Service FastAPI Subscribes to the Google Pub/Sub topic and handles billing-related events. Billing Service

โš™๏ธ Technologies Used

  • Google Cloud Pub/Sub: Message broker used to decouple services.
  • Google Artifact Registry (GAR): Container registry to store and manage Docker images.
  • Cloud Run: To deploy services in a serverless environment.
  • GitHub Actions: For CI/CD automation to deploy services.
  • Docker: To containerize the services.
  • React: Client-side user interface.
  • Node.js (Express): Backend for the order service.
  • Spring Boot: For the notification service.
  • FastAPI: For the billing service.

๐Ÿ“ Project Flow

  1. Client App: User interacts with the client app to trigger an event.

    • Endpoint: /publish (Express app)
  2. Order Service: Receives the event and publishes the message to a Google Pub/Sub topic.

  3. Google Pub/Sub: Distributes the message to two subscribers:

    • Notification Service (Spring Boot)
    • Billing Service (FastAPI)
  4. Notification Service: Processes notification messages and logs to Google Cloud Logger.

  5. Billing Service: Handles billing-related messages and logs to Google Cloud Logger.


๐Ÿš€ Deployment Details

The project is fully containerized using Docker, and CI/CD pipelines are set up using GitHub Actions to automate deployment to Google Cloud Run. Here's a brief outline of the steps:

  1. Commit Changes: Push your local commits to GitHub.
  2. GitHub Actions: Detects changes and triggers the pipeline.
  3. Containerization: Each service is containerized using Docker.
  4. Artifact Registry: Docker images are pushed to Google Artifact Registry.
  5. Cloud Run: Services are deployed to Google Cloud Run.
  6. IAM & Permissions: Managed via Google Cloud IAM for secure access and deployments.

๐Ÿ› ๏ธ How to Run Locally

To run the services locally, make sure you have the following tools installed:

  1. Docker
  2. Node.js (for the Order Service)
  3. Python (for the Billing Service)
  4. Java (for the Notification Service)
  5. React (for the Client App)

Steps:

  1. Clone the repository.
  2. Build the Docker images for each service (includes build--args):
    docker build -t client-app ./client
    docker build -t order-service ./order
    docker build -t notification-service ./notification
    docker build -t billing-service ./billing
  3. Run the services

๐Ÿ“Š Logs & Monitoring

All services are integrated with Google Cloud Logger for logging and monitoring. You can view logs by navigating to the Google Cloud Console under the Cloud Logger section.


๐Ÿ“‹ Pub/Sub Topic & Subscription

Topic Subscribers
order-topic Notification Service (Spring Boot), Billing Service (FastAPI)

Make sure the topic and subscriptions are correctly set up in Google Cloud Pub/Sub.


๐ŸŒ External Links

Service URL
Client App https://pubsub-client-850033850526.us-central1.run.app
Order Service https://pubsub-order-service-850033850526.us-central1.run.app
Notification Service https://pubsub-noti-service-850033850526.us-central1.run.app
Billing Service https://pubsub-billing-service-850033850526.us-central1.run.app

๐ŸŽฏ Conclusion

This project successfully demonstrates the power of Google Pub/Sub in a microservices architecture. Each service is built using a different technology stack and deployed serverlessly using Google Cloud Run. CI/CD pipelines with GitHub Actions ensure that the system remains robust and easily maintainable.

About

This project demonstrates a Google Pub/Sub architecture using Node.js (Express),React, Spring Boot, and FastAPI๐Ÿš€. All services are containerized ๐Ÿณ and deployed on Google Cloud Run โ˜๏ธ. CI/CD is automated with GitHub Actions ๐Ÿค–. The system enables seamless message publishing and subscribing between services ๐Ÿ’ฌ๐Ÿ””๐Ÿ’ป.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published