Sam123ben / IDP-Integrated-Developer-Platform

A user-friendly tool for real-time tracking of infrastructure release versions and environment health status. It checks the health of environments in real-time from the PostgreSQL database.
1 stars 0 forks source link

Consolidate Backend Services under a Single Entry Point and Port #6

Closed Sam123ben closed 2 days ago

Sam123ben commented 2 days ago

Epic: #5

Goal:
To streamline backend services by consolidating them under a single entry point at localhost:8080/api, with unified Swagger documentation for all endpoints. This setup will improve maintainability, reduce redundancy, and provide a cohesive API structure.


Description:

This issue focuses on consolidating backend services so they can be run from a single entry point at localhost:8080, accessed via /api. This includes the integration of a single Swagger documentation UI for all services and necessary refactoring to ensure maintainability, consistent naming, and modular route management.

Tasks:

  1. Unify Entry Point and Port:

    • Refactor main.go to host all backend services (Company, Infra Types, Internal Env Details) from a single entry point at localhost:8080.
    • Group all API routes under /api for a unified API structure.
  2. Swagger Documentation Integration:

    • Set up Swagger documentation for all services in a consolidated UI, accessible at localhost:8080/swagger.
    • Annotate handler functions in each service with Swagger documentation comments to provide clear descriptions, parameters, and response structures.
    • Ensure all endpoints from each service (Company, Infra Types, Internal Env Details) appear in the single Swagger UI for easy navigation and testing.
  3. Dynamic Product Validation:

    • Refactor the Internal Env Details service to dynamically fetch the list of valid products from the database.
    • Add a repository function to retrieve products and update handler logic for validation, replacing hardcoded lists.
  4. Standardize Repository Method Names:

    • Update the method Getcompany in the Company service repository to GetCompany to follow Go naming conventions and avoid case-sensitive issues.
  5. Centralized CORS and Middleware:

    • Implement centralized CORS and middleware configuration in main.go to handle cross-origin requests and reduce redundant configurations.
  6. Modularized Route Setup:

    • Create Setup*Routes functions for each service to keep routing logic modular and organized by service.

Acceptance Criteria:


Final Commit Message (linked to this issue)

Once this issue is complete, refer to the issue number in the commit:


feat: Consolidate backend services to run under a single entry point on port 8080

Resolves #[ISSUE_NUMBER]

- Refactored backend services to be accessible from a single `main.go` file
- Unified API entry point at `localhost:8080/api` for all services (Company, Infra Types, Internal Env Details)
- Integrated centralized CORS configuration and middleware in `main.go`
- Enabled consolidated Swagger documentation for all services at `/swagger`
- Added dynamic product validation in Internal Env Details service by fetching valid products from the database
- Refactored Company service repository method `Getcompany` to `GetCompany` for consistency
- Modularized route setup by adding dedicated `Setup*Routes` functions for each service

These changes consolidate the API structure, reduce redundancy, and improve maintainability while providing a single, accessible Swagger UI.
Sam123ben commented 2 days ago

The issue is closed.