API Overview
The communication layer of LibreApps Desktop ecosystem.
Overview
LibreApps Desktop's microservices communicate with each other and the frontend primarily through RESTful APIs. These APIs are designed to be consistent, secure, and easy to use.
Key Principles
- RESTful Design: We follow standard REST principles, using HTTP methods (GET, POST, PUT, DELETE) and status codes correctly.
- JSON Payloads: All data is exchanged in JSON format.
- Statelessness: Each request contains all the information needed to process it (e.g., the JWT for authentication).
- Versioning: We use versioning in the URL (e.g.,
/api/v1/users) to ensure backward compatibility. - Documentation: All APIs are documented using OpenAPI (Swagger).
API Gateway
The LibreApps Gateway acts as the central entry point for all external API requests. It handles:
- Routing: Directing requests to the correct microservice.
- Authentication: Validating the user's JWT.
- Rate Limiting: Protecting the backend from abuse.
- CORS: Managing cross-origin resource sharing.
Internal vs. External APIs
- External APIs: Exposed through the Gateway and used by LibreApps Desktop frontend.
- Internal APIs: Used for service-to-service communication within the backend network. These are often not accessible from the public internet.
Best Practices
- ✅ Do this: Use descriptive and consistent naming for your API endpoints.
- ✅ Do this: Provide clear and helpful error messages in the response body.
- ❌ Don't do this: Expose internal implementation details (e.g., database IDs) in your public APIs if possible.