CoolFace
Apppublic

Mnsory/PharmaCore

sourceHugging Faceupdated 4mo agoView on Hugging Face
0likes
App README

πŸ’Š 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

LayerTechnologyVersionPurpose
FrontendReact^19.2.5UI Framework
Vite^8.0.9Build Tool
TailwindCSS^4.2.2Styling
HeroUI^3.0.3Components
Zustand^5.0.12State Management
TanStack Query^5.100.5Data Fetching
Axios^1.15.1HTTP Client
React Router^7.14.1Routing
TypeScript~6.0.2Language
BackendASP.NET Core9.0API Server
Entity Framework Core9.0.14ORM
JWT Bearer9.0.14Authentication
BCrypt.Net-Next4.1.0Hashing
AutoMapper16.1.1Mapping
Swagger10.1.7Documentation
DatabaseSQL Server2022Database
DevOpsDockerLatestContainers
Docker ComposeLatestOrchestration
Caddy2-alpineReverse Proxy
GitHub Actions-CI/CD

🎯 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)

bash
git clone https://github.com/mnsoory/PharmaCore.git
cd PharmaCore
cp .env.example .env
docker-compose up -d

Access at: https://mnsory-pharmacore.hf.space/

Option 2: Local Development

Backend:

bash
cd backend
dotnet restore
dotnet ef database update
dotnet run

Frontend:

bash
cd frontend
npm install --legacy-peer-deps
npm run dev

βš™οΈ Configuration

Create .env file:

env
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

PolicyLimitWindow
Global100 req1 min
Login5 attempts30 min
Password Change3 attempts15 min

πŸ“ 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

  1. 1.Fork the repository
  2. 2.Create feature branch: git checkout -b feature/your-feature
  3. 3.Commit with conventional commits: git commit -m "feat(scope): description"
  4. 4.Push branch: git push origin feature/your-feature
  5. 5.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 handling

Recent 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)


❓ Troubleshooting

Port Already in Use

bash
lsof -ti:7860 | xargs kill -9

Database Connection Failed

bash
docker-compose ps
docker-compose logs db

Frontend Build Issues

bash
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>