Mnsory/PharmaCore
π PharmaCore
<div align="center">
![Build Status]() ![Latest Commit]() ![TypeScript]() ![C#]()
A comprehensive, production-ready pharmacy management system with JWT authentication, real-time inventory tracking, and role-based access control.
Features β’ Quick Start β’ Architecture β’ API Docs β’ Contributing
</div>
π Overview
PharmaCore is a full-stack pharmacy management platform designed to streamline pharmaceutical operations. It provides comprehensive tools for inventory management, supplier relationships, sales processing, stock tracking, and advanced reportingβall with enterprise-grade security and scalability.
Built with ASP.NET Core 9.0 backend, React 19 frontend, and SQL Server database, PharmaCore offers a modern, containerized architecture ready for immediate deployment.
ποΈ Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (React 19) β
β β’ Vite Build Tool β’ TailwindCSS β’ HeroUI Components β
β β’ React Router v7 β’ TanStack Query β’ Zustand State Mgmt β
ββββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββ
β HTTP/REST (8080)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Reverse Proxy (Caddy 2.0-alpine) β
β β’ TLS/HTTPS β’ Security Headers β’ Rate Limiting β
β β’ Static File Serving β’ API Routing β
ββββββββββββββββββ¬βββββββββββββββββββββββ¬βββββββββββββββββββββ
β β
ββββββββββΌβββββββββ βββββββββΌβββββββββ
β Backend API β β Frontend App β
β (Port 8080) β β (Port 80/443) β
β .NET Core 9.0 β β (via Nginx) β
ββββββββββ¬βββββββββ ββββββββββββββββββ
β
βΌ
ββββββββββββββββββββββββββββββ
β Database (SQL Server 2022)β
β β’ Entity Framework Core 9 β
β β’ Auto-Migrations β
β β’ Azure SQL Edge Support β
ββββββββββββββββββββββββββββββπ οΈ Tech Stack
π― Key Features
π¦ Inventory Management
- Real-time stock tracking with batch-level precision
- Low-stock & out-of-stock alerts
- Expiration date tracking
- Drug alternative suggestions
π€ Supplier Management
- Purchase order creation & tracking
- Partial receipt handling
- Order status workflows
π³ Sales & POS
- Transaction processing
- Multi-drug sales
- Sales cancellation with stock reversal
π Security
- JWT authentication with refresh tokens
- Role-based access control
- Rate limiting (100 req/min, 5 login attempts/30min)
- Security headers & CORS protection
π Dashboard
- Real-time metrics
- Low-stock alerts
- Sales trends & performance
π Data Recovery
- Automatic backups
- Hugging Face integration
- Auto-migrations
π Quick Start
Option 1: Docker Compose (Recommended)
git clone https://github.com/mnsoory/PharmaCore.git
cd PharmaCore
cp .env.example .env
docker-compose up -dAccess at: https://mnsory-pharmacore.hf.space/
Option 2: Local Development
Backend:
cd backend
dotnet restore
dotnet ef database update
dotnet runFrontend:
cd frontend
npm install --legacy-peer-deps
npm run devβοΈ Configuration
Create .env file:
MSSQL_SA_PASSWORD=YourStrongPassword123!
JWT_SECRET=your-super-secret-key-at-least-32-chars-long
JWT_ISSUER=PharmaCore
JWT_AUDIENCE=PharmaCore
JWT_EXPIRY_MINUTES=60
HF_TOKEN=your_hugging_face_token # Optionalπ‘ API Documentation
Access Swagger UI at: /swagger
Core Endpoints
Authentication (/api/users)
- POST
/register- Register user - POST
/login- Authenticate - POST
/refresh- Refresh token - POST
/change-password- Update password
Inventory (/api/drugs, /api/stock-batches)
- GET
/api/drugs- List drugs - GET
/api/stock-batches/low-stock- Low stock alerts - GET
/api/stock-batches/expiring-soon- Expiration alerts
Sales (/api/sales)
- GET
/api/sales- List transactions - POST
/api/sales- Process sale - DELETE
/api/sales/{id}- Cancel sale
Purchase Orders (/api/purchase-orders)
- GET
/api/purchase-orders- List orders - POST
/api/purchase-orders- Create order - PUT
/api/purchase-orders/{id}- Update order
Rate Limiting
π Project Structure
PharmaCore/
βββ backend/
β βββ PharmaCore.API/ # REST API Layer
β β βββ Controllers/ # 11 API endpoints
β β βββ Filters/ # Authorization filters
β β βββ Middlewares/ # Error handling
β β βββ Program.cs # Service setup
β βββ PharmaCore.Application/ # Business logic
β β βββ Services/ # Domain services
β β βββ Mappings/ # AutoMapper profiles
β βββ PharmaCore.Core/ # Domain models
β β βββ Entities/ # Database models
β β βββ Interfaces/ # Contracts
β β βββ Enums/ # Types
β βββ PharmaCore.Infrastructure/ # Data access
β βββ Data/ # DbContext
β βββ Repositories/ # Data layer
β βββ Migrations/ # Database schema
βββ frontend/
β βββ src/
β β βββ pages/ # Route pages
β β βββ components/ # React components
β β βββ services/ # API calls
β β βββ api/ # API clients
β β βββ store/ # Zustand stores
β β βββ hooks/ # Custom hooks
β β βββ types/ # TypeScript types
β β βββ utils/ # Utilities
β β βββ App.tsx # Root component
β βββ package.json
β βββ vite.config.ts
β βββ tsconfig.json
βββ docker-compose.yml
βββ Dockerfile
βββ backend.Dockerfile
βββ frontend.Dockerfile
βββ Caddyfile
βββ run.sh
βββ .env.example
βββ README.mdπ€ Contributing
Workflow
- Fork the repository
- Create feature branch:
git checkout -b feature/your-feature - Commit with conventional commits:
git commit -m "feat(scope): description" - Push branch:
git push origin feature/your-feature - Submit Pull Request
Commit Convention
<type>(<scope>): <subject>
<body>Types: feat, fix, refactor, docs, test, chore
Examples:
feat(auth): implement JWT refresh token rotation
fix(purchase-order): resolve stock data corruption
refactor(frontend): centralize API error handlingRecent Improvements
- β¨ Centralized API error handling
- π Comprehensive endpoint authorization
- π Swagger auto-documentation for 401/403
- π Fixed stock data corruption
- π¨ Optimized UI layout & z-indexing
π¨βπ» Author
Mohamed Almansoury (@mnsoory)
- GitHub: github.com/mnsoory
- Email: mohamed.almansoury8@gmail.com
β Troubleshooting
Port Already in Use
lsof -ti:7860 | xargs kill -9Database Connection Failed
docker-compose ps
docker-compose logs dbFrontend Build Issues
cd frontend
rm -rf node_modules package-lock.json
npm install --legacy-peer-deps
npm run build<div align="center">
Made with β€οΈ by Mohamed Almansoury
β Star this repo if you find it useful!
</div>
