A comprehensive full-stack pharmacy management system built with Spring Boot and React, featuring secure authentication, inventory management, sales tracking, and supplier management.
- Features
- Technology Stack
- Architecture
- Design Patterns
- Getting Started
- Docker Deployment
- API Documentation
- Testing
- Project Structure
- Contributing
- License
- π Secure Authentication: JWT-based authentication with OTP verification
- π Product Management: Complete CRUD operations for pharmaceutical products
- π¦ Inventory Management: Real-time stock tracking and low-stock alerts
- π° Sales Management: Point-of-sale system with receipt generation
- π’ Supplier Management: Manage supplier information and relationships
- π Dashboard Analytics: Real-time statistics and insights
- π Advanced Search: Multi-criteria search across products and sales
- π₯ User Management: Role-based access control (Admin, User)
- JWT token-based authentication
- Password encryption with BCrypt
- OTP verification for login
- Role-based authorization
- CORS configuration
- SQL injection prevention
- XSS protection
- Framework: Spring Boot 3.2.3
- Language: Java 21
- Database: PostgreSQL 16
- Security: Spring Security + JWT
- ORM: Spring Data JPA / Hibernate
- Build Tool: Maven
- API Documentation: SpringDoc OpenAPI (Swagger)
- Email: Spring Mail
- Testing: JUnit 5, Mockito, MockMvc
- Framework: React 18
- Build Tool: Vite
- Styling: CSS3
- HTTP Client: Axios
- Routing: React Router
- Containerization: Docker & Docker Compose
- Database: PostgreSQL (containerized)
- Web Server: Nginx (for frontend)
- Version Control: Git & GitHub
The application follows a layered architecture pattern:
βββββββββββββββββββββββββββββββββββββββββββ
β React Frontend (Vite) β
β (Port 80 - Nginx) β
βββββββββββββββββββ¬ββββββββββββββββββββββββ
β HTTP/REST API
βββββββββββββββββββΌββββββββββββββββββββββββ
β Spring Boot Backend (Port 8082) β
β βββββββββββββββββββββββββββββββββββ β
β β Controllers (REST API) β β
β ββββββββββββββββ¬βββββββββββββββββββ β
β ββββββββββββββββΌβββββββββββββββββββ β
β β Services (Business Logic) β β
β ββββββββββββββββ¬βββββββββββββββββββ β
β ββββββββββββββββΌβββββββββββββββββββ β
β β Repositories (Data Access) β β
β ββββββββββββββββ¬βββββββββββββββββββ β
βββββββββββββββββββΌββββββββββββββββββββββββ
β JDBC
βββββββββββββββββββΌββββββββββββββββββββββββ
β PostgreSQL Database (Port 5432) β
βββββββββββββββββββββββββββββββββββββββββββ
This project implements multiple industry-standard design patterns:
- Repository Pattern - Data access abstraction
- DTO Pattern - Data transfer between layers
- Dependency Injection - Loose coupling via Spring IoC
- MVC Pattern - Separation of concerns
- Singleton Pattern - Spring bean management
- Proxy Pattern - Security and AOP
- Factory Pattern - Bean creation
- Builder Pattern - Complex object construction
- Strategy Pattern - Authentication strategies
- Observer Pattern - Event handling
π Detailed Documentation: See DESIGN_PATTERNS.md for comprehensive explanations with code examples.
- Java 21 or higher
- Node.js 18 or higher
- PostgreSQL 16
- Maven 3.9+
- Docker & Docker Compose (for containerized deployment)
git clone https://github.com/yourusername/pharmacy-management-system.git
cd pharmacy-management-system# Create PostgreSQL database
createdb pharmacymanagement
# Or using psql
psql -U postgres
CREATE DATABASE pharmacymanagement;cd pharmacy-management
# Update application.properties with your database credentials
# src/main/resources/application.properties
# Build and run
./mvnw clean install
./mvnw spring-boot:runThe backend will start on http://localhost:8082
cd pharmacy_frontend
# Install dependencies
npm install
# Start development server
npm run devThe frontend will start on http://localhost:5173
# Build and start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Stop all services
docker-compose down
# Stop and remove volumes (clean slate)
docker-compose down -v- Frontend: http://localhost (port 80)
- Backend: http://localhost:8082
- Database: localhost:5432
services:
postgres: # PostgreSQL database
backend: # Spring Boot application
frontend: # React app with NginxYou can customize the deployment by setting environment variables:
# Database
POSTGRES_DB=pharmacymanagement
POSTGRES_USER=celse
POSTGRES_PASSWORD=123456
# Backend
SERVER_PORT=8082
SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/pharmacymanagementOnce the backend is running, access the API documentation at:
- Swagger UI: http://localhost:8082/swagger-ui.html
- OpenAPI JSON: http://localhost:8082/v3/api-docs
POST /api/users/register - Register new user
POST /api/users/login - Initiate login (send OTP)
POST /api/users/verify-otp - Verify OTP and get JWT
POST /api/users/logout - Logout user
GET /api/products - Get all products
GET /api/products/{id} - Get product by ID
POST /api/products - Create new product
PUT /api/products/{id} - Update product
DELETE /api/products/{id} - Delete product
GET /api/products/search - Search products
GET /api/sales - Get all sales
GET /api/sales/{id} - Get sale by ID
POST /api/sales - Create new sale
DELETE /api/sales/{id} - Delete sale
GET /api/suppliers - Get all suppliers
GET /api/suppliers/{id} - Get supplier by ID
POST /api/suppliers - Create new supplier
PUT /api/suppliers/{id} - Update supplier
DELETE /api/suppliers/{id} - Delete supplier
GET /api/stock - Get all stock items
GET /api/stock/{id} - Get stock by ID
POST /api/stock - Add stock
PUT /api/stock/{id} - Update stock
cd pharmacy-management
# Run all tests
./mvnw test
# Run specific test class
./mvnw test -Dtest=ProductServiceTest
# Run tests with coverage
./mvnw test jacoco:report
# View coverage report
open target/site/jacoco/index.html- Unit Tests: Service layer, Security utilities
- Integration Tests: REST API endpoints, Controllers
- Security Tests: JWT authentication, Authorization
π Detailed Testing Plan: See TESTING_PLAN.md
- β ProductServiceTest (8 test cases)
- β ProductControllerTest (7 test cases)
- β JwtUtilsTest (7 test cases)
- Total: 22+ test cases implemented
pharmacy-management-system/
βββ pharmacy-management/ # Backend (Spring Boot)
β βββ src/
β β βββ main/
β β β βββ java/com/example/pharmacy/
β β β β βββ config/ # Configuration classes
β β β β βββ controller/ # REST controllers
β β β β βββ dto/ # Data Transfer Objects
β β β β βββ entity/ # JPA entities
β β β β βββ repository/ # Data repositories
β β β β βββ security/ # Security components
β β β β βββ service/ # Business logic
β β β β βββ exception/ # Exception handling
β β β βββ resources/
β β β βββ application.properties
β β βββ test/ # Unit & integration tests
β βββ Dockerfile
β βββ pom.xml
β
βββ pharmacy_frontend/ # Frontend (React)
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Page components
β β βββ services/ # API services
β β βββ utils/ # Utility functions
β β βββ App.jsx
β βββ Dockerfile
β βββ nginx.conf
β βββ package.json
β
βββ docker-compose.yml # Docker orchestration
βββ DESIGN_PATTERNS.md # Design patterns documentation
βββ TESTING_PLAN.md # Testing strategy
βββ README.md # This file
- Authentication: JWT tokens with expiration
- Password Storage: BCrypt hashing
- SQL Injection: Parameterized queries via JPA
- XSS Protection: Input validation and sanitization
- CORS: Configured for specific origins
- HTTPS: Recommended for production
- Environment Variables: Sensitive data in env vars
This project follows Google's coding standards and industry best practices:
- β Clean Code: Meaningful names, small functions, clear comments
- β SOLID Principles: Single responsibility, dependency inversion
- β DRY: Don't Repeat Yourself
- β Separation of Concerns: Layered architecture
- β Error Handling: Global exception handler
- β Logging: Structured logging with SLF4J
- β Code Organization: Logical package structure
- β Documentation: Comprehensive JavaDoc and comments
- β Version Control: Clear commit messages, branching strategy
- Users: User accounts with roles
- Products: Pharmaceutical products
- Suppliers: Product suppliers
- Stock: Inventory tracking
- Sales: Sales transactions
- SaleItems: Individual sale line items
- Roles: User roles (Admin, User)
- OtpVerification: OTP codes for authentication
π ERD Diagram: See Medix Pharma ERD.png
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Your Name - Initial work
- Spring Boot team for the excellent framework
- React team for the powerful UI library
- PostgreSQL community
- All contributors and supporters
For support, email your-email@example.com or open an issue in the repository.
Made with β€οΈ using Spring Boot and React