Skip to content

JBRKR000/FixmedFullstackApp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FixMed β€” Medical Platform Backend

A production-grade Spring Boot REST API for a comprehensive medical platform connecting patients, doctors, and healthcare facilities with appointment scheduling, real-time messaging, and secure file management.

πŸ“‘ Quick Links


✨ Features

πŸ” Authentication & Security

  • JWT-based token authentication with role-based access control (RBAC)
  • Support for multiple user roles: PATIENT, DOCTOR, ADMIN, FACILITY
  • Token lifecycle management (issuance, refresh, validation, revocation)
  • BCrypt password hashing for enhanced security
  • Stateless authentication architecture

πŸ‘₯ User Management

  • Role-specific user profiles with comprehensive data models
  • Doctor profiles with specialization and verification details
  • Patient medical history tracking
  • Healthcare facility management
  • Profile updates and self-service management via /users/me endpoint

πŸ“… Appointment Management

  • Intelligent slot availability verification
  • Full appointment lifecycle (create, retrieve, update, cancel, complete)
  • Attachment support for medical documents
  • Advanced filtering and search capabilities
  • Asynchronous event-driven processing for side-effects (notifications, audit)

πŸ’¬ Real-Time Messaging

  • Direct doctor-patient communication
  • Conversation history management
  • Patient-doctor relationship tracking
  • Built for scalability with RabbitMQ integration

πŸ₯ Healthcare Services

  • Medical service catalog per facility
  • Service details: pricing, duration, specialization
  • Service search and filtering

πŸ“ File Management

  • Doctor profile photo uploads and management
  • Medical document attachment storage
  • File validation (size and type constraints)
  • MinIO S3-compatible integration for reliable, scalable storage

⭐ Review System

  • Doctor and facility rating system
  • Review history tracking
  • Aggregate rating calculations

πŸ›  Technology Stack

Layer Technology
Framework Spring Boot 3.4.4, Spring Framework 6.x
Language Java 17 (LTS)
Build Tool Maven 3.9+
Security Spring Security, JWT (JJWT 0.12.6), BCrypt
Database MySQL 8.0+, Spring Data JPA
Migration Liquibase (schema versioning)
File Storage MinIO 8.5.17 (S3-compatible)
Messaging RabbitMQ, Spring AMQP
Testing JUnit 5, Spring Security Test, MockMVC
Code Quality Lombok, Spring Boot DevTools
Validation Jakarta Bean Validation, Spring Validation

πŸ— Architecture

Layered Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   REST Controllers (Presentation)   β”‚
β”‚   β”œβ”€β”€ AuthenticationController      β”‚
β”‚   β”œβ”€β”€ UsersController               β”‚
β”‚   └── Domain-specific Controllers   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Service Layer (Business Logic)    β”‚
β”‚   β”œβ”€β”€ AuthenticationService         β”‚
β”‚   β”œβ”€β”€ AppointmentsService           β”‚
οΏ½οΏ½   └── Domain Services               β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Persistence Layer (Data Access)   β”‚
β”‚   β”œβ”€β”€ Spring Data Repositories      β”‚
β”‚   └── JPA Entity Models             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
        β”‚   MySQL DB  β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Design Patterns

  • Event-Driven Architecture: Domain events (e.g., AppointmentRegisteredEvent) published via ApplicationEventPublisher for decoupled, asynchronous processing
  • Service-Repository Pattern: Clean separation between business logic and data access
  • DTO Pattern: Request/Response models in model.dto package for secure API contracts
  • Stateless Authentication: JWT tokens eliminate server-side session storage
  • Async Messaging: RabbitMQ integration for inter-service communication and notifications

πŸ“ Project Structure

