Mobile Development 10 min read

Building a WeChat Mini‑Program Health Management System with AI in 20 Minutes (Spring AI 2.0 + Spring Boot 4 + Vue 3)

In just 20 minutes, the author uses Cursor AI to generate a full‑stack WeChat mini‑program for personal health management, featuring an AI‑driven health consultant, a Spring Boot 4 backend with JWT security, MySQL storage, and a Vue 3 admin console, and explains the architecture, routing, and deployment details.

java1234
java1234
java1234
Building a WeChat Mini‑Program Health Management System with AI in 20 Minutes (Spring AI 2.0 + Spring Boot 4 + Vue 3)

Project Overview

Advanced personal health‑management system for ordinary users (daily health data recording and AI health consultation) and administrators (data statistics and platform maintenance). Front‑end/back‑end separation; a single set of backend APIs is shared by three clients: Vue admin console, WeChat mini‑program, and public API.

Components:

Backend Service (directory server/, port 8080) – provides REST APIs.

Admin Console (directory client/, port 5173) – Vue admin UI.

WeChat Mini‑Program (directory weixin/) – native WXML/WXSS/JS client.

Database Scripts ( db/db_health.sql, MySQL port 3308).

Business Logic

Roles

Administrator (admin) : logs in via Vue console, manages users and health data, publishes articles, views dashboard charts.

Regular user (user) : registers/logs in via mini‑program, records health metrics, browses articles, interacts with AI advisor “Xiaokang”.

Core Business Domains

User & Authentication – role‑based login, JWT, registration/password change. Tables: t_admin, t_user.

Health Metrics – weight, blood pressure, blood sugar, heart rate, temperature; trend and latest‑value queries. Table: t_health_metric.

Diet Records – food and calories per meal, daily summary. Table: t_diet.

Exercise Records – type, duration, calories burned, steps. Table: t_exercise.

Health Plans – goals (weight loss, muscle gain, sleep) and status tracking. Table: t_health_plan.

Health Articles – admin‑published articles, list/detail view. Table: t_article.

AI Smart Customer Service – Alibaba Cloud Bailei (qwen3.6‑plus) conversational and streaming replies, chat history stored. Table: t_chat_message.

Typical Flows

Mini‑program user flow: Register/login → Record health data → View overview → Chat with AI advisor.

Admin console flow: Login → Manage users, metrics, diet, exercise, plans, articles → View statistics.

Technology Stack

Backend (server)

Framework: Spring Boot 4.0.6

ORM: MyBatis‑Plus

Security: JWT (jjwt) with JwtInterceptor for unified interception

AI: Spring AI 2.0, compatible with OpenAI protocol to connect Alibaba Cloud Bailei

Utilities: Hutool, unified Result response wrapper, global exception handling

Runtime: JDK 21+, Maven

Admin Console (client)

Framework: Vue 3 + Vite

UI Library: Element Plus

State Management: Pinia

Charts: ECharts

HTTP: Axios with

Authorization: Bearer <token>

WeChat Mini‑Program (weixin)

Developed with native WXML, WXSS, and JavaScript. API calls use utils/request.js to backend routes under /wx/**. baseUrl must be set to the LAN IP because the mini‑program cannot access localhost.

Data Layer

Database: MySQL 8, schema db_health, tables prefixed with t_.

Default connection: localhost:3308, password 123456.

File uploads: stored in D:/uploads, served statically via /uploads/**.

AI Configuration

API Key: environment variable OPENAI_API_KEY Base URL: https://dashscope.aliyuncs.com/compatible-mode/v1 Chat Model: qwen3.6-plus System Role: defined in HealthSystemPrompt as the “Xiaokang” health advisor

System Architecture

Backend Layered Structure

com.java1234.health
├── controller/     # AdminController, WxController, other controllers
├── service/        # Business logic (User, Chat, Diet, Exercise, etc.)
├── mapper/         # MyBatis‑Plus data access
├── entity/         # Entity‑table mappings
├── dto/            # Request/response objects
├── config/         # JWT, CORS, AI, interceptor registration
├── common/         # Result, JwtUtil, exceptions, file upload
└── ai/             # HealthSystemPrompt and other AI presets

API Routing

/admin/**

– called by admin console, requires admin JWT (except login), provides statistics, user management, CRUD for all business modules, article publishing, file upload. /wx/** – called by mini‑program, requires user JWT (except login/registration), provides profile, overview, AI chat, personal data for each module. /api/** – public or mini‑program, token required for most endpoints; article list/detail accessible anonymously.

Authentication Flow

Interceptor configuration registers JwtInterceptor for /admin/**, /wx/**, and /api/**. Token validation is applied except for /admin/login, /wx/login, /wx/register, and public article read endpoints.

Database Overview

Key tables: t_admin, t_user, t_health_metric, t_diet, t_exercise, t_health_plan, t_article, t_chat_message. All tables use the t_ prefix.

Front‑End Module Mapping

Admin Console Routes

/login

– admin login /home – dashboard statistics (ECharts) /user – user management /metric – health metric management /diet – diet record management /exercise – exercise record management /plan – health plan management /article – health article management

Mini‑Program Tabs & Pages

Home – health overview ( /wx/overview)

Metrics – record and view health metric trends

AI Service – streaming/normal chat with history

Me – profile, password change, entry to diet, exercise, plan

Articles – list and detail ( /api/article)

Images

Architecture Diagram
Architecture Diagram
Authentication Flow
Authentication Flow
Database Overview
Database Overview
Mini‑program User Flow
Mini‑program User Flow
Admin Console Operation Flow
Admin Console Operation Flow
Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

WeChat Mini ProgramSpring BootmysqlSpring AIJWTAI ChatbotVue 3
java1234
Written by

java1234

Former senior programmer at a Fortune Global 500 company, dedicated to sharing Java expertise. Visit Feng's site: Java Knowledge Sharing, www.java1234.com

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.