Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Employee Address Microservices

Overview

Employee Address Microservices is a Spring Boot-based project that demonstrates communication between two independent microservices using RestTemplate.

The project consists of:

  • Employee Service
  • Address Service

The Employee Service retrieves employee details from its database and fetches the corresponding address from the Address Service using REST API communication.


Project Architecture

                    Client
                       |
                       |
          GET /api/v1/emp/{id}
                       |
               Employee Service
                  Port : 9991
                       |
         RestTemplate HTTP Call
                       |
                       V
               Address Service
                  Port : 9992
                       |
                    MySQL

Technologies Used

  • Java 21
  • Spring Boot
  • Spring Data JPA
  • Hibernate
  • RestTemplate
  • ModelMapper
  • MySQL
  • Maven
  • Lombok

Microservices

Employee Service

Port

9991

Responsibilities

  • Fetch employee details
  • Communicate with Address Service
  • Return combined Employee + Address response

Address Service

Port

9992

Responsibilities

  • Fetch address information
  • Return Address DTO

Database

MySQL

Employee Table

emp71

Address Table

address70

REST APIs

Employee Service

Get All Employees

GET /api/v1/getAll

Get Employee By Id

GET /api/v1/emp/{id}

Example

GET http://localhost:9991/api/v1/emp/1

Response

{
    "id":1,
    "name":"John",
    "email":"john@gmail.com",
    "age":24,
    "addressResponse":{
        "id":1,
        "city":"Hyderabad",
        "state":"Telangana"
    }
}

Address Service

Get Address By Employee Id

GET /api/v1/add/{id}

Example

GET http://localhost:9992/api/v1/add/1

Response

{
    "id":1,
    "city":"Hyderabad",
    "state":"Telangana"
}

Features

  • Spring Boot REST APIs
  • Microservices Architecture
  • Service-to-Service Communication
  • RestTemplate Integration
  • ModelMapper for DTO Mapping
  • Spring Data JPA
  • Native SQL Query
  • MySQL Database
  • Maven Build
  • Clean Layered Architecture

Project Structure

Employee-Address-Microservices
│
├── employeeservice
│   ├── Controller
│   ├── Service
│   ├── Repository
│   ├── Entity
│   ├── Response DTO
│   └── Configuration
│
├── addressservice
│   ├── Controller
│   ├── Service
│   ├── Repository
│   ├── Entity
│   ├── Response DTO
│   └── Configuration
│
└── README.md

How to Run

Clone Repository

git clone https://github.com/venky4378/Employee-Address-Microservices.git

Configure MySQL

Update the following in application.properties

spring.datasource.url
spring.datasource.username
spring.datasource.password

Run Address Service

localhost:9992

Run Employee Service

localhost:9991

Test APIs

Use

  • Browser
  • Postman

Future Enhancements

  • Spring Cloud Eureka Server
  • API Gateway
  • Config Server
  • OpenFeign
  • Spring Security + JWT
  • Docker
  • Swagger/OpenAPI
  • Circuit Breaker (Resilience4j)

Author

Swamy Ch

GitHub

https://github.com/venky4378

LinkedIn

https://www.linkedin.com/in/swamy-ch/

About

Employee and Address Microservices using Spring Boot, Spring Data JPA, RestTemplate, ModelMapper, MySQL, and Maven. Demonstrates inter-service communication in a simple microservices architecture.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages