Skip to content

punitcx/Pharmacy-SwasthiQ

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pharmacy EMR System - SwasthiQ (SDE Intern Assignment)

image image image

REST API Structure

The APIs are mainly classified into two categories: Inventory and Dashboard.

Inventory APIs

Method Endpoint Description
GET /inventory/overview Inventory Overview
GET /inventory/ List Medicines
POST /inventory/ Add Medicine
PUT /inventory/{medicine_id} Update Medicine

Dashboard APIs

Method Endpoint Description
POST /dashboard/make-sale Make Sale
GET /dashboard/total-sales Get Sales Summary
GET /dashboard/items-sold Get Items Sold
GET /dashboard/recent-sales Get Recent Sales
GET /dashboard/low-stock Get Low Stock
GET /dashboard/purchase-orders Get Purchase Orders

Repository Structure

Pharmacy-SwasthiQ/
│
├── backend/
├── frontend/
├── LICENSE
└── README.md

Backend (FastAPI – Python)

The backend is implemented using FastAPI for REST API development, SQLAlchemy for ORM-based database interaction, Pydantic for validation, and PostgreSQL as the database. The database URL is configured using environment variables for deployment.

Swagger UI for testing: https://pharmacy-fastapi-backend.onrender.com/docs

Backend Folder Structure

backend/
│
├── main.py
├── database.py
├── models.py
├── schemas.py
├── crud.py
├── requirements.txt
├── generate_inventory.sh
│
└── routers/
    ├── dashboard.py
    └── inventory.py
  • main.py – Entry point of the FastAPI application. Initializes the app and includes API routers.
  • database.py – Handles database connection setup using SQLAlchemy with environment variable configuration.
  • models.py – Defines database tables and ORM models.
  • schemas.py – Contains Pydantic models for request validation and structured API responses.
  • crud.py – Contains core business logic and database operations. The logic to check and update medicine status, reduce stock after sales, and maintain consistency is written here. All update operations are handled through controlled transactional sessions.
  • routers/dashboard.py – Defines dashboard-related endpoints such as total sales, items sold, low stock, purchase summary, and recent sales.
  • routers/inventory.py – Defines inventory-related endpoints to list, add, update, and manage medicines.
  • generate_inventory.sh – Script to seed the database with sample medicine data for demonstration and testing.

Medicine Status and Update Logic

The logic to determine and update medicine status such as Active, Low Stock, Expired, or Out of Stock is implemented in crud.py. This file contains the main business logic that recalculates medicine status based on quantity and expiry date and ensures consistent updates when inventory changes occur through API operations.


Frontend (React – Vite)

The frontend is developed using React and Vite. React Router DOM is used for routing and navigation. The frontend communicates with the backend using a configurable environment variable for the API base URL.

Frontend Folder Structure

frontend/
│
├── src/
│   ├── App.jsx
│   ├── config.js
│   ├── main.jsx
│   ├── pages/
│   │   ├── Dashboard.jsx
│   │   ├── Inventory.jsx
│   │   ├── RecentSalesSection.jsx
│   │   └── respective CSS files
  • App.jsx – Contains main routing logic for the application.
  • config.js – Stores backend base URL using the VITE_API_URL environment variable.
  • Dashboard.jsx – Displays dashboard overview cards and provides toggle navigation between Sales and Inventory views.
  • Inventory.jsx – Displays inventory overview and complete medicine list with status indicators and update functionality.
  • RecentSalesSection.jsx – Displays recent sales data fetched from the backend.
  • Each page has its respective CSS file for layout and styling consistency.

About

SwasthiQ Assignment application (Pharmacy Store) made with React Frontend and FastAPI Backend.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors