AWS Builder Center

Building PharmaStock: A Serverless Multi-Vendor Inventory & Bedrock AI Analytics SaaS on AWS

Managing retail pharmacy operations manually often leads to stockouts, inventory waste, and overlooked medicine batch expiries. For the AWS Bharat Builds Tour ("First Commit") hackathon, I set out to solve this real-world problem by building PharmaStock—a serverless inventory management and AI-driven business analytics platform built entirely on AWS.

🏗️ System Architecture & Stack PharmaStock is built using a modern, decoupled serverless architecture on AWS:
Compute (AWS Lambda): Python-based microservices handle stock updates, CRUD operations, and prompt orchestration.
Database (Amazon DynamoDB): A high-throughput single-table schema (PharmacyInventory) tracking stock quantities, batch details, expiration dates, rack locations, and unit pricing.
API Layer (Amazon API Gateway): Manages REST API endpoints connecting the frontend interface to backend Lambda functions with CORS enabled.
Generative AI (Amazon Bedrock): Utilizes amazon.titan-text-express-v1 to evaluate live DynamoDB stock levels and stream real-time operational advice.
Authentication: Integrated Firebase Auth for secure multi-tenant pharmacy login and access control.
Hosting (Amazon EC2): Front-end static assets (index.html, style.css, app.js) deployed on an Amazon Linux 2023 EC2 instance running Nginx.
💡 Key Features & AI Business Insights
  1. Real-Time Stock Management Pharmacy staff can quickly view live inventory counts, search for specific medications, receive incoming batch stock, or dispense sales directly from an enterprise dashboard. Items with critical quantities (less than 10 units) are highlighted with automated visual badges to prevent stockouts.
  1. Intelligent AI Recommendations via Amazon Bedrock Instead of requiring manual stock audits, PharmaStock leverages Amazon Bedrock (Titan Text Express) to automatically analyze DynamoDB inventory state and provide instant actionable guidance:
Low Stock Alerts: Automatically flags fast-moving medications that require immediate reordering.
Expiry Management: Recommends clearance or rotation strategies for batches nearing expiration.
Shelf Optimization: Suggests reorganizing high-demand items based on rack locations.
  1. Smart Resiliency & Fallback To ensure maximum uptime during network or quota restrictions, the AWS Lambda backend includes a smart fallback engine. If Bedrock API calls encounter region latency, the system instantly generates localized analysis based on live DynamoDB metrics—ensuring zero interface crashes or service interruption.
🚀 Live Deployment & Next Steps The entire platform is deployed live on AWS, serving real-time requests directly from an Amazon Linux 2023 EC2 instance behind an Nginx web server.
Looking beyond the hackathon, the project roadmap includes expanding DynamoDB schemas with composite primary keys (medicine_id + batch_number) to support First-Expired, First-Out (FEFO) dispensing rules across multi-batch stock arrivals. #BharatBuilds
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article