How bhoomika7860/suvidha works
Purpose and Entry Points
PharmaCore360 is a role-based pharmacy/store operations system: daily sales reporting, purchasing, deliveries, expenses, receivables (“udhaar”), staff tasks, multi-store management, analytics, exports, and audit history. The React SPA starts at frontend/src/main.jsx, composes application state in frontend/src/App.jsx, and maps protected role-specific views through frontend/src/routes/AppRoutes.jsx. The FastAPI backend is bootstrapped by backend/app/main.py.
Frontend Application Shell and Access Control
Authentication state is centralized in frontend/src/contexts/AuthContext.jsx and consumed through frontend/src/hooks/useAuth.js. Route access is gated by frontend/src/routes/ProtectedRoute.jsx and frontend/src/components/auth/ProtectedRoute.jsx; layout differs for manager, owner, and staff roles via frontend/src/components/layout/ManagerLayout.jsx, frontend/src/components/layout/OwnerLayout.jsx, and frontend/src/components/layout/StaffLayout.jsx. API communication is centralized in frontend/src/api/api.js, with domain-specific service adapters under frontend/src/services/.
Backend API, Authentication, and Authorization
FastAPI routes expose the domain API from backend/app/routes/, with login/auth endpoints in backend/app/routes/auth.py. Token creation/validation and password/security mechanics are separated into backend/app/core/token.py and backend/app/core/security.py. Endpoint-level identity and role enforcement flow through backend/app/dependencies/auth.py and backend/app/dependencies/roles.py, forming the primary trust boundary between browser clients and business data.
Persistence and Domain Model
Database setup is owned by backend/app/database.py; persistent entities are organized as ORM models in backend/app/models/, with request/response contracts in parallel under backend/app/schemas/. The core operational aggregate is daily reporting (backend/app/models/daily_report.py), connected to sales/payment capture, purchases, expenses, deliveries, and udhaar. Related accounting/operations records include backend/app/models/payment_machine_entry.py, backend/app/models/purchase.py, and backend/app/models/expense.py.
Daily Reporting and Financial Operations Flow
Manager/staff workflows assemble a daily report through frontend/src/pages/manager/DailyReport.jsx and modular entry sections such as frontend/src/components/dailyReport/SalesSection.jsx, frontend/src/components/dailyReport/PurchaseSection.jsx, and frontend/src/components/dailyReport/ExpenseSection.jsx. These invoke corresponding backend resources, principally backend/app/routes/daily_reports.py, backend/app/routes/purchase.py, and backend/app/routes/expenses.py. Owners consume completed/history detail through frontend/src/pages/owner/DailyReports.jsx and frontend/src/pages/owner/ReportDetails.jsx.
Operational Workflows
Deliveries are recorded and assigned through backend/app/routes/deliveries.py and backend/app/routes/delivery_assignments.py, surfaced in frontend/src/pages/delivery/Delivery.jsx. Purchasing includes both received purchases and purchase orders, backed by backend/app/routes/purchase.py and backend/app/routes/purchase_orders.py. Staff coordination is modeled through backend/app/models/task.py and exposed through backend/app/routes/tasks.py, with role-specific pages including frontend/src/pages/staff/StaffTasks.jsx.
Oversight, Reporting, and Integrations
Analytics, export, and audit functions provide owner/manager oversight through backend/app/routes/analytics.py, backend/app/routes/export.py, and backend/app/routes/audit_logs.py; export generation is isolated in backend/app/services/export_service.py. Bill and delivery evidence cross the API/file boundary via upload directories backend/app/uploads/bills and backend/app/uploads/delivery_bills. The frontend includes Firebase setup and a messaging service worker at frontend/src/firebase.js and frontend/public/firebase-messaging-sw.js, indicating Firebase-based notifications. Deployment-facing artifacts include frontend/vercel.json; backend runtime dependencies are declared in backend/requirements.txt.
Main entry points: ProtectedRoute.jsx Protected access · api.js API client · auth.py Identity & role enforcement · App.jsx App state shell
Components 21
React SPA
- SPA entry
frontend/src/main.jsx - App state shell
frontend/src/App.jsx - Auth state
frontend/src/contexts/AuthContext.jsx - Role-specific routes
frontend/src/routes/AppRoutes.jsx - Protected access · Enforces authenticated role access before views load.
frontend/src/routes/ProtectedRoute.jsx - Role layouts · Manager, owner, and staff shells.
frontend/src/components/layout/ManagerLayout.jsx - Daily report entry · Sales, purchase, and expense sections assemble daily reports.
frontend/src/pages/manager/DailyReport.jsx - Owner report review · Completed reports and details.
frontend/src/pages/owner/DailyReports.jsx - Delivery workspace
frontend/src/pages/delivery/Delivery.jsx - API client · Central browser-to-backend communication.
frontend/src/api/api.js
FastAPI Backend
- FastAPI application
backend/app/main.py - Authentication API
backend/app/routes/auth.py - Identity & role enforcement · Primary browser-to-business-data trust boundary.
backend/app/dependencies/auth.py - Token & password security
backend/app/core/token.py - Operational APIs · Daily reports, purchases, expenses, deliveries, assignments, and tasks.
backend/app/routes/daily_reports.py - Analytics, export & audit
backend/app/routes/analytics.py - Export generator
backend/app/services/export_service.py
Data & Integrations
- Firebase notifications
frontend/src/firebase.js - Operational domain model · Daily reports link sales, payments, purchases, expenses, deliveries, udhaar, and tasks.
backend/app/models/daily_report.py - Database
backend/app/database.py - Bill evidence uploads · Uploaded bill and delivery evidence.
backend/app/uploads/bills
Connections 25
- SPA entry → App state shell: mounts
- App state shell → Auth state: provides session state
- App state shell → Role-specific routes: renders
- Role-specific routes → Protected access: gates protected views
- Protected access → Role layouts: selects permitted shell
- Protected access → Daily report entry: allows manager/staff workflow
- Protected access → Owner report review: allows owner review
- Protected access → Delivery workspace: allows delivery workflow
- Auth state → API client: authenticates requests
- Daily report entry → API client: submits financial entries
- Owner report review → API client: reads reports and exports
- Delivery workspace → API client: records deliveries
- API client → FastAPI application: HTTPS API calls
- FastAPI application → Authentication API: serves login
- FastAPI application → Identity & role enforcement: applies dependencies
- Authentication API → Token & password security: issues and validates tokens
- Identity & role enforcement → Token & password security: verifies identity
- Identity & role enforcement → Operational APIs: authorizes domain access
- Identity & role enforcement → Analytics, export & audit: authorizes oversight access
- Operational APIs → Operational domain model: creates and updates records
- Analytics, export & audit → Operational domain model: queries reporting history
- Operational domain model → Database: persists
- Operational APIs → Bill evidence uploads: stores bill evidence
- Analytics, export & audit → Export generator: generates exports
- Firebase notifications → Auth state: notification-aware client session