ADR-015 - Frontend-Backend Communication
| Status | accepted |
|---|---|
| Date | 2025-04-14 |
| Decision Makers | Dardan Bujupaj (AX), Marc Gähwiler (AX) |
Context
As defined in ADR-006 - Application Architecture the frontend and backend of the Sunny Calculator Add-On will be two different applications. The frontend will be a pure web application (see ADR-008 - Frontend Architecture) whereas the backend will run in the Azure Cloud (see ADR-007 - Backend Architecture) .
We need to decide on a well defined communication protocol between the frontend and backend.
This will allow us to develop the two apps independently while ensuring seamless integration and data exchange.
Decision
We will use a RESTful API for communication between the frontend and backend. We will use JSON as the data format for the API.
API Specification
All endpoints will be documented using OpenAPI Specification. We will use the OpenAPI file that is automatically generated by FastAPI (/openapi.json). This specification can then be used to generate a client library for the frontend.
Authentication
We will authenticate the user using Griesser’s Azure API Management instance. This will keep the backend secure and ensure that only authorized users can access the data while also reducing the overall complexity of the backend itself.
Consequences
- Azure API Management needs to be configured correctly using the OpenAPI specification.
Alternatives
- GraphQL: Alternative to plain HTTP requests that allows for a more flexible API, where the client (frontend) can define the data it needs. As the needed data is well defined and the backend and frontend are developed in close collaboration the flexibility is not worth the additional complexity.
- Custom Authentication: Having a separate authentication service would make development easier/faster (no API Management configuration updates needed, when APIs change), but would also introduce additional complexity and potential security risks.