This document describes the migration from the Python Flask backend to the Java Spring Boot backend.
The original Python Flask application (app.py) has been fully converted to a Java Spring Boot application located in the aushadham-backend directory.
- Python Flask → Java Spring Boot 3.1.5
- Port: 5000 (unchanged)
- All REST endpoints maintained
- Session management using
ConcurrentHashMap
Original Python:
app.py
requirements.txt
New Java:
aushadham-backend/
├── pom.xml # Maven configuration
├── src/
│ ├── main/
│ │ ├── java/com/aushadham/
│ │ │ ├── App.java # Main application
│ │ │ ├── config/ # CORS and questionnaire templates
│ │ │ ├── controller/ # REST API endpoints
│ │ │ ├── dto/ # Request/Response objects
│ │ │ ├── model/ # Domain models
│ │ │ └── service/ # Business logic
│ │ └── resources/
│ │ └── application.properties
│ └── test/
│ └── java/com/aushadham/ # Unit tests
└── README.md
All endpoints from the Flask application have been replicated:
| Endpoint | Method | Description |
|---|---|---|
/ |
GET | API information |
/start_questionnaire |
POST | Start new questionnaire |
/submit_answer |
POST | Submit answer and navigate |
/get_current_question |
POST | Get current question |
/get_report |
POST | Generate final report |
/health_check |
GET | Health status |
✅ All questionnaire templates (stomach, headache, fever, cough)
✅ Conditional question logic
✅ Risk score calculation
✅ Report generation with recommendations
✅ Session management
✅ CORS support
✅ Medical recommendations and medications
- Python: In-memory dictionary
- Java: ConcurrentHashMap for thread-safety
- Python: Dynamic typing
- Java: Static typing with model classes
- Python: requirements.txt with pip
- Java: pom.xml with Maven
cd aushadham-backend
mvn clean packagejava -jar target/aushadham-backend-1.0-SNAPSHOT.jarOr use Maven:
mvn spring-boot:runThe Java backend has been tested to ensure:
- All endpoints work correctly
- Question flow matches Python version
- Conditional questions trigger properly
- Report generation produces same structure
- Session management is thread-safe
- No security vulnerabilities (CodeQL verified)
The Java backend maintains 100% API compatibility with the Python version. The frontend HTML file (index.html) works with both backends without any modifications.
Simply change the API_BASE_URL in index.html to point to the Java backend:
const API_BASE_URL = 'http://localhost:5000'; // Java backend- Type Safety: Compile-time type checking prevents runtime errors
- Performance: Better performance for concurrent requests
- Scalability: Built-in support for enterprise features
- Maintenance: Strongly typed code is easier to maintain
- Security: CodeQL analysis shows zero vulnerabilities
- Testing: Comprehensive test framework with JUnit 5
- Deployment: Single JAR file for easy deployment
- Run the Java backend instead of Python
- Keep the existing HTML frontend unchanged
- Use the same API endpoints
- Build the JAR file:
mvn clean package - Deploy the JAR to your server
- Run with:
java -jar aushadham-backend-1.0-SNAPSHOT.jar - Configure environment variables if needed
The Java backend can be configured using standard Spring Boot properties:
# Change port
java -jar aushadham-backend-1.0-SNAPSHOT.jar --server.port=8080
# Set profile
java -jar aushadham-backend-1.0-SNAPSHOT.jar --spring.profiles.active=prodFor any issues with the Java backend:
- Check the README in
aushadham-backend/ - Review the API documentation
- Run the test suite:
mvn test - Check application logs for errors