A robust, secure, and scalable backend API for managing a pharmacy's inventory, sales, and users. Built with Go and the Gin framework.
- Authentication & Authorization: Role-based access control (Admin, Pharmacist, Customer) using JWT.
- Inventory Management: Full CRUD operations for medicines, including batch tracking and expiry dates.
- Advanced Search: Fuzzy search functionality to find medicines by name, category, or manufacturer.
- Sales & Orders: Automated stock deduction upon purchase with transaction history.
- Smart Reporting: Low-stock alerts and sales performance tracking.
- Data Integrity: Auto-migrating SQLite database schema.
- Language: Go (Golang)
- Framework: Gin Gonic (HTTP Web Framework)
- Database: SQLite (with GORM-ready structure)
- Security: JWT (JSON Web Tokens) & Bcrypt password hashing
├── cmd/
│ └── api/ # Application entry point (main.go)
├── internal/
│ ├── auth/ # JWT and Password logic
│ ├── database/ # DB connection and migrations
│ ├── handlers/ # Request controllers
│ ├── middleware/ # Role-based protection
│ └── models/ # Database schemas
├── pharma.db # SQLite database (ignored by git)
└── .env # Configuration (ignored by git)
- Clone the repository:
git clone [https://github.com/arvtia/BackendServices.git](https://github.com/arvtia/BackendServices.git)
cd BackendServices
- Install dependencies:
go mod tidy
- Configure Environment Variables:
Create a
.envfile in the root directory:
PORT=8080
JWT_SECRET=your_super_secret_key
DB_PATH=pharma.db
- Run the application:
go run cmd/api/main.go
| Method | Endpoint | Access | Description |
|---|---|---|---|
POST |
/api/v1/auth/register |
Public | Create a new account |
POST |
/api/v1/auth/login |
Public | Get JWT Token |
GET |
/api/v1/medicines/search |
All Roles | Search inventory |
POST |
/api/v1/orders |
Customer | Place a new order |
GET |
/api/admin/reports/low-stock |
Admin | Check inventory alerts |
PATCH |
/api/admin/medicines/:id |
Admin | Partial update of medicine |
Developed by arvtia
### How to push this to your GitHub:
Since this is a new file, you need to tell Git to upload it:
1. **Stage the file**:
```bash
git add README.md
```
2. **Commit it**:
```bash
git commit -m "Docs: Added professional README with setup instructions"
```
3. **Push it**:
```bash
git push
```