Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Payment System Microservice Project

This project is a microservice-based payment system developed using Spring Boot and Spring Cloud. It aims to demonstrate modern cloud-native application patterns such as service discovery, an API gateway, and asynchronous communication in distributed systems.

Services in the Architecture

The project consists of four main services, each responsible for a specific function:

1. Eureka Server (eureka-server)

This is where all microservices in the system register and discover each other. Other services register with Eureka to announce their network location (IP address and port), allowing them to communicate with each other dynamically. In short, it acts as the system's phone book.

2. Gateway Service (gateway-service)

It is the single point of entry for all client requests. It routes incoming requests to the appropriate microservice. It also manages cross-cutting concerns like authentication. When a user logs in, it generates a JWT (JSON Web Token) and secures requests to other services with this token.

3. User Service (user-service)

Manages all responsibilities related to user operations. It handles tasks such as creating new user registrations and verifying the credentials of existing users. When a new user is created, it notifies other services (e.g., account-service) via RabbitMQ.

4. Account Service (account-service)

Manages all operations related to user accounts, balances, and financial transactions. When it receives a notification from RabbitMQ that a new user has been created, it automatically opens an account for that user. It handles operations like deposits, withdrawals, and balance inquiries.


How to Run the Project

You can follow the steps below to run the project on your local machine:

  1. Start the Eureka Server: First, start the eureka-server application. It needs to be running before all other services can connect to it.

  2. Start the Other Services: Next, start the user-service, account-service, and gateway-service applications in any order.

  3. Access: Once all services have started successfully, the system will be accessible through the gateway-service (by default at http://localhost:8080).


Required Configurations (application.yml)

This project excludes application.yml files from version control using .gitignore. To run the project, you need to create an application.yml file in the src/main/resources directory of each service with the content specified below.

Eureka Server Configuration

File Path: eureka-server/src/main/resources/application.yml

server:
  port: 8761

eureka:
  client:
    register-with-eureka: false
    fetch-registry: false

Gateway Service Configuration

File Path: gateway-service/src/main/resources/application.yml

Note: The jwt.secret value here must be the same as the value in the other services.

server:
  port: 8080

spring:
  application:
    name: gateway-service
  cloud:
    gateway:
      routes:
        - id: user-service-register-route
          uri: lb://user-service
          predicates:
            - Path=/api/auth/register
          filters:
            - StripPrefix=2
        - id: account-service-route
          uri: lb://account-service
          predicates:
            - Path=/api/account/**
          filters:
            - name: AuthenticationFilter
            - StripPrefix=1

jwt:
  secret: MCZNZmpEWS13Olp4LS5bIypxYmozViRnQ3kvQlovKU0=

User Service Configuration

File Path: user-service/src/main/resources/application.yml

Note: Don't forget to update the url, username, and password fields under spring.datasource according to your own PostgreSQL database configuration.

spring:
  application:
    name: user-service
  profiles:
    active: dev
  rabbitmq:
    host: localhost
    port: 5672
    username: guest
    password: guest
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect
  datasource:
    url: jdbc:postgresql://localhost:5433/user_db
    username: postgres
    password: your_db_password # Enter your own password
    driver-class-name: org.postgresql.Driver

server:
  port: 8081

rabbitmq:
  queue:
    user-created: user-created-queue

eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/
  instance:
    prefer-ip-address: true

Account Service Configuration

File Path: account-service/src/main/resources/application.yml

Note: Don't forget to update the url, username, and password fields under spring.datasource according to your own PostgreSQL database configuration. The jwt.secret value must be the same as in the gateway-service.

spring:
  application:
    name: account-service
  profiles:
    active: dev
  rabbitmq:
    host: localhost
    port: 5672
    username: guest
    password: guest
  jpa:
    hibernate:
      ddl-auto: update
    show-sql: true
    properties:
      hibernate:
        dialect: org.hibernate.dialect.PostgreSQLDialect
  datasource:
    url: jdbc:postgresql://localhost:5433/account_db
    username: postgres
    password: your_db_password # Enter your own password
    driver-class-name: org.postgresql.Driver

jwt:
  secret: MCZNZmpEWS13Olp4LS5bIypxYmozViRnQ3kvQlovKU0=

server:
  port: 8082

rabbitmq:
  queue:
    user-created: user-created-queue

eureka:
  client:
    service-url:
      defaultZone: http://localhost:8761/eureka/
  instance:
    preferIpAddress: true

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages