A comprehensive 3-tier enterprise application for managing dynamic forms with automatic versioning, schema evolution, and backward compatibility. Built with Spring Boot for financial services with strict audit and compliance requirements.
- Overview
- Key Features
- Tech Stack
- Architecture
- Prerequisites
- Quick Start
- Project Structure
- Running the Application
- API Documentation
- Testing
- Documentation
- Contributing
- License
This system enables organizations to manage complex order forms with:
- Dynamic field types (multi-valued fields, nested sub-forms, inline tables)
- Immutable versioning (every save creates a new version)
- Schema evolution (change form structure without data migration)
- Backward compatibility (historical data rendered with original schemas)
- Audit compliance (complete change history)
Use Case: Order management system where users create and modify orders with complex nested data structures, requiring full audit trails for regulatory compliance.
- โ Automatic versioning - Every save creates a new immutable version
- โ Version history - View and compare all versions of an order
- โ Work-in-progress tracking - Draft versions auto-saved separately
- โ Daily purge - Automatic cleanup of old WIP versions
- โ Dynamic schemas - Forms defined by JSON schemas stored in database
- โ Backward compatibility - Old data rendered with original schema
- โ No data migration - Schema changes don't require data updates
- โ Multi-version support - Multiple schema versions active simultaneously
- โ Dimensional table integration - Populate forms from legacy SQL tables
- โ Denormalized snapshots - Preserve data as it was at creation time
- โ Field mapping registry - Configure transformations declaratively
- โ Spring Security - HTTP Basic (demo mode) with role-based access
- โ Redis caching - High-performance schema and lookup caching
- โ Spring Batch - Scheduled purge jobs
- โ REST API - Full CRUD operations with OpenAPI documentation
- โ Comprehensive testing - Unit and integration tests with Testcontainers
- Java 17 (LTS)
- Spring Boot 3.2.2
- Spring Data MongoDB - JSON document storage
- Spring Data JPA - Schema and dimensional table management
- Spring Security 6 - Authentication and authorization
- Spring Batch 5 - Scheduled purge jobs
- Spring Cache - Redis caching layer
- MongoDB 7+ - Versioned order documents
- PostgreSQL 15+ - Form schemas and dimensional tables
- Redis 7+ - Caching layer
- Maven 3.9+ - Build and dependency management
- JUnit 5 - Unit testing
- Mockito - Mocking framework
- Testcontainers - Integration testing
- Lombok - Reduce boilerplate
- MapStruct - Object mapping
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ PRESENTATION LAYER (React) โ
โ Dynamic Form Renderer | Version Viewerโ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโ
โ REST API
โโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโ
โ SERVICE LAYER (Spring Boot) โ
โ Version Orchestration | Schema Mgmt โ
โ Validation | Transformation | Purge โ
โโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโดโโโโโโโโโโโ
โผ โผ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
โ MongoDB โ โ PostgreSQL โ
โ (Orders) โ โ (Schemas) โ
โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ
For detailed architecture diagrams, see docs/ARCHITECTURE-DIAGRAM.md
# Check Java version
java -version
# Output: openjdk version "17.0.x" or "21.0.x"
# Check Maven version
mvn -version
# Output: Apache Maven 3.9.x
# Check Docker version
docker --version
# Output: Docker version 24.x or highergit clone https://github.com/your-org/dynamic-form-system.git
cd dynamic-form-system# Start MongoDB
docker run -d \
--name mongodb \
-p 27017:27017 \
mongo:7
# Start PostgreSQL
docker run -d \
--name postgres \
-p 5432:5432 \
-e POSTGRES_DB=form_schema \
-e POSTGRES_USER=postgres \
-e POSTGRES_PASSWORD=postgres \
postgres:15
# Start Redis
docker run -d \
--name redis \
-p 6379:6379 \
redis:7
# Verify all containers are running
docker ps# Build all modules
mvn clean install
# Skip tests for faster build
mvn clean install -DskipTests# Run main service
cd form-service
mvn spring-boot:run
# Or run the JAR directly
java -jar target/form-service-1.0.0.jar# Check health endpoint
curl http://localhost:8080/api/actuator/health
# Expected output:
# {"status":"UP"}dynamic-form-system/
โโโ AGENTS.md # AI agent coding guidelines
โโโ README.md # This file
โโโ pom.xml # Parent Maven POM
โ
โโโ docs/ # Documentation
โ โโโ REQUIREMENTS.md # Business requirements
โ โโโ DATA-MODEL-DESIGN.md # Database design
โ โโโ ARCHITECTURE-DIAGRAM.md # Architecture diagrams
โ
โโโ form-common/ # Shared module
โ โโโ pom.xml
โ โโโ src/main/java/com/dynamicform/form/common/
โ โโโ dto/ # Data Transfer Objects
โ โโโ enums/ # Enums (OrderStatus, etc.)
โ โโโ exception/ # Custom exceptions
โ โโโ util/ # Utility classes
โ
โโโ form-service/ # Main application
โ โโโ pom.xml
โ โโโ src/
โ โโโ main/
โ โ โโโ java/com/dynamicform/form/
โ โ โ โโโ FormApplication.java # Main class
โ โ โ โโโ config/ # Configuration
โ โ โ โโโ controller/ # REST Controllers
โ โ โ โโโ service/ # Business Logic
โ โ โ โโโ repository/ # Data Access
โ โ โ โ โโโ mongo/
โ โ โ โ โโโ postgres/
โ โ โ โโโ entity/ # Domain entities
โ โ โ โ โโโ mongo/
โ โ โ โ โโโ postgres/
โ โ โ โโโ mapper/ # MapStruct mappers
โ โ โ โโโ security/ # Security components
โ โ โ โโโ exception/ # Exception handlers
โ โ โโโ resources/
โ โ โโโ application.yml
โ โ โโโ application-dev.yml
โ โ โโโ application-prod.yml
โ โโโ test/ # Tests
โ โโโ java/com/dynamicform/form/
โ
โโโ form-batch/ # Batch jobs
โโโ pom.xml
โโโ src/main/java/com/dynamicform/form/batch/
โโโ BatchApplication.java
โโโ config/ # Batch configuration
โโโ job/ # Purge job
# Terminal 1: Run main service
cd form-service
mvn spring-boot:run -Dspring-boot.run.profiles=dev
# Terminal 2: Run batch service (optional)
cd form-batch
mvn spring-boot:run
# Application will start on http://localhost:8080# Build production JAR
mvn clean package -Pprod
# Run with production profile
java -jar form-service/target/form-service-1.0.0.jar \
--spring.profiles.active=prod# Start all services
docker-compose up -d
# Stop all services
docker-compose downOnce the application is running, access interactive API documentation at:
http://localhost:8080/api/swagger-ui.html
# Create new order (auto-save as WIP)
POST /api/v1/orders
Content-Type: application/json
{
"orderId": "ORD-12345",
"deliveryLocations": ["Location A", "Location B"],
"data": { ... },
"finalSave": false
}
# Get latest version of order
GET /api/v1/orders/{orderId}
# Get all versions of order
GET /api/v1/orders/{orderId}/versions
# Get specific version
GET /api/v1/orders/{orderId}/versions/{versionNumber}# Get active schema
GET /api/v1/schemas/active
# Get schema by version
GET /api/v1/schemas/{formVersionId}
# Create new schema (Admin only)
POST /api/v1/schemas
# Activate schema version (Admin only)
PUT /api/v1/schemas/{formVersionId}/activateCreate Order Request:
curl -X POST http://localhost:8080/api/v1/orders \
-H "Content-Type: application/json" \
-u user:password \
-d '{
"orderId": "ORD-12345",
"deliveryLocations": ["New York", "Boston"],
"data": {
"deliveryCompany": {
"companyId": "DC-789",
"name": "FastShip Logistics"
},
"items": [
{
"itemNumber": "ITEM-001",
"itemName": "Widget A",
"quantity": 10,
"price": 25.50
}
]
},
"finalSave": false
}'Response:
{
"orderId": "ORD-12345",
"orderVersionNumber": 1,
"formVersionId": "v2.1.0",
"orderStatus": "WIP",
"userName": "admin@example.com",
"timestamp": "2026-02-11T10:30:00Z",
"isLatestVersion": true,
"data": { ... }
}# Run all tests with coverage
mvn clean test
# View coverage report
open target/site/jacoco/index.htmlmvn test -Dgroups=unitmvn test -Dgroups=integrationmvn test -Dtest=VersionOrchestrationServiceTest- โ Minimum 80% code coverage
- โ All public service methods must have unit tests
- โ Critical paths must have integration tests
- โ Use Testcontainers for real database testing
- REQUIREMENTS.md - Business requirements and functional specifications
- DATA-MODEL-DESIGN.md - Database design, entities, and data flows
- ARCHITECTURE-DIAGRAM.md - System architecture and component diagrams
- AGENTS.md - Coding standards and guidelines for AI agents
- Swagger/OpenAPI - http://localhost:8080/api/swagger-ui.html (when running)
- Actuator Endpoints - http://localhost:8080/api/actuator (when running)
If you are an AI coding agent (Cursor, Copilot, etc.), please read AGENTS.md for coding standards and conventions.
- Follow Spring Boot best practices
- Use Lombok to reduce boilerplate
- Constructor injection (not field injection)
- Write tests for all new features
- 80%+ code coverage required
<type>(<scope>): <subject>
<body>
<footer>
Types: feat, fix, docs, style, refactor, test, chore
Example:
feat(order): add version comparison endpoint
Implement REST endpoint to compare two versions of an order.
Returns field-level differences.
Closes #123
This project is proprietary software developed for Demo Organization.
Copyright ยฉ 2026 Demo Organization. All rights reserved.
Project Owner: Demo Owner
Email: admin@example.com
Interview Date: February 11, 2026, 7:00 PM
- Local API: http://localhost:8080/api
- Swagger UI: http://localhost:8080/api/swagger-ui.html
- Health Check: http://localhost:8080/api/actuator/health
- Metrics: http://localhost:8080/api/actuator/metrics
Modern React UI for the Dynamic Versioned Form Management System.
- Install dependencies:
cd form-ui
npm install- Start dev server:
npm run dev- Access at: http://localhost:5173
- Ensure backend is running at: http://localhost:8080
- Every save creates a new version (immutable)
- WIP versions are auto-saved drafts
- Committed versions are final and permanent
- Daily purge job keeps only latest WIP per order
- Form schemas are versioned separately from data
- Old data is always rendered with its original schema
- No data migration required when schema changes
- Multiple schema versions can coexist
- Redis caching for schemas and lookups
- MongoDB indexes on composite keys
- Lightweight version index for fast queries
- Connection pooling for all databases