How apexnewbie/ai-health-management works
Project type and purpose
• This is a full-stack AI Health Management System:
• Backend: Spring Boot REST API (Java 17, Spring Security, JWT, MyBatis, Redis)
• Frontend: React static pages (fitness & diet UI, chat interface next)
• Persistence: Relational DB (SQL scripts in docs/V1_user.sql) and Redis cache
• Planned integrations: LLM chat, nutrition DB, blockchain/NFT, scheduling service
File structure
• src/main/java/com/example/aihealthmanagement:
• Application entry point (AiHealthManagementApplication.java)
• config: SecurityConfig, WebConfig
• controller: AuthController, ProfileController (REST endpoints)
• service / service/impl: business logic (AuthServiceImpl, CustomUserDetailsService)
• repository: UserRepository (MyBatis/JPA)
• security: JWT filter, token provider, CustomUserDetails
• common/exception: ServiceResponse, ServiceException, GlobalExceptionHandler
• dto & entity: data transfer objects and JPA entities
• src/main/resources/application.properties: DB & Redis configs, JWT settings
• docs: SQL schema and structure notes
• README: lists implemented features (authentication, global error handling, static React UI) and future modules
Key architectural patterns & design principles
• Layered architecture: Controller → Service → Repository → Database
• Stateless authentication: JWT issued by AuthService → validated by JwtAuthenticationFilter
• Cross-cutting concerns: GlobalExceptionHandler, unified ServiceResponse wrapper
• External integrations: AI/LLM, nutrition API, blockchain node
Main components
a. Clients
• Web Browser / Mobile app (React UI)
b. API Gateway / Spring Boot Backend
• Security Layer (JWT filter, Spring Security)
• API Layer (Controllers)
• Business Layer (Services)
• Data Layer (Repositories, MyBatis/JPA)
c. Data Stores
• Relational Database (MySQL/PostgreSQL)
• Redis Cache
d. External Services
• LLM Chat API (psychological support)
• Nutrition Database API
• Blockchain/NFT node
• Scheduling/Notification Service
e. DevOps & Monitoring (optional)
• Swagger/OpenAPI UI
• CI pipeline
Relationships & interactions
• Client → HTTP(S) → Spring Boot REST endpoints
• Security Filter validates/attaches JWT → Controller
• Controller invokes Service → Repository
• Repository ↔ Database (CRUD)
• Service ↔ Redis (cache tokens, session data)
• Service ↔ External LLM / Nutrition / Blockchain APIs
• Errors bubble up → GlobalExceptionHandler → unified ServiceResponse