A comprehensive Spring Boot microservices architecture for data visualization and analytics, providing REST APIs for dataset management, security, and integration with Apache Superset.
- Overview
- Architecture
- Modules
- Technology Stack
- Getting Started
- API Documentation
- Configuration
- Development
- Release
- Deployment
The Data Visualization API is a multi-module Spring Boot application designed to provide a scalable, secure platform for data visualization and analytics. It follows a microservices architecture with service discovery, API gateway, security layer, and business logic components.
More Documentation: Data VIZ Documentation
- Microservices Architecture: Modular design with independent, scalable services
- Service Discovery: Netflix Eureka for dynamic service registration and discovery
- API Gateway: Spring Cloud Gateway for routing and load balancing
- Security: JWT-based authentication and authorization
- Data Management: Generic dataset handling with CSV import/export capabilities
- Caching: Redis and Caffeine-based caching for performance optimization
- Superset Integration: Proxy service for Apache Superset integration
- Multi-dimensional Analysis: Support for dimensions, measures, and filters
- RESTful APIs: Comprehensive REST endpoints for all operations
┌─────────────────────────────────────────────────────────────┐
│ Client Applications │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ API Gateway (Port 8080) │
│ Spring Cloud Gateway + Caffeine Cache │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Service Registry (Eureka) │
│ Port 8761 │
└─────────────────────────────────────────────────────────────┘
│
┌───────────────┼───────────────┐
▼ ▼ ▼
┌─────────────┐ ┌──────────────┐ ┌────────────────┐
│ API Security│ │Superset Proxy│ │Business Services│
│ Service │ │ Service │ │ (with Commons)│
└─────────────┘ └──────────────┘ └────────────────┘
│ │ │
└───────────────┼───────────────┘
▼
┌──────────────────┐
│ PostgreSQL DB │
└──────────────────┘
The core module containing shared business logic, domain models, services, and utilities.
Key Components:
- Domain Models: Dataset, Category, Job, DimensionDefinition, MeasureDefinition, FilterDefinition
- Services:
DatasetService: Dataset CRUD operations and managementDatasetRecordService: Generic record handlingCategoryService: Category managementDimensionDefinitionService: Dimension metadata managementMeasureDefinitionService: Measure metadata managementFilterDefinitionService: Filter metadata managementJobService: Asynchronous job processingGenericConfigService: Configuration management
- Controllers:
BaseStatsController: Generic statistics endpointsAdminDatasetsController: Dataset adminAdminCategoriesController: Category adminAdminDimensionsController: Dimension adminiAdminMeasuresController: Measure adminJobsController: Job status monitoring
- CSV Import/Export:
BaseCSVImporterfor data import functionality - Observer Pattern: Dataset change notification system
Technologies:
- Spring Boot 3.2.10
- Spring Data JPA with QueryDSL
- Liquibase for database migrations
- OpenCSV for CSV processing
- PostgreSQL
Spring Cloud Gateway providing routing, load balancing, and caching.
Key Features:
- Dynamic service routing via Eureka service discovery
- Caffeine-based response caching (60-minute TTL)
- Request/response filtering
- Gateway-level security headers
Configuration:
- Port: 8080
- Cache expiration: 60 minutes
- Eureka integration: Enabled with lowercase service IDs
Dependencies:
- Spring Cloud Gateway
- Spring Cloud Netflix Eureka Client
- Caffeine Cache
Authentication and authorization service providing JWT-based security.
Key Components:
LoginController: Authentication endpointsLoginService: User authentication logic- Spring Security configuration
- JWT token generation and validation
- PostgreSQL-backed user management
API Endpoints:
POST /gateway/signin: User authentication
Technologies:
- Spring Security
- JWT (JSON Web Tokens)
- Spring Data JPA
- PostgreSQL
Netflix Eureka service registry for microservices discovery.
Key Features:
- Service registration and health monitoring
- Service discovery for inter-service communication
- High availability support
- Dashboard UI
Configuration:
- Port: 8761
- Spring Boot 3.4.0
- Netflix Eureka Server 4.1.3
Proxy service for Apache Superset integration with caching and data transformation.
Key Components:
SupersetController: REST endpoints for Superset dataSupersetProxyService: Business logic for Superset integration- Redis-based caching (production)
- Custom key generation for cache optimization
API Endpoints:
GET /status: Health checkGET /charts: Retrieve available chartsGET /datasets: Get datasetsGET /dimensions: Get dimension definitionsGET /measures: Get measure definitionsGET /filters: Get filter definitionsGET /categories: Get categoriesGET /categories/{categoryType}: Get specific category typeGET /stats: Statistics endpointGET /warmUp: Cache warm-upGET /cacheEvict: Cache invalidation
Technologies:
- Spring Boot 3.2.12
- Redis (production profile)
- Spring Cloud Netflix Eureka Client
- Spring Cache
- Java: 21 (LTS)
- Spring Boot: 3.2.x - 3.4.0
- Spring Cloud: 2023.0.3 - 2024.0.0
- Maven: 3.8.9+ for build automation
- PostgreSQL: Primary database
- Liquibase: Database version control (4.29.0)
- Spring Data JPA: Data access layer
- QueryDSL: Type-safe query construction (5.1.0)
- Netflix Eureka: Service registry and discovery (4.1.3)
- Spring Cloud Gateway: API gateway and routing
- Spring Cloud Netflix: Microservices patterns
- Caffeine: In-memory caching
- Redis: Distributed caching (production)
- Spring Cache: Cache abstraction
- Spring Security: Authentication and authorization
- JWT: Token-based authentication
- SpringDoc OpenAPI: API documentation (2.6.0)
- Swagger UI: Interactive API explorer (1.8.0)
- OpenCSV: CSV file processing (5.9)
- Apache Commons Text: String utilities (1.12.0)
- Google Cloud Translate: Translation services (26.43.0)
- Jackson: JSON processing
- Maven Compiler Plugin: Java 21 compilation (3.11.0)
- Spring Boot Maven Plugin: Application packaging
- Maven Checkstyle Plugin: Code quality (3.5.0)
- Java Development Kit (JDK): 21 or higher
- Maven: 3.8.9 or higher
- PostgreSQL: 12 or higher
- Redis: 6 or higher (for production)
- Docker (optional): For containerized deployment
-
Clone the repository:
git clone git@github.com/devgateway/data-viz-api.git cd data-viz-api -
Update Configuration Files:
Update application properties with your database credentials:
api-security/src/main/resources/application.propertiescommons/src/main/resources/common.properties
-
Build the Project:
mvn clean install
-
Start Eureka Registry:
cd registry mvn spring-boot:runAccess at: http://localhost:8761
-
Start API Security:
cd api-security mvn spring-boot:run -
Start Superset Proxy:
cd superset-proxy mvn spring-boot:run -
Start API Gateway:
cd api-gateway mvn spring-boot:runAccess at: http://localhost:8080
docker compose up -d- Check Eureka Dashboard: http://localhost:8761
- Verify all services are registered
- Test gateway endpoint: http://localhost:8080/actuator/health
- API Gateway:
http://localhost:8080 - Eureka Dashboard:
http://localhost:8761
All API requests (except /gateway/signin) require JWT authentication:
# Login
curl -X POST http://localhost:8080/gateway/signin \
-d "username=admin&password=admin123"
# Use returned token in subsequent requests
curl -H "Authorization: Bearer <token>" \
http://localhost:8080/admin/datasetsGET /admin/datasets- List all datasetsGET /admin/datasets/{code}- Get dataset by codePOST /admin/datasets- Create new datasetPUT /admin/datasets/{code}- Update datasetDELETE /admin/datasets/{code}- Delete datasetGET /admin/datasets/{code}/download- Download dataset file
GET /admin/categories- List categoriesGET /admin/categories/{id}- Get category by IDPUT /admin/categories/{id}- Update categoryDELETE /admin/categories/{id}- Delete category
GET /admin/dimensions- List dimensionsGET /admin/dimensions/{id}- Get dimension by IDPUT /admin/dimensions/{id}- Update dimension
GET /admin/measures- List measuresGET /admin/measures/{id}- Get measure by IDPUT /admin/measures/{id}- Update measure
GET /admin/jobs/{id}- Get job status by IDGET /admin/jobs/code/{code}- Get job by code
GET /categories- Get all categoriesGET /stats- Get statisticsGET /stats/**- Get statistics with dimensionsGET /dimensions- Get dimension definitionsGET /filters- Get filter definitionsGET /measures- Get measure definitions
GET /charts- Get Superset chartsGET /datasets- Get Superset datasetsGET /dimensions?dvzProxyDatasetId={id}- Get dimensions for datasetGET /measures?dvzProxyDatasetId={id}- Get measures for datasetGET /filters?dvzProxyDatasetId={id}- Get filters for datasetGET /categories?dvzProxyDatasetId={id}- Get categories for dataset
GET /cacheEvict- Evict all cachesGET /warmUp- Warm up caches
Once the application is running, access interactive API documentation at:
- Swagger UI:
http://localhost:8080/swagger-ui.html - OpenAPI JSON:
http://localhost:8080/v3/api-docs
spring:
application:
name: api-gateway
server:
port: 8080
eureka:
client:
serviceUrl:
defaultZone: http://eureka:8761/eurekaspring.application.name=api-security
spring.datasource.url=jdbc:postgresql://localhost:5432/dataviz_security
spring.datasource.username=postgres
spring.datasource.password=your_password
spring.jpa.hibernate.ddl-auto=updateviz.initial.config=true # Enable initial configuration setup
viz.startup.import=false # Enable automatic import on startup
viz.import.directory=/data/import # Import directory path
viz.date.format=yyyy-MM-dd # Date format for imports- Development Profile: Uses in-memory cache, verbose logging
- Activate:
--spring.profiles.active=dev
- Activate:
- Production Profile: Uses Redis cache, optimized logging
- Activate:
--spring.profiles.active=prod
- Activate:
This project uses Gitleaks to prevent secrets from being accidentally committed. Install the pre-commit hook after cloning:
pip install pre-commit
pre-commit installAfter installation, every git commit will automatically scan staged files for secrets.
data-viz-api/
├── api-gateway/ # API Gateway module
│ ├── src/main/
│ │ ├── java/
│ │ └── resources/
│ └── pom.xml
├── api-security/ # Security module
│ ├── src/main/
│ └── pom.xml
├── commons/ # Shared business logic
│ ├── src/main/
│ │ ├── java/
│ │ │ └── org/devgateway/viz/commons/
│ │ │ ├── boot/ # Application bootstrap
│ │ │ ├── controllers/ # REST controllers
│ │ │ ├── domain/ # Domain models
│ │ │ ├── io/ # Import/Export
│ │ │ ├── observers/ # Event observers
│ │ │ ├── pojo/ # DTOs
│ │ │ ├── repositories/ # Data repositories
│ │ │ └── services/ # Business services
│ │ └── resources/
│ └── pom.xml
├── registry/ # Eureka service registry
│ ├── src/main/
│ └── pom.xml
├── superset-proxy/ # Superset integration
│ ├── src/main/
│ └── pom.xml
└── pom.xml # Parent POM
# Build entire project
mvn clean install
# Build specific module
cd commons
mvn clean install
# Skip tests
mvn clean install -DskipTests
# Run specific service
cd api-gateway
mvn spring-boot:runCode quality is enforced using Maven Checkstyle Plugin (currently disabled in config):
mvn checkstyle:check# Run all tests
mvn test
# Run tests for specific module
cd commons
mvn testLiquibase is used for database version control. Changelog files are located in:
src/main/resources/db/changelog/
To run migrations manually:
mvn liquibase:update- Create new Maven module in parent POM
- Add dependencies to Eureka Client
- Implement
@SpringBootApplicationclass with@EnableDiscoveryClient - Configure
application.ymlwith service name and Eureka URL - Build and run
See RELEASE.md
Each module includes a Dockerfile for containerization.
# Build all images
docker compose build
# Build specific service
docker build -t dataviz-api-gateway ./api-gatewayversion: '3.8'
services:
eureka:
build: ./registry
ports:
- "8761:8761"
postgres:
image: postgres:14
environment:
POSTGRES_DB: dataviz_main
POSTGRES_USER: postgres
POSTGRES_PASSWORD: password
api-gateway:
build: ./api-gateway
depends_on:
- eureka
ports:
- "8080:8080"
api-security:
build: ./api-security
depends_on:
- eureka
- postgresdocker compose up -d-
Environment Configuration:
- Set production database credentials
- Configure Redis for caching
- Enable HTTPS/TLS
- Set appropriate log levels
-
Health Checks: All services expose Spring Actuator endpoints:
/actuator/health- Service health/actuator/info- Service information/actuator/metrics- Service metrics
-
Monitoring:
- Use Spring Boot Admin for centralized monitoring
- Configure Prometheus for metrics collection
- Set up Grafana dashboards
This project is developed by Development Gateway licensed under Apache-2.0 license
For questions or contributions, please contact the Development Gateway team.