An open API service indexing awesome lists of open source software.

https://github.com/ar-ecommerce-platform/config-server

Centralized configuration service
https://github.com/ar-ecommerce-platform/config-server

centralized-configuration config-server git-backed-config microservices spring-boot spring-cloud-config

Last synced: 3 months ago
JSON representation

Centralized configuration service

Awesome Lists containing this project

README

          

# ๐Ÿ› ๏ธ Config Server โ€“ E-commerce Backend

[![CI Status](https://github.com/ar-ecommerce-platform/config-server/actions/workflows/ci-config-server.yml/badge.svg)](https://github.com/ar-ecommerce-platform/config-server/actions/workflows/ci-config-server.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=ar-ecommerce-platform_config-server&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=ar-ecommerce-platform_config-server)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=ar-ecommerce-platform_config-server&metric=coverage)](https://sonarcloud.io/summary/new_code?id=ar-ecommerce-platform_config-server)
[![Snyk](https://snyk.io/test/github/ar-ecommerce-platform/config-server/badge.svg)](https://snyk.io/test/github/ar-ecommerce-platform/config-server)

Centralized configuration service for all microservices in the E-commerce backend. Fetches and distributes configuration properties from a remote Git repository.

---

## ๐Ÿ”ง Tech Stack

- **Java**
- **Spring Boot**
- **Spring Cloud Config Server**
- **Git (Remote Config Repo)**
- **Docker**

---

## ๐Ÿš€ Features

- ๐Ÿ“ฆ Centralized and externalized configuration for all microservices
- ๐Ÿ“‚ Supports multiple environments (`dev`, `prod`, etc.)
- ๐Ÿ”„ Dynamic reload (Spring Cloud Bus support on client-side)
- ๐Ÿ” Separation of sensitive values from application code
- ๐ŸŒ Git-backed storage for version-controlled configuration

---

## ๐Ÿงฑ Architecture Overview

The Config Server reads configuration files from a centralized Git repository and exposes them to all microservices at runtime. This allows consistent configuration management across environments.

๐Ÿ“ Config Repository: https://github.com/ar-ecommerce-platform/config-repo

๐Ÿ”— Config access URL pattern:
`http://localhost:8888/{application}/{profile}`

All services are configured to use this server via:
```yaml
spring:
config:
import: configserver:http://localhost:8888
```

---

## ๐Ÿงพ Example: Microservice application.yml
To connect your service to the Config Server, add the following to your application.yml:

```yaml
spring:
application:
name: inventory-service-dev # This must match the config file name in the config repo
config:
import: configserver:http://localhost:8888 # Tells Spring to fetch config from the Config Server
```
๐Ÿ“ Make sure your Config Server is running and points to the correct Git repo!

---

## ๐Ÿ“ Directory Structure

```
config-server/
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ main/
โ”‚ โ”‚ โ”œโ”€โ”€ java/com/ecommerce/ecommerce_config_server/
โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ EcommerceConfigServerApplication.java # Main Spring Boot app
โ”‚ โ”‚ โ””โ”€โ”€ resources/
โ”‚ โ”‚ โ”œโ”€โ”€ application.yml # Optional default Spring Boot properties
โ”‚ โ”‚ โ””โ”€โ”€ bootstrap.yml # Config Server bootstrap properties
โ”‚ โ”œโ”€โ”€ smoke/
โ”‚ โ”‚ โ””โ”€โ”€ java/com/ecommerce/ecommerce_config_server/
โ”‚ โ”‚ โ””โ”€โ”€ ConfigServerSmokeTest.java # Smoke test for Config Server
โ”‚ โ””โ”€โ”€ test/
โ”‚ โ”œโ”€โ”€ java/com/ecommerce/ecommerce_config_server/
โ”‚ โ”‚ โ””โ”€โ”€ EcommerceConfigServerApplicationTests.java # Unit & context load tests
โ”‚ โ””โ”€โ”€ resources/
โ”‚ โ”œโ”€โ”€ application-test.yml # Test profile config (Spring Boot 3 format)
โ”‚ โ””โ”€โ”€ config-repo/
โ”‚ โ””โ”€โ”€ application.yml # Local test repo content served by Config Server
โ”œโ”€โ”€ build.gradle
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ .github/
โ”‚ โ””โ”€โ”€ workflows/
โ”‚ โ””โ”€โ”€ ci-config-server.yml # CI workflow for Config Server
```

---

## โš™๏ธ Configuration

The server pulls all config files from a remote Git repository using the following setup:

```yaml
spring:
cloud:
config:
server:
git:
uri: https://github.com/ar-ecommerce-platform/config-repo
```

---

## ๐Ÿงช Testing Strategy

The `config-server` is validated with **smoke tests** to ensure reliable startup and connectivity.

### โœ… What We're Testing
- **Service Boot & Health** โ€“ Verifies the config server starts up and reports healthy status.
- **Git Integration** โ€“ Confirms that configs are pulled correctly from the remote Git repository.
- **Profile-Specific Resolution** โ€“ Checks that services receive the correct environment configs (e.g., `dev`, `prod`).
- **Fallback Behavior** โ€“ Ensures graceful responses for unknown profiles or services using global defaults.

### ๐Ÿง  Why This Matters
In production, configuration servers are a critical part of system startup. If they fail, services may boot with incorrect or missing properties. These tests simulate realistic interactions and edge cases to guarantee stability under normal and degraded conditions.

### โš™๏ธ How It's Done
- Uses **Testcontainers** to spin up a real Docker container of the config server.
- Sends real HTTP requests (via RestAssured) to endpoints like `/auth-service/dev`.
- Validates:
- That correct YAML files are resolved and merged.
- That the `/actuator/health` endpoint reports `UP` (smoke test).
- That default and global fallbacks are applied as expected.
---

## ๐Ÿ”— Main Project Page

For the main E-commerce backend platform repository and all related projects, visit:

https://github.com/ar-ecommerce-platform