- Java 21
- Docker and Docker compose installed
docker compose down
docker compose up -d --buildIn order to access the ConfigServer config registry, ONLY ONCE you need to do this:
ssh-keygen -t ed25519 -C "email", whereemailis your github email- Visit https://github.com/settings/keys
- Create new authentication key
- Copy key from location where you saved generated public key (default
~/.ssh/*.pub) - ssh -T [email protected]
Documentation from all services are aggregated at the Gateway service. So there is two ways:
- Open base url of the gateway service and append
/swagger-ui.html - Open base url of the desired service and append
/swagger-ui.html
Enjoy your Swagger endpoint documentation!
This project includes a full observability stack based on:
- Prometheus (metrics collection)
- Grafana (visualization)
- Spring Boot Actuator + Micrometer (metrics exposure)
| Service | URL |
|---|---|
| Prometheus | http://localhost:9090 |
| Grafana | http://localhost:3001 |
| Auth metrics | http://localhost:8083/actuator/prometheus |
login: admin
password: admin
- Go to Grafana
- Navigate to:
SettingsβData SourcesβAdd data source - Choose:
Prometheus - Set URL:
http://prometheus:9090 - Action: Click
Save & Test
| Metric | Description |
|---|---|
auth_login_success_total |
Successful logins |
auth_login_failure_total |
Failed logins (tagged by reason) |
auth_login_duration_seconds |
Login latency (histogram) |
auth_users_count |
Total users |
| Metric | Description |
|---|---|
gateway_requests_duration |
Request duration |
gateway_errors_total |
Gateway errors |
| Metric | Description |
|---|---|
app_errors_total |
Application errors (tagged by type) |
Tags:
type=bad_requesttype=internal_error
Metrics automatically provided by the framework:
http_server_requests_secondsjvm_memory_used_bytessystem_cpu_usagehikaricp_connections
rate(app_errors_total[1m])
rate(auth_login_failure_total[1m])
rate(auth_login_success_total[1m])
histogram_quantile(0.95, rate(auth_login_duration_seconds_bucket[5m]))
rate(http_server_requests_seconds_count[1m]) by (status)
Every running service writes logs to the shared volume which then being served by Loki to Grafana. Every log entry should have the correlationId that allows to connect log entries from multiple services into one request flow
Here is example log entry:
{
"message": "Request GET /api/test -> 200",
"correlationId": "abc-123",
"service": "api-gateway",
"level": "INFO"
}Example queries
{correlationId="abc-123"} #trace by correlationId
{service-name="api-gateway"} #trace by service logs
The AI module is implemented as a separate Python-based service located in the dedicated AI/ directory. Unlike the remaining backend components, which are implemented as Spring Boot microservices, the AI module focuses on machine learning inference and optimization algorithms.
Technologies:
- Python 3.12
- FastAPI
- Apache Kafka
- Pandas
- XGBoost
- Ant Colony Optimization (ACO)
The AI codebase follows a layered architecture:
AI/
βββ Domain/
β βββ Algorithms/
β βββ Resources/
β βββ Models/
β
βββ Execution/
β βββ Training/
β βββ Inference/
β
βββ Orchestration/
β βββ RequestManager
β βββ ConfigManager
β βββ Kafka Consumers
β βββ Kafka Producers
β βββ Event Mappers
β
βββ main.py
Contains business-oriented AI components:
- machine learning algorithms
- optimization algorithms
- model resources
- configuration files
Responsible for model execution:
- model loading
- inference pipelines
- forecasting logic
- route optimization execution
Responsible for integration with the microservice ecosystem:
- Kafka consumers
- Kafka producers
- request routing
- configuration management
- event mapping
The RequestManager acts as the central entry point responsible for dispatching requests to the appropriate AI model.
The electricity forecasting model predicts future household energy consumption based on historical readings.
The complete prediction flow is fully event-driven:
Data Ingestion Service
β
electricity.readings.raw
β
AI Service
β
predictions.generated
β
Decision Service
β
alerts.created
β
Notification Service
β
Reporting Service
The AI Service consumes raw electricity measurements from Kafka, performs inference using an XGBoost model and publishes prediction events back to Kafka.
Generated predictions are automatically evaluated by the Decision Service. High-risk predictions result in alert creation and notification generation.
The traffic forecasting module follows the same architectural pattern as electricity forecasting.
Traffic measurements are expected to be generated by the Data Ingestion Service and delivered through a dedicated Kafka topic.
Planned processing flow:
Data Ingestion Service
β
traffic.readings.raw
β
AI Service
β
traffic.predictions.generated
β
Decision Service
β
alerts.created
The AI Service consumes traffic sensor readings, generates traffic forecasts using an XGBoost model and publishes prediction events for further evaluation.
This approach simulates real-world smart city sensor infrastructure where measurements are continuously streamed into the platform.
The route optimization module solves the Vehicle Routing Problem (VRP).
It can be used by the frontend or an operator to calculate the optimal order of visiting incidents or service points. Unlike electricity and traffic forecasting, it is not based on continuous sensor streams, so it is exposed through a synchronous REST API.
The optimization process is executed directly inside the AI Service:
Client Request
β
AI Service
β
ACO Optimizer
β
Optimized Routes
The implementation uses an Ant Colony Optimization algorithm to calculate optimized delivery routes and transportation costs.
Example use cases:
- emergency response planning
- utility maintenance routing
- logistics optimization
- city service vehicle scheduling
GET /ai-service/healthExample response:
{
"status": "UP",
"service": "ai-service",
"models": [
"electricity",
"traffic",
"vrp"
]
}electricity.readings.raw
predictions.generated
traffic.readings.raw
traffic.predictions.generated
alerts.created
incidents.created
incidents.updated
The AI module integrates with the rest of the platform through Apache Kafka and supports an event-driven architecture for predictive analytics and alert generation.