Skip to content

RuchiSetti/Health_record_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Health Record System

A comprehensive healthcare records management system built with Spring Boot backend and Next.js frontend.

πŸ—οΈ Architecture

  • 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

πŸš€ Quick Start

Prerequisites

  • Java 21+
  • Node.js 18+
  • Docker & Docker Compose
  • Maven 3.6+

1. Clone the Repository

git clone <your-repo-url>
cd HEALTH

2. Environment Setup

Backend Configuration

The backend uses the following environment variables:

  • APP_API_KEY: API key for authentication (default: dev-demo-key)
  • SPRING_DATASOURCE_URL: MySQL connection URL
  • SPRING_DATASOURCE_USERNAME: Database username (default: health)
  • SPRING_DATASOURCE_PASSWORD: Database password (default: health)

Frontend Configuration

Create a .env.local file in the frontend directory:

# Copy the example file
cp frontend/env.example frontend/.env.local

Edit frontend/.env.local:

NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_API_KEY=dev-demo-key
NODE_ENV=development

3. Development Setup

Option A: Using Docker Compose (Recommended)

# Set your API key
export APP_API_KEY=your-secure-api-key

# Start all services
docker-compose up -d --build

This will start:

  • Backend API on http://localhost:8000
  • Frontend on http://localhost:3000
  • MySQL database

Option B: Manual Setup

Backend:

cd backend
mvn clean install
mvn spring-boot:run

Frontend:

cd frontend
npm install
npm run dev

Database:

# 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.4

πŸ”‘ API Authentication

The 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/users

πŸ‘₯ Demo Users

The system includes demo users for testing:

Role Email Password
Admin admin@health.com password123
Doctor doctor@health.com password123
Patient patient@health.com password123

πŸ“ Project Structure

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

πŸ”§ API Endpoints

Admin Endpoints

  • GET /api/admin/users - List all users
  • POST /api/admin/users - Create new user
  • GET /api/admin/patients - List all patients
  • GET /api/admin/doctors - List all doctors

Doctor Endpoints

  • GET /api/doctor/patients - List doctor's patients
  • POST /api/doctor/medical-records - Create medical record
  • POST /api/doctor/prescriptions - Create prescription
  • POST /api/doctor/lab-reports - Create lab report

Patient Endpoints

  • GET /api/patient/profile/{id} - Get patient profile
  • GET /api/patient/medical-records/{id} - Get patient records
  • GET /api/patient/prescriptions/{id} - Get patient prescriptions
  • GET /api/patient/lab-reports/{id} - Get patient lab reports

🐳 Docker Commands

# 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 -v

πŸ”„ CI/CD with Jenkins

The project includes a Jenkinsfile for automated CI/CD:

  1. Checkout: Pull latest code
  2. Build Backend: Maven build
  3. Build Docker Images: Create container images
  4. Deploy: Deploy using Docker Compose

Jenkins Setup

  1. Create a new Pipeline job in Jenkins
  2. Set the pipeline script to read from SCM
  3. Configure the repository URL
  4. Add APP_API_KEY as a credential in Jenkins
  5. Run the pipeline

πŸ› οΈ Development

Backend Development

cd backend
mvn spring-boot:run

The API will be available at http://localhost:8000 API documentation: http://localhost:8000/swagger-ui.html

Frontend Development

cd frontend
npm run dev

The frontend will be available at http://localhost:3000

Database Management

Connect to MySQL:

docker exec -it health-mysql mysql -u health -p health

πŸ”’ Security

  • API key authentication for all endpoints
  • CORS configuration for frontend-backend communication
  • Input validation and sanitization
  • Secure password handling (in production, use proper hashing)

πŸ“ Environment Variables

Backend (.env or system environment)

APP_API_KEY=your-secure-api-key
SPRING_DATASOURCE_URL=jdbc:mysql://mysql:3306/health
SPRING_DATASOURCE_USERNAME=health
SPRING_DATASOURCE_PASSWORD=health

Frontend (.env.local)

NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_API_KEY=your-secure-api-key
NODE_ENV=development

πŸš€ Deployment

Production Deployment

  1. Set secure API keys
  2. Configure production database
  3. Update CORS origins
  4. Use Docker Compose for deployment
  5. Set up reverse proxy (nginx) for SSL

Environment-specific Configuration

  • Development: Use dev-demo-key for API key
  • Staging: Use environment-specific API keys
  • Production: Use strong, unique API keys

πŸ› Troubleshooting

Common Issues

  1. API Connection Failed

    • Check if backend is running on port 8000
    • Verify API key in frontend environment
    • Check CORS configuration
  2. Database Connection Issues

    • Ensure MySQL container is running
    • Check database credentials
    • Verify network connectivity
  3. Frontend Build Issues

    • Clear node_modules and reinstall
    • Check Node.js version compatibility
    • Verify environment variables

Logs

# Backend logs
docker-compose logs backend

# Frontend logs
docker-compose logs frontend

# Database logs
docker-compose logs mysql

πŸ“„ License

This project is licensed under the MIT License.

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“ž Support

For support and questions, please contact the development team.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors