An AI-powered procurement dashboard for pharmacies. Mira, the built-in assistant, monitors supplier emails, surfaces critical alerts (stock-outs, delivery delays, price changes, cancellations), and helps procurement teams review and send purchase orders.
- Rx Deck — live feed of supplier email events parsed into actionable alerts
- PO Queue — review, edit, and confirm purchase orders with SKU-level reasoning
- Order Run — send confirmed POs to suppliers via Gmail in one click
- Mira Chat — conversational assistant with full procurement context
- Studio — internal data editor for demo and development scenarios
- Next.js 16 (App Router, Turbopack)
- NextAuth.js — Google OAuth sign-in
- Groq — fast inference (email parsing, chat)
- Gmail API — reading supplier emails and sending POs
- Zustand — client state
- Framer Motion — animations
- Tailwind CSS + SCSS modules
- Storybook — component development
- Vitest + Playwright — testing
- Yarn
- Node.js 18+
- Yarn 1.22+
- A Google Cloud project (free tier is fine)
- A Groq API key (free at console.groq.com)
git clone https://github.com/Yevhenbk/pharmchat.git
cd pharmchat
yarn installcp .env.example .env.localFill in each value as described below.
Set to true for local development. Enables demo data and bypasses production guards.
NEXT_PUBLIC_ENV_IS_LOCAL=true
Used to parse incoming supplier emails and power the Mira chat assistant.
- Go to console.groq.com/keys
- Sign up (free) and create an API key
- Paste it in:
GROQ_API_KEY=gsk_...
The app uses Gmail to read supplier emails and send purchase orders. This requires an OAuth 2.0 credential from Google Cloud. The same credential also powers the Sign in with Google button via NextAuth.
- Go to console.cloud.google.com
- Click the project dropdown → New Project → give it a name (e.g.
pharmchat) - Select the project once created
- In the left sidebar go to APIs & Services → Library
- Search for Gmail API and click Enable
- Go to APIs & Services → OAuth consent screen
- Choose External → Create
- Fill in:
- App name:
PharmChat - User support email: your Gmail address
- Developer contact: your Gmail address
- App name:
- Click Save and Continue through the remaining steps
- On the Test users step, add your Gmail address as a test user
- Save
- Go to APIs & Services → Credentials
- Click + Create Credentials → OAuth client ID
- Application type: Web application
- Name:
PharmChat Web - Under Authorised redirect URIs, add:
http://localhost:3000/api/auth/callback/google - Click Create
- Copy the Client ID and Client Secret into
.env.local:
GMAIL_CLIENT_ID=your_client_id.apps.googleusercontent.com
GMAIL_CLIENT_SECRET=your_client_secret
This token lets the server send emails on behalf of your account without a live user session. Use Google's OAuth Playground:
- Go to developers.google.com/oauthplayground
- Click the gear icon (top right) → check Use your own OAuth credentials
- Enter your Client ID and Client Secret from Step 4
- In the left panel, select these two scopes:
https://www.googleapis.com/auth/gmail.readonly https://www.googleapis.com/auth/gmail.send - Click Authorize APIs → sign in with your Gmail account → allow access
- Click Exchange authorization code for tokens
- Copy the Refresh token into
.env.local:
GMAIL_REFRESH_TOKEN=1//0...
GMAIL_USER_EMAIL=you@gmail.com
NEXTAUTH_URL=http://localhost:3000
Generate a secure secret:
openssl rand -base64 32Paste the output as:
NEXTAUTH_SECRET=your_generated_secret
Used to fetch drug shortage data from the OpenFDA API.
- Register at open.fda.gov/apis/authentication
- Paste the key in:
FDA_API_KEY=your_fda_api_key
The app works without this key — shortage data will simply be unavailable.
yarn devOpen http://localhost:3000. Sign in with the Gmail account you added as a test user in Step 3.
| Command | Description |
|---|---|
yarn build |
Production build |
yarn start |
Start production server |
yarn test |
Run unit tests (Vitest) |
yarn test:e2e |
Run end-to-end tests (Playwright) |
yarn storybook |
Launch Storybook on port 6006 |
yarn lint |
Run ESLint |
yarn format |
Format with Prettier |
app/
├── api/ # Next.js API routes
│ ├── auth/ # NextAuth Google provider
│ ├── emails/ # Gmail inbox reader
│ ├── send-po/ # Send PO via Gmail
│ ├── mira-chat/ # Mira chat
│ ├── parse-supplier-emails/
│ ├── analyze-action-emails/
│ └── shortages/ # FDA drug shortage data
├── components/
│ ├── blocks/ # Feature-level components (each with .stories.tsx + .test.tsx)
│ ├── ui/ # Primitive UI components
│ ├── icons/ # SVG icon components
│ └── animations/ # Motion wrapper components
├── constants/ # Shared constants (API routes, etc.)
├── demo/ # Mock data for development and Storybook
├── hooks/ # Custom React hooks
├── models/ # TypeScript interfaces
├── providers/ # React context providers
├── services/ # Business logic
├── stores/ # Zustand state stores
├── styles/ # Global CSS tokens and theme
└── studio/ # Internal data editor (dev only)
- The app ships with demo data so all UI is visible on first load — no real emails or API keys are needed to explore the interface.
- To connect real Gmail: complete the OAuth setup above and sign in with your Google account.
- The OAuth consent screen stays in Testing mode until published. Only accounts added as test users can sign in while in testing mode.