src/main/java/org/fixmed/fixmed/
β”œβ”€β”€ FixmedApplication.java                 # Spring Boot entry point
β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ ApplicationConfig.java             # Bean definitions (security, auth, validation)
β”‚   β”œβ”€β”€ SecurityConfig.java                # Spring Security configuration
β”‚   └── RabbitMQConfig.java                # Message broker setup
β”œβ”€β”€ auth/
β”‚   β”œβ”€β”€ AuthenticationController.java      # Auth endpoints (register, login, refresh)
β”‚   β”œβ”€β”€ AuthenticationService.java         # JWT lifecycle & token validation
β”‚   └── JwtTokenProvider.java              # Token generation & parsing
β”œβ”€β”€ controller/
β”‚   β”œβ”€β”€ UsersController.java               # User management endpoints
β”‚   β”œβ”€β”€ AppointmentsController.java        # Appointment CRUD & operations
β”‚   β”œβ”€β”€ MessagingController.java           # Doctor-patient messaging
β”‚   └── FacilitiesController.java          # Facility management
β”œβ”€β”€ service/
β”‚   β”œβ”€β”€ AppointmentsService.java           # Interface defining appointment operations
β”‚   β”œβ”€β”€ MessagingService.java              # Messaging logic
β”‚   └── FileStorageService.java            # MinIO integration
β”œβ”€β”€ service/impl/
β”‚   β”œβ”€β”€ AppointmentsServiceImpl.java        # Slot verification, event publishing
β”‚   β”œβ”€β”€ MessagingServiceImpl.java           # Message persistence & retrieval
β”‚   └── FileStorageServiceImpl.java         # S3 upload/download
β”œβ”€β”€ repository/
β”‚   β”œβ”€β”€ AppointmentsRepository.java        # JPA queries (Spring Data)
β”‚   β”œβ”€β”€ UsersRepository.java               # User data access
β”‚   └── MessagesRepository.java            # Message persistence
β”œβ”€β”€ model/
β”‚   β”œβ”€β”€ User.java                          # JPA entity with role support
β”‚   β”œβ”€β”€ Appointment.java                   # Appointment entity
β”‚   β”œβ”€β”€ Message.java                       # Message entity
β”‚   └── dto/
β”‚       β”œβ”€β”€ UserDTO.java                   # Transfer object for user data
β”‚       β”œβ”€β”€ AppointmentDTO.java            # Transfer object for appointments
β”‚       └── AuthResponse.java              # JWT response payload
β”œβ”€β”€ event/
β”‚   β”œβ”€β”€ AppointmentRegisteredEvent.java    # Domain event for appointments
β”‚   └── AppointmentEventListener.java      # Async listener for side-effects
└── exception/
    β”œβ”€β”€ GlobalExceptionHandler.java        # Centralized error handling
    └── CustomExceptions.java              # Domain-specific exceptions

src/main/resources/
β”œβ”€β”€ application.properties                 # Base configuration
β”œβ”€β”€ application-dev.properties             # Development overrides
β”œβ”€β”€ application-prod.properties            # Production overrides
β”œβ”€β”€ application-example.properties         # Template for secrets/credentials
└── db/changelog/                          # Liquibase migration files

src/test/java/
β”œβ”€β”€ controller/                            # Controller unit & integration tests
β”œβ”€β”€ service/                               # Service layer tests
└── repository/                            # Repository & JPA tests

πŸš€ Getting Started

Prerequisites

  • Java 17+ (LTS)
  • Maven 3.9+
  • MySQL 8.0+
  • Docker & Docker Compose (optional, for RabbitMQ and MinIO)

Installation

  1. Clone the repository

    git clone https://github.com/JBRKR000/FixmedFullstackApp.git
    cd FixmedFullstackApp
  2. Configure environment

    cp src/main/resources/application-example.properties src/main/resources/application.properties
    # Edit application.properties with your database, JWT secret, MinIO, and RabbitMQ credentials
  3. Start dependencies (Docker)

    docker-compose up -d
  4. Build and run

    ./mvnw clean install
    ./mvnw spring-boot:run

    The API will be available at http://localhost:8080


πŸ“‘ API Overview

Authentication Endpoints

POST   /api/auth/register          β†’ Create new user account
POST   /api/auth/authenticate      β†’ Login and receive JWT token
POST   /api/auth/refresh           β†’ Refresh expired token
POST   /api/auth/authenticatetoken β†’ Validate current token
POST   /api/auth/logout            β†’ Revoke token

User Management

GET    /api/users                  β†’ List all users (paginated)
GET    /api/users/{id}             β†’ Get user profile by ID
POST   /api/users                  β†’ Create new user (admin only)
GET    /api/users/me               β†’ Current authenticated user profile
PUT    /api/users/me               β†’ Update current user profile

Appointments

POST   /api/appointments           β†’ Create appointment
GET    /api/appointments/{id}      β†’ Get appointment details
GET    /api/appointments           β†’ List appointments (filtered, paginated)
PUT    /api/appointments/{id}      β†’ Update appointment
DELETE /api/appointments/{id}      β†’ Cancel appointment
POST   /api/appointments/{id}/complete β†’ Mark as completed

Messaging

POST   /api/messages               β†’ Send message
GET    /api/messages/{conversationId} β†’ Get conversation history
GET    /api/messages/doctors/{doctorId} β†’ List doctors' conversations
GET    /api/messages/patients/{patientId} β†’ List patient's doctors

Additional Endpoints

  • Facilities: /api/facilities - Manage healthcare facilities
  • Services: /api/services - Medical service catalog
  • Slots: /api/availability-slots - Appointment availability
  • Reviews: /api/reviews - Rate doctors and facilities

Full API documentation available via Swagger/OpenAPI at /swagger-ui.html (if enabled)


βš™οΈ Configuration

Environment Variables

Create src/main/resources/application.properties with:

# Spring & Server
spring.application.name=fixmed-backend
server.port=8080

# Database
spring.datasource.url=jdbc:mysql://localhost:3306/fixmed_db
spring.datasource.username=root
spring.datasource.password=your_db_password
spring.jpa.hibernate.ddl-auto=validate

# JWT Security
app.security.jwt.secret=your_jwt_secret_key_min_256_bits
app.security.jwt.expiration=86400000
app.security.jwt.refresh-expiration=604800000

# MinIO File Storage
minio.url=http://localhost:9000
minio.access-key=minioadmin
minio.secret-key=minioadmin
minio.bucket-name=fixmed-files
doctor.photos.base-url=http://localhost:9000/fixmed-files

# RabbitMQ Messaging
spring.rabbitmq.host=localhost
spring.rabbitmq.port=5672
spring.rabbitmq.username=guest
spring.rabbitmq.password=guest
app.rabbitmq.exchange=fixmed-exchange
app.rabbitmq.queue=fixmed-queue

# Logging
logging.level.org.fixmed.fixmed=DEBUG
logging.level.org.springframework.security=DEBUG

πŸ§ͺ Testing

Running Tests

# All tests
./mvnw test

# Specific test class
./mvnw test -Dtest=AppointmentsServiceTest

# With coverage
./mvnw test jacoco:report

Test Coverage

  • Unit Tests: Service layer logic, validation, calculations
  • Integration Tests: Repository queries, database transactions
  • Controller Tests: REST endpoints, request validation, response formats
  • Security Tests: Authentication, authorization, token validation

Recommended: Use Testcontainers for realistic MinIO and RabbitMQ testing


πŸ”’ Security Highlights

βœ… Stateless JWT Authentication - No session storage overhead βœ… Role-Based Access Control - Fine-grained authorization per role βœ… Password Hashing - BCrypt with configurable strength βœ… Token Revocation - Logout functionality with token blacklisting βœ… Input Validation - Jakarta Bean Validation on all DTOs βœ… Exception Handling - Centralized, secure error responses βœ… CORS Configuration - Configurable cross-origin policies


πŸ“Š Performance & Scalability

  • Stateless Design: Horizontally scalable (add more instances behind load balancer)
  • Async Events: Non-blocking appointment creation and notifications
  • RabbitMQ Integration: Decoupled inter-service communication
  • MinIO S3 Storage: Scalable file storage with multi-instance support
  • Database Indexing: Optimized queries with strategic index placement
  • Pagination: All list endpoints support paginated responses

🀝 Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

This project is proprietary and confidential.


πŸ‘¨β€πŸ’» Author

JBRKR000 Full-stack developer specializing in Spring Boot backend architecture and Java microservices.


πŸ™‹ Support

For issues, questions, or suggestions, please open a GitHub issue or contact the development team.

About

A production-grade Spring Boot REST API for a comprehensive medical platform connecting patients, doctors, and healthcare facilities with appointment scheduling, real-time messaging, and secure file management.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages