This is a pragmatically modernized version of the Todo application, demonstrating a "just enough" approach to containerization that minimizes changes while enabling cloud deployment. This approach mirrors real-world enterprise scenarios where complete rewrites are often impractical, and incremental modernization is preferred.
- Create, read, update, and delete todo items
- Filter todos by status (All, Active, Completed)
- Sort by creation date (Newest First, Oldest First)
- Track creation and completion timestamps for todos
- Responsive web interface
- Health check endpoint for monitoring
- Container-native design
- Technical overview page
- Podman or Docker
- curl (for health checks)
../run.sh container start
The application will be available at: http://localhost:18080/todo Health check endpoint: http://localhost:18080/todo/health
../run.sh container debug
Then in VS Code:
- Set breakpoints in your code
- Select "Debug Containerized Todo" configuration
- Press F5
This version demonstrates a pragmatic approach to containerization that:
- Minimizes code changes while enabling cloud deployment
- Preserves existing application architecture
- Focuses on infrastructure modernization over application modernization
- Balances modernization benefits with risk and effort
- Replaced file storage with PostgreSQL
- Removed local caching in favor of stateless design
- Moved configuration to environment variables
- Updated logging for container compatibility
- Added health monitoring
- Servlet/JSP Architecture: Maintained traditional Java web application structure
- Tomcat Server: Kept the familiar servlet container
- JSP Views: Preserved JSP-based views
- Traditional Build Process: Maintained Maven-based build
- Basic Error Handling: Kept simple error handling
- Simple Authentication: Maintained basic security
- Framework: Migration to Spring Boot for modern dependency injection
- Frontend: Adoption of React/Vue.js for a more dynamic UI
- API Design: Implementation of OpenAPI/Swagger for documentation
- Testing: Comprehensive test coverage with modern frameworks
- Security: Implementation of OAuth2/JWT for authentication
- Monitoring: Addition of Prometheus/Grafana for metrics
- CI/CD: Implementation of modern CI/CD pipelines
- Build Tools: Adoption of Gradle or modern build systems
Client Layer (Browser)
│
▼
Presentation Layer (JSP)
│ - index.jsp: Main UI
│ - error.jsp: Error handling
│ - about.jsp: Technical overview
│
▼
Controller Layer (Servlets)
│ - TodoServlet: Handles CRUD operations
│ - HealthCheckServlet: Application health monitoring
│
▼
Service Layer
│ - TodoStorage: PostgreSQL-based storage service
│
▼
Model Layer
│ - Todo: Data model for todo items
│
▼
Storage Layer
│ - PostgreSQL Database (Containerized)
- Database-Driven Storage: PostgreSQL replaces file-based storage with proper transaction management and scalability
- Stateless Architecture: Container-ready design with horizontal scalability
- Container Configuration: Environment variables for configuration with no hardcoded values
- Modern Logging: Container-native logging with structured formats for aggregation
- Code Quality: Consistent styling with automated validation
- Runtime: Java 17, Tomcat 9
- Database: PostgreSQL 16
- Build: Maven 3.9
- Dependencies: Servlet API 3.1.0, PostgreSQL JDBC 42.7.2, HikariCP 5.1.0, Jackson 2.15.3, SLF4J/Logback
The application uses the following environment variables:
DB_HOST
: PostgreSQL host (default: postgres)DB_PORT
: PostgreSQL port (default: 5432)DB_NAME
: Database name (default: todo)DB_USER
: Database user (default: todo)DB_PASSWORD
: Database password (default: todo)DB_POOL_SIZE
: Connection pool size (default: 10)DB_POOL_TIMEOUT
: Connection timeout in ms (default: 30000)HEALTH_CHECK_INTERVAL
: Health check interval in ms (default: 60000)
Note: The config.properties file in the resources directory contains legacy settings that aren't used in the containerized version. The application now uses environment variables for all configuration.
after-container/
├── src/
│ └── main/
│ ├── java/ # Java source files
│ ├── resources/ # Configuration files
│ └── webapp/ # Web resources and JSP pages
├── podman/ # Container configuration
│ ├── tomcat/ # Tomcat configuration
│ └── postgres/ # PostgreSQL configuration
├── podman-compose.yml # Container orchestration
└── pom.xml # Maven configuration
For future versions, we plan to implement:
-
Enhanced connection pooling with configurable parameters:
DB_POOL_SIZE
: Connection pool sizeDB_POOL_TIMEOUT
: Connection timeout in milliseconds
-
Advanced health checking with configurable intervals:
HEALTH_CHECK_INTERVAL
: Health check interval in milliseconds
-
Transaction management with configurable isolation levels