A comprehensive healthcare records management system built with Spring Boot backend and Next.js frontend.
- Backend: Spring Boot 3.3.3 with Java 21
- Frontend: Next.js 15.5.4 with React 18.3.1
- Database: MySQL 8.4
- Authentication: API Key based authentication
- Containerization: Docker & Docker Compose
- Java 21+
- Node.js 18+
- Docker & Docker Compose
- Maven 3.6+
git clone <your-repo-url>
cd HEALTHThe backend uses the following environment variables:
APP_API_KEY: API key for authentication (default:dev-demo-key)SPRING_DATASOURCE_URL: MySQL connection URLSPRING_DATASOURCE_USERNAME: Database username (default:health)SPRING_DATASOURCE_PASSWORD: Database password (default:health)
Create a .env.local file in the frontend directory:
# Copy the example file
cp frontend/env.example frontend/.env.localEdit frontend/.env.local:
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_API_KEY=dev-demo-key
NODE_ENV=development# Set your API key
export APP_API_KEY=your-secure-api-key
# Start all services
docker-compose up -d --buildThis will start:
- Backend API on
http://localhost:8000 - Frontend on
http://localhost:3000 - MySQL database
Backend:
cd backend
mvn clean install
mvn spring-boot:runFrontend:
cd frontend
npm install
npm run devDatabase:
# Start MySQL container
docker run -d \
--name health-mysql \
-e MYSQL_DATABASE=health \
-e MYSQL_USER=health \
-e MYSQL_PASSWORD=health \
-e MYSQL_ROOT_PASSWORD=root \
-p 3306:3306 \
mysql:8.4The system uses API key authentication. Include the API key in all requests:
curl -H "X-API-KEY: dev-demo-key" \
-H "Content-Type: application/json" \
http://localhost:8000/api/admin/usersThe system includes demo users for testing:
| Role | Password | |
|---|---|---|
| Admin | admin@health.com | password123 |
| Doctor | doctor@health.com | password123 |
| Patient | patient@health.com | password123 |
HEALTH/
βββ backend/ # Spring Boot API
β βββ src/main/java/com/health/
β β βββ config/ # Security & CORS configuration
β β βββ controller/ # REST controllers
β β βββ model/ # Data models
β β βββ service/ # Business logic
β β βββ repo/ # Data access layer
β βββ src/main/resources/
β β βββ application.yml # Application configuration
β βββ Dockerfile
βββ frontend/ # Next.js React app
β βββ src/
β β βββ app/ # Next.js app router pages
β β βββ components/ # Reusable components
β β βββ lib/ # API client & utilities
β β βββ store/ # State management
β βββ Dockerfile
βββ docker-compose.yml # Multi-container setup
βββ Jenkinsfile # CI/CD pipeline
βββ README.md
GET /api/admin/users- List all usersPOST /api/admin/users- Create new userGET /api/admin/patients- List all patientsGET /api/admin/doctors- List all doctors
GET /api/doctor/patients- List doctor's patientsPOST /api/doctor/medical-records- Create medical recordPOST /api/doctor/prescriptions- Create prescriptionPOST /api/doctor/lab-reports- Create lab report
GET /api/patient/profile/{id}- Get patient profileGET /api/patient/medical-records/{id}- Get patient recordsGET /api/patient/prescriptions/{id}- Get patient prescriptionsGET /api/patient/lab-reports/{id}- Get patient lab reports
# Build and start all services
docker-compose up -d --build
# View logs
docker-compose logs -f
# Stop all services
docker-compose down
# Rebuild specific service
docker-compose up -d --build backend
# Remove all containers and volumes
docker-compose down -vThe project includes a Jenkinsfile for automated CI/CD:
- Checkout: Pull latest code
- Build Backend: Maven build
- Build Docker Images: Create container images
- Deploy: Deploy using Docker Compose
- Create a new Pipeline job in Jenkins
- Set the pipeline script to read from SCM
- Configure the repository URL
- Add
APP_API_KEYas a credential in Jenkins - Run the pipeline
cd backend
mvn spring-boot:runThe API will be available at http://localhost:8000
API documentation: http://localhost:8000/swagger-ui.html
cd frontend
npm run devThe frontend will be available at http://localhost:3000
Connect to MySQL:
docker exec -it health-mysql mysql -u health -p health- API key authentication for all endpoints
- CORS configuration for frontend-backend communication
- Input validation and sanitization
- Secure password handling (in production, use proper hashing)
APP_API_KEY=your-secure-api-key
SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/health
SPRING_DATASOURCE_USERNAME=health
SPRING_DATASOURCE_PASSWORD=healthNEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_API_KEY=your-secure-api-key
NODE_ENV=development- Set secure API keys
- Configure production database
- Update CORS origins
- Use Docker Compose for deployment
- Set up reverse proxy (nginx) for SSL
- Development: Use
dev-demo-keyfor API key - Staging: Use environment-specific API keys
- Production: Use strong, unique API keys
-
API Connection Failed
- Check if backend is running on port 8000
- Verify API key in frontend environment
- Check CORS configuration
-
Database Connection Issues
- Ensure MySQL container is running
- Check database credentials
- Verify network connectivity
-
Frontend Build Issues
- Clear node_modules and reinstall
- Check Node.js version compatibility
- Verify environment variables
# Backend logs
docker-compose logs backend
# Frontend logs
docker-compose logs frontend
# Database logs
docker-compose logs mysqlThis project is licensed under the MIT License.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
For support and questions, please contact the development team.