Smart Health Platform is an intelligent health management system that integrates health data management, diet tracking, medication reminders, exercise monitoring, and community interaction. The backend is built with Spring Boot 3.2.0 and follows a clean three-layer architecture (Controller-Service-Mapper).
Key Features:
- Comprehensive health data tracking (BMI, weight, blood pressure, heart rate, sleep, steps)
- AI-powered health analysis and personalized recommendations
- Real-time medication reminders via WebSocket
- Nutrition tracking with external API integration (FatSecret)
- FDA drug information database integration
- Community forum with rich text support
- Smart health report generation
healthplatform/
├── src/main/java/com/health/healthplatform/
│ ├── config/ # Configuration classes
│ │ ├── CorsConfig.java # CORS configuration
│ │ ├── JwtConfig.java # JWT authentication
│ │ ├── WebSocketConfig.java # WebSocket setup
│ │ └── OAuth2Config.java # OAuth2 configuration
│ │
│ ├── controller/ # REST API controllers
│ │ ├── AuthController.java
│ │ ├── UserController.java
│ │ ├── HealthDataController.java
│ │ ├── AIAnalysisController.java
│ │ ├── ArticleController.java
│ │ ├── DietRecord/
│ │ ├── MedicineReminder/
│ │ └── ExerciseRecord/
│ │
│ ├── service/ # Business logic layer
│ │ ├── UserService.java
│ │ ├── AuthService.java
│ │ ├── health_data/ # Health metrics services
│ │ ├── DietRecord/ # Diet management
│ │ ├── MedicineReminder/ # Medication management
│ │ ├── HealthReport/ # Report generation
│ │ ├── DeepSeekService.java # AI integration
│ │ ├── FdaDrugApiService.java
│ │ └── FileService.java # OSS file upload
│ │
│ ├── mapper/ # Data access layer
│ │ ├── UserMapper.java
│ │ ├── HealthDataMapper.java
│ │ └── ...
│ │
│ ├── entity/ # Database entities
│ │ ├── User.java
│ │ ├── HealthData.java
│ │ ├── MedicineReminder.java
│ │ └── ...
│ │
│ ├── DTO/ # Data transfer objects
│ ├── vo/ # View objects
│ ├── websocket/ # WebSocket handlers
│ ├── handler/ # Exception handlers
│ ├── interceptor/ # JWT interceptor
│ └── util/ # Utility classes
│
├── src/main/resources/
│ ├── application.properties # Application configuration
│ ├── mapper/ # MyBatis XML mappings
│ └── sql/ # Database scripts
│
└── pom.xml # Maven dependencies
- Real-time tracking of multiple health metrics
- Historical trend analysis with date range queries
- Automatic BMI calculation
- Health status assessment based on medical standards
- Integration with DeepSeek AI service
- Personalized health recommendations
- Context-aware health Q&A
- Multi-dimensional health score calculation
- Medicine record tracking
- Smart reminder scheduling
- FDA drug information integration
- Real-time push notifications via WebSocket
- Meal recording with nutrition details
- Daily nutrition summary
- Goal setting and achievement tracking
- FatSecret API integration for food data
- Article publishing with rich text editor
- Multi-level comment system
- Social features (likes, favorites, shares)
- Image upload to Aliyun OSS
- WebSocket for instant notifications
- Automatic reconnection mechanism
- Session management for multiple users
- Support for various notification types
- JDK 17 or higher
- Maven 3.9.9 or higher
- MySQL 8.0 or higher
- Aliyun account (for OSS, SMS services)
- Clone the repository
git clone https://github.com/nova728/health-platform-backend.git
cd health-platform-backend- Configure database
# Create database
mysql -u root -p
CREATE DATABASE healthplatform CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# Import database schema
mysql -u root -p healthplatform < src/main/resources/sql/schema.sql- Configure application.properties
# Database configuration
spring.datasource.url=jdbc:mysql://localhost:3306/healthplatform
spring.datasource.username=your_username
spring.datasource.password=your_password
# Aliyun OSS configuration
aliyun.oss.endpoint=your_endpoint
aliyun.oss.accessKeyId=your_access_key
aliyun.oss.accessKeySecret=your_secret_key
aliyun.oss.bucketName=your_bucket_name
# JWT configuration
jwt.secret=your_jwt_secret_key
jwt.expiration=3600000
# DeepSeek AI configuration
deepseek.api.key=your_deepseek_api_key
deepseek.api.url=https://api.deepseek.com- Build and run
# Build the project
mvn clean install
# Run the application
mvn spring-boot:run
# Or run the jar file
java -jar target/healthplatform-0.0.1-SNAPSHOT.jar- Verify installation
# Check if the server is running
curl http://localhost:8088/actuator/healthThe backend server will start on http://localhost:8088
POST /api/user/login- User loginPOST /api/user/register- User registrationGET /api/user/{id}- Get user profile
GET /api/health/{userId}/history- Get health data historyPOST /api/health/{userId}/data- Add health data recordGET /api/health/{userId}/bmi- Get BMI dataGET /api/health/{userId}/blood-pressure- Get blood pressure data
POST /api/ai/chat- AI health assistant chatPOST /api/ai/health-qa- Health knowledge Q&APOST /api/health-reports/{userId}/generate- Generate health report
GET /api/medicines/{userId}/medicine- Get medication historyPOST /api/medicines/{userId}/medicine- Add medication recordPOST /api/medicines/{userId}/medicine/{medicineId}/reminder- Set reminder
GET /api/articles- Get article listPOST /api/articles/{userId}- Create articlePOST /api/articles/{userId}/{id}/comments- Add commentPOST /api/articles/{id}/{userId}/like- Like/unlike article
Core Tables:
user- User informationhealth_data- Health metrics recordsmedicine_records- Medication recordsmedicine_reminders- Medication remindersmeal_records- Diet recordsdiet_goals- Nutrition goalsexercise_records- Exercise logsarticles- Community articlescomments- Article commentshealth_reports- Generated health reports
For detailed database schema, see Database Design Document
- Three-Layer Architecture: Clear separation of Controller, Service, and Mapper layers
- Dependency Injection: Extensive use of Spring's IoC container
- Exception Handling: Unified exception handling with custom error codes
- Logging: Comprehensive logging using Slf4j
- Security: JWT authentication, password encryption, SQL injection prevention
- Real-time Communication: WebSocket for instant notifications
- External Integration: Multiple third-party API integrations (FDA, FatSecret, AI services)
- Follow Java naming conventions
- Use Lombok annotations to reduce boilerplate code
- Write comprehensive JavaDoc comments
- Keep methods focused and under 50 lines
# Run unit tests
mvn test
# Run integration tests
mvn verify
# Generate test coverage report
mvn jacoco:report- Database indexing on frequently queried columns
- MyBatis-Plus pagination for large datasets
- Caching for frequently accessed data
- Async processing for time-consuming tasks
# Build Docker image
docker build -t health-platform-backend .
# Run container
docker run -d -p 8088:8088 --name health-backend health-platform-backend- Deploy application to ECS instance
- Configure security groups and firewall
- Set up Nginx reverse proxy
- Configure SSL certificate for HTTPS
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Project Link: https://github.com/nova728/health-platform-backend






