English | 简体中文
The backend project of Health Management Platform, a RESTful API service built with Spring Boot. Provides complete user management, health data management, community interaction, and other core functions, supporting high concurrency access and real-time message pushing.
- Spring Boot 3.2.0 - Framework for rapid production-ready application development
- Spring Security - Authentication and authorization functionality
- MyBatis - Excellent persistence framework
- MySQL 8.0 - Relational database
- Redis - Caching and session management
- WebSocket - Real-time message pushing
- JWT - Stateless authentication
- ERNIE Bot API - AI health consultation
- FatSecret Platform API - Food nutrition data
- OpenFDA API - Drug information lookup
- User Management - Registration, login, authentication, authorization
- Health Data Management - Heart rate, blood pressure, weight, BMI, sleep tracking
- Exercise Management - Activity logging, goal management, leaderboards
- Diet Management - Nutrition tracking, food database
- Medication Management - Medicine records, reminder services
- Health Reports - Intelligent analysis, scoring, recommendation generation
- Community Forum - Article management, comments, likes, favorites
- Real-time Notifications - WebSocket message pushing
- JDK 17+
- Maven 3.9.9+
- MySQL 8.0+
- Redis 6.0+ (optional)
- Clone the repository
git clone https://github.com/nova728/healthplatform
cd healthplatform- Configure database
Create database:
CREATE DATABASE healthplatform CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;Modify database configuration in src/main/resources/application.yml:
spring:
datasource:
url: jdbc:mysql://localhost:3306/healthplatform?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
username: your_username
password: your_password- Configure third-party APIs
Configure API keys in application.yml:
api:
ernie-bot:
api-key: your_ernie_bot_api_key
fatsecret:
consumer-key: your_fatsecret_consumer_key
consumer-secret: your_fatsecret_consumer_secret
openfda:
base-url: https://api.fda.gov- Start application
mvn spring-boot:runThe application will start at http://localhost:8080.
mvn clean packageThe generated JAR file is located in the target/ directory.
healthplatform/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/healthplatform/
│ │ │ ├── controller/ # Controller layer
│ │ │ ├── service/ # Business logic layer
│ │ │ ├── mapper/ # Data access layer
│ │ │ ├── entity/ # Entity classes
│ │ │ ├── dto/ # Data transfer objects
│ │ │ ├── config/ # Configuration classes
│ │ │ ├── security/ # Security configuration
│ │ │ ├── websocket/ # WebSocket configuration
│ │ │ └── util/ # Utility classes
│ │ └── resources/
│ │ ├── mapper/ # MyBatis XML mapping files
│ │ ├── application.yml # Application configuration
│ │ └── application-dev.yml # Development environment config
│ └── test/ # Test code
├── pom.xml # Maven configuration
└── README.md
POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/user/profile- Get user informationPUT /api/user/profile- Update user information
POST /api/health/record- Add health recordGET /api/health/records- Get health records listGET /api/health/report- Generate health reportGET /api/health/statistics- Get health statistics
POST /api/exercise/record- Add exercise recordGET /api/exercise/records- Get exercise recordsPOST /api/exercise/goal- Set exercise goalsGET /api/exercise/leaderboard- Get leaderboard
POST /api/diet/record- Add diet recordGET /api/diet/records- Get diet recordsGET /api/diet/nutrition- Get nutrition analysisGET /api/diet/food/search- Search food
POST /api/medication/record- Add medication recordGET /api/medication/records- Get medication recordsPOST /api/medication/reminder- Set medication reminderGET /api/medication/info- Query drug information
POST /api/forum/article- Publish articleGET /api/forum/articles- Get articles listPOST /api/forum/comment- Post commentPOST /api/forum/like- LikePOST /api/forum/favorite- Favorite
- JWT Authentication - Stateless authentication mechanism
- Password Encryption - BCrypt encrypted storage
- Permission Control - Role-based access control (RBAC)
- XSS Protection - Input validation and output encoding
- SQL Injection Protection - Prepared statements
- Redis Cache - Cache hot data
- Database Connection Pool - HikariCP high-performance connection pool
- Asynchronous Processing - @Async annotation for async execution
- Pagination - MyBatis PageHelper pagination
- Index Optimization - Database index optimization
- Exception Handling - Global exception handling mechanism
- Logging - SLF4J + Logback logging framework
- Health Checks - Spring Boot Actuator
- Transaction Management - Declarative transactions
user- User tablehealth_record- Health records tableexercise_record- Exercise records tablediet_record- Diet records tablemedication_record- Medication records tablearticle- Articles tablecomment- Comments tablenotification- Notifications table
The project follows Alibaba Java Development Guidelines and uses CheckStyle for code checking.
mvn testWe recommend using Postman or Swagger UI for API testing.
Swagger UI address: http://localhost:8080/swagger-ui.html
# Build image
docker build -t healthplatform:latest .
# Run container
docker run -d -p 8080:8080 healthplatform:latestFor production environment, use application-prod.yml configuration file and ensure:
- Modify database connection configuration
- Configure Redis connection
- Update API keys
- Enable HTTPS
- Configure log levels
Issues and Pull Requests are welcome!
- Fork this 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
- Frontend Repository: healthplatform_front
- Desktop Application: healthplatform_electron
This project is licensed under the MIT License - see the LICENSE file for details
For questions or suggestions, please contact us through Issues.
⭐ If this project helps you, please give us a Star!