What is the better approach for integrating multiple APIs in a Spring Boot application, direct or indirect communication among API’s? [closed]

We are developing a backend system for an airline company using Spring Boot. Our project requires us to integrate data from multiple APIs to generate flight rosters. Here is the current structure of our project:

src/
└── main/
    └── java/com/su/FlightScheduler/
        ├── APIs/
        │   ├── CabinCrewAPI/
        │   ├── FlightAPI/
        │   ├── PassengerAPI/
        │   └── PilotAPI/
        ├── DTO/
        ├── Entity/
        ├── Repository/
        ├── Security/
        ├── Service/
        └── FlightSchedulerApplication.java

Each API (Cabin Crew, Flight, Passenger, and Pilot) has its own controllers and services to perform CRUD operations. Now, we need to design the Main System that integrates the functionalities of these APIs to generate comprehensive flight rosters.

We are uncertain about the best approach to integrate these APIs within our main system. We are considering two approaches:

  • Calling the endpoints of each API from the main system:
    The main system API would make HTTP requests to the endpoints of the other APIs to gather the necessary data.

  • Using direct service communication:
    The main system would directly invoke the service methods of the other APIs.

Which approach is generally recommended for such a scenario, and what are the best practices for implementing it? Are there other approaches we should consider? Any insights on maintaining modularity, performance, and ease of maintenance in such integrations would be highly appreciated.

Additional context:

  • Our main system needs to provide different views for the flight roster (tabular view, plane view, and extended view).
  • We are using Spring Boot for our application framework.

For now, we only completed the API’s aside from the main system API. So we actually did not wanted to start developing the main system before clearing this problem at our mind.

New contributor

Kağan Becel is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

1

If All your APIs run within the same container there is no reason to use HTTP calls for them to communicate. So, definitely, call them directly.

However, be mindful of transaction management. Lets say you have some API end-point lets call it Call-A. It is exposed as REST endpoint and has controller and underlying service. However, besides being exposed as an independent end-point you also need to call it internally from your other endpoint (let’s call it Call-B). Here comes the question if you want entire logic of Call-B including invoking logic of Call-A to be a single transaction or do you want invocation of Call-A to be a separate transaction just as if it was called from outside? If you want it to be a single transaction then within Call-B invoke Call-A using its service (or even lover level BL class method if it is a single method). Else if you want Call-A logic be handled as a separate transaction then call it on Controller level (or even use an HTTP call to simulate external invocation)

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật