{"id":19509496,"url":"https://github.com/yevhenbk/pharmchat","last_synced_at":"2026-04-27T00:32:04.252Z","repository":{"id":225539781,"uuid":"766225585","full_name":"Yevhenbk/pharmchat","owner":"Yevhenbk","description":"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","archived":false,"fork":false,"pushed_at":"2026-03-25T10:51:45.000Z","size":1673,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-26T13:46:43.563Z","etag":null,"topics":["auth","fda-api","gmail-api","google-api","groq","nextjs","open-assistant"],"latest_commit_sha":null,"homepage":"https://pharmchat-procurement.vercel.app/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Yevhenbk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-03-02T17:17:25.000Z","updated_at":"2026-03-25T10:51:49.000Z","dependencies_parsed_at":"2024-11-10T23:12:20.353Z","dependency_job_id":"d0778156-858e-4cb4-b5e3-aea4f1cea30d","html_url":"https://github.com/Yevhenbk/pharmchat","commit_stats":null,"previous_names":["yevhenbk/pharmchat"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/Yevhenbk/pharmchat","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yevhenbk%2Fpharmchat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yevhenbk%2Fpharmchat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yevhenbk%2Fpharmchat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yevhenbk%2Fpharmchat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Yevhenbk","download_url":"https://codeload.github.com/Yevhenbk/pharmchat/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Yevhenbk%2Fpharmchat/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32318417,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"ssl_error","status_checked_at":"2026-04-26T23:26:25.802Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["auth","fda-api","gmail-api","google-api","groq","nextjs","open-assistant"],"created_at":"2024-11-10T23:12:10.122Z","updated_at":"2026-04-27T00:32:04.227Z","avatar_url":"https://github.com/Yevhenbk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PharmChat — Procurement Dashboard\n\nAn 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.\n\n## Features\n\n- **Rx Deck** — live feed of supplier email events parsed into actionable alerts\n- **PO Queue** — review, edit, and confirm purchase orders with SKU-level reasoning\n- **Order Run** — send confirmed POs to suppliers via Gmail in one click\n- **Mira Chat** — conversational assistant with full procurement context\n- **Studio** — internal data editor for demo and development scenarios\n\n## Tech Stack\n\n- [Next.js 16](https://nextjs.org) (App Router, Turbopack)\n- [NextAuth.js](https://next-auth.js.org) — Google OAuth sign-in\n- [Groq](https://groq.com) — fast inference (email parsing, chat)\n- Gmail API — reading supplier emails and sending POs\n- [Zustand](https://zustand-demo.pmnd.rs) — client state\n- [Framer Motion](https://www.framer.com/motion/) — animations\n- [Tailwind CSS](https://tailwindcss.com) + SCSS modules\n- [Storybook](https://storybook.js.org) — component development\n- [Vitest](https://vitest.dev) + [Playwright](https://playwright.dev) — testing\n- Yarn\n\n---\n\n## Prerequisites\n\n- Node.js 18+\n- Yarn 1.22+\n- A Google Cloud project (free tier is fine)\n- A Groq API key (free at [console.groq.com](https://console.groq.com/keys))\n\n---\n\n## Setup\n\n### 1. Clone and install\n\n```bash\ngit clone https://github.com/Yevhenbk/pharmchat.git\ncd pharmchat\nyarn install\n```\n\n### 2. Create your environment file\n\n```bash\ncp .env.example .env.local\n```\n\nFill in each value as described below.\n\n---\n\n## Environment Variables\n\n### `NEXT_PUBLIC_ENV_IS_LOCAL`\n\nSet to `true` for local development. Enables demo data and bypasses production guards.\n\n```\nNEXT_PUBLIC_ENV_IS_LOCAL=true\n```\n\n---\n\n### `GROQ_API_KEY`\n\nUsed to parse incoming supplier emails and power the Mira chat assistant.\n\n1. Go to [console.groq.com/keys](https://console.groq.com/keys)\n2. Sign up (free) and create an API key\n3. Paste it in:\n\n```\nGROQ_API_KEY=gsk_...\n```\n\n---\n\n### Gmail OAuth 2.0 — Full Setup\n\nThe 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.\n\n#### Step 1 — Create a Google Cloud project\n\n1. Go to [console.cloud.google.com](https://console.cloud.google.com)\n2. Click the project dropdown → **New Project** → give it a name (e.g. `pharmchat`)\n3. Select the project once created\n\n#### Step 2 — Enable the Gmail API\n\n1. In the left sidebar go to **APIs \u0026 Services → Library**\n2. Search for **Gmail API** and click **Enable**\n\n#### Step 3 — Configure the OAuth consent screen\n\n1. Go to **APIs \u0026 Services → OAuth consent screen**\n2. Choose **External** → **Create**\n3. Fill in:\n   - App name: `PharmChat`\n   - User support email: your Gmail address\n   - Developer contact: your Gmail address\n4. Click **Save and Continue** through the remaining steps\n5. On the **Test users** step, add your Gmail address as a test user\n6. Save\n\n#### Step 4 — Create OAuth 2.0 credentials\n\n1. Go to **APIs \u0026 Services → Credentials**\n2. Click **+ Create Credentials → OAuth client ID**\n3. Application type: **Web application**\n4. Name: `PharmChat Web`\n5. Under **Authorised redirect URIs**, add:\n   ```\n   http://localhost:3000/api/auth/callback/google\n   ```\n6. Click **Create**\n7. Copy the **Client ID** and **Client Secret** into `.env.local`:\n\n```\nGMAIL_CLIENT_ID=your_client_id.apps.googleusercontent.com\nGMAIL_CLIENT_SECRET=your_client_secret\n```\n\n#### Step 5 — Get a Gmail refresh token\n\nThis token lets the server send emails on behalf of your account without a live user session. Use Google's OAuth Playground:\n\n1. Go to [developers.google.com/oauthplayground](https://developers.google.com/oauthplayground)\n2. Click the gear icon (top right) → check **Use your own OAuth credentials**\n3. Enter your **Client ID** and **Client Secret** from Step 4\n4. In the left panel, select these two scopes:\n   ```\n   https://www.googleapis.com/auth/gmail.readonly\n   https://www.googleapis.com/auth/gmail.send\n   ```\n5. Click **Authorize APIs** → sign in with your Gmail account → allow access\n6. Click **Exchange authorization code for tokens**\n7. Copy the **Refresh token** into `.env.local`:\n\n```\nGMAIL_REFRESH_TOKEN=1//0...\nGMAIL_USER_EMAIL=you@gmail.com\n```\n\n---\n\n### `NEXTAUTH_URL` and `NEXTAUTH_SECRET`\n\n```\nNEXTAUTH_URL=http://localhost:3000\n```\n\nGenerate a secure secret:\n\n```bash\nopenssl rand -base64 32\n```\n\nPaste the output as:\n\n```\nNEXTAUTH_SECRET=your_generated_secret\n```\n\n---\n\n### `FDA_API_KEY` (optional)\n\nUsed to fetch drug shortage data from the OpenFDA API.\n\n1. Register at [open.fda.gov/apis/authentication](https://open.fda.gov/apis/authentication/)\n2. Paste the key in:\n\n```\nFDA_API_KEY=your_fda_api_key\n```\n\nThe app works without this key — shortage data will simply be unavailable.\n\n---\n\n## Running the app\n\n```bash\nyarn dev\n```\n\nOpen [http://localhost:3000](http://localhost:3000). Sign in with the Gmail account you added as a test user in Step 3.\n\n---\n\n## Other commands\n\n| Command | Description |\n|---|---|\n| `yarn build` | Production build |\n| `yarn start` | Start production server |\n| `yarn test` | Run unit tests (Vitest) |\n| `yarn test:e2e` | Run end-to-end tests (Playwright) |\n| `yarn storybook` | Launch Storybook on port 6006 |\n| `yarn lint` | Run ESLint |\n| `yarn format` | Format with Prettier |\n\n---\n\n## Project structure\n\n```\napp/\n├── api/                  # Next.js API routes\n│   ├── auth/             # NextAuth Google provider\n│   ├── emails/           # Gmail inbox reader\n│   ├── send-po/          # Send PO via Gmail\n│   ├── mira-chat/        # Mira chat\n│   ├── parse-supplier-emails/\n│   ├── analyze-action-emails/\n│   └── shortages/        # FDA drug shortage data\n├── components/\n│   ├── blocks/           # Feature-level components (each with .stories.tsx + .test.tsx)\n│   ├── ui/               # Primitive UI components\n│   ├── icons/            # SVG icon components\n│   └── animations/       # Motion wrapper components\n├── constants/            # Shared constants (API routes, etc.)\n├── demo/                 # Mock data for development and Storybook\n├── hooks/                # Custom React hooks\n├── models/               # TypeScript interfaces\n├── providers/            # React context providers\n├── services/             # Business logic\n├── stores/               # Zustand state stores\n├── styles/               # Global CSS tokens and theme\n└── studio/               # Internal data editor (dev only)\n```\n\n---\n\n## Notes\n\n- 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.\n- To connect real Gmail: complete the OAuth setup above and sign in with your Google account.\n- The OAuth consent screen stays in **Testing** mode until published. Only accounts added as test users can sign in while in testing mode.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyevhenbk%2Fpharmchat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyevhenbk%2Fpharmchat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyevhenbk%2Fpharmchat/lists"}