How vinonachi/pharma_inventory works
PharmaIQ is a pharmaceutical distribution management application with inventory, purchasing, sales, supplier, warehouse, reporting, forecasting, analytics, and AI-assistant/agent capabilities. Users enter through the web interface; the FastAPI backend exposes domain APIs, with sales explicitly allocating stock from soonest-expiring batches. Database initialization seeds the operational data. The README is empty, and frontend page-to-API wiring was not visible in the excerpts, so those links are left unverified rather than presented as confirmed calls.
Main entry points: main.py FastAPI application · ai_query_router.py Grounded query tools · auto_seed.py Schema and seeding · database.py Database sessions
Components 32
Web application
- Operations pages
frontend/app - Login page
frontend/app/login/page.tsx - Auth client
frontend/lib/auth.ts - API client
frontend/lib/api.ts
API and operations
- FastAPI application
backend/app/main.py - Authentication
backend/app/routers/auth.py - Medicine catalog
backend/app/routers/medicines.py - Purchasing
backend/app/routers/purchases.py - Sales
backend/app/routers/sales.py - Inventory
backend/app/routers/inventory.py - Suppliers
backend/app/routers/suppliers.py - Warehouses
backend/app/routers/warehouses.py - Dashboard
backend/app/routers/dashboard.py
Analytics and AI
- Analytics
backend/app/routers/analytics.py - Demand forecasting
backend/app/routers/forecasting.py - Reports
backend/app/routers/reports.py - AI assistant
backend/app/routers/ai_assistant.py - Agent cycle API
backend/app/routers/agent.py - Grounded query tools
backend/app/services/ai_query_router.py - Agent engine
backend/app/services/agent_engine.py - FEFO allocator
backend/app/services/fefo_allocator.py - Expiry alerts
backend/app/services/expiry_alerts.py - Forecast service
backend/app/services/demand_forecast.py - Report generator
backend/app/services/report_generator.py - Supplier scorecard
backend/app/services/supplier_scorecard.py
Data and access
- Database sessions
backend/app/database.py - Domain models
backend/app/models/core.py - Schema and seeding
backend/app/core/auto_seed.py - Password and tokens
backend/app/core/security.py - Role authorization
backend/app/core/rbac.py
Other components
- Staff or admin
- SQL database
Connections 37
- Staff or admin → Operations pages: uses
- Staff or admin → Login page: signs in
- Login page → Auth client: uses
- Auth client → API client: gets base URL
frontend/lib/auth.ts - API client → FastAPI application: sends API requests
- FastAPI application → Authentication: mounts
backend/app/main.py - FastAPI application → Medicine catalog: mounts
backend/app/main.py - FastAPI application → Purchasing: mounts
backend/app/main.py - FastAPI application → Sales: mounts
backend/app/main.py - FastAPI application → Inventory: mounts
backend/app/main.py - FastAPI application → Suppliers: mounts
backend/app/main.py - FastAPI application → Warehouses: mounts
backend/app/main.py - FastAPI application → Dashboard: mounts
backend/app/main.py - FastAPI application → Analytics: mounts
backend/app/main.py - FastAPI application → Demand forecasting: mounts
backend/app/main.py - FastAPI application → Reports: mounts
backend/app/main.py - FastAPI application → AI assistant: mounts
backend/app/main.py - FastAPI application → Agent cycle API: mounts
backend/app/main.py - FastAPI application → Schema and seeding: initializes on startup
backend/app/main.py - Authentication → Database sessions: opens session
backend/app/routers/auth.py - Authentication → Password and tokens: verifies and signs
backend/app/routers/auth.py - Sales → FEFO allocator: allocates batches
backend/app/routers/sales.py - Sales → Database sessions: reads and writes
backend/app/routers/sales.py - Agent cycle API → Agent engine: invokes
backend/app/routers/agent.py - Agent engine → Grounded query tools: uses grounded tools
backend/app/services/agent_engine.py - Grounded query tools → Expiry alerts: calls
backend/app/services/ai_query_router.py - Grounded query tools → FEFO allocator: calls
backend/app/services/ai_query_router.py - Grounded query tools → Supplier scorecard: calls
backend/app/services/ai_query_router.py - AI assistant → Grounded query tools: routes queries
backend/app/routers/ai_assistant.py - Analytics → Expiry alerts: uses
backend/app/routers/analytics.py - Analytics → FEFO allocator: uses
backend/app/routers/analytics.py - Demand forecasting → Forecast service: uses
backend/app/routers/forecasting.py - Reports → Report generator: uses
backend/app/routers/reports.py - Schema and seeding → Database sessions: creates schema
backend/app/core/auto_seed.py - Schema and seeding → Domain models: loads models
backend/app/core/auto_seed.py - Schema and seeding → Password and tokens: hashes passwords
backend/app/core/auto_seed.py - Database sessions → SQL database: connects to
backend/app/database.py