# prakash7474/b2p architecture

> Architecture diagram of the GitHub repository prakash7474/b2p, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prakash7474/b2p
- Repository: https://github.com/prakash7474/b2p

## Overview

B2POnline is a vendor-network platform for shop profiles, products, inventory, sales, demand and restocking, with a mobile vendor portal and a manufacturer-facing web portal. The vendor workflow is account access, then shop operations such as inventory and demand requests, with forecasting and risk views supporting decisions; the documented backend exposes API endpoints and uses MongoDB. The README documents only a small subset of the API. Several portal and backend modules are unsampled, so their internal connections are omitted or marked unverified.

Main entry points: [`App/src/lib/api.ts`](https://github.com/prakash7474/b2p/blob/main/App/src/lib/api.ts) (API client), [`backend/main.py`](https://github.com/prakash7474/b2p/blob/main/backend/main.py) (FastAPI service), [`App/src/app/(auth)`](https://github.com/prakash7474/b2p/tree/main/App/src/app/(auth)) (Sign in / Sign up), [`App/src/lib/auth.tsx`](https://github.com/prakash7474/b2p/blob/main/App/src/lib/auth.tsx) (Auth session)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_vendor["Vendor mobile"]
  node_vendor_auth["Sign in / Sign up"]
  node_vendor_session["Auth session<br/>[auth.tsx]"]
  node_vendor_home["Shop dashboard<br/>[index.tsx]"]
  node_vendor_inventory["Inventory<br/>[inventory.tsx]"]
  node_vendor_demands["Demand requests<br/>[demands.tsx]"]
  node_vendor_forecast["Demand forecast<br/>[forecast.tsx]"]
  node_vendor_risk["Risk view<br/>[risk.tsx]"]
  node_vendor_profile["Shop profile<br/>[profile.tsx]"]
  node_mobile_api["API client<br/>[api.ts]"]
end

subgraph group_admin["Manufacturer web"]
  node_admin_portal["Manufacturer portal<br/>[App.jsx]"]
end

subgraph group_service["Backend services"]
  node_backend_api["FastAPI service<br/>[main.py]"]
  node_mongo[("MongoDB collections")]
end

subgraph group_ml["Forecast modeling"]
  node_demand_training["Demand model training"]
  node_spoilage_training["Spoilage model training"]
end

node_vendor_actor(("Vendor"))
node_manufacturer(("Manufacturer staff"))

node_vendor_actor -.->|"opens account"| node_vendor_auth
node_vendor_auth -.->|"authenticates"| node_vendor_session
node_vendor_session -->|"calls API"| node_mobile_api
node_vendor_actor -.->|"uses portal"| node_vendor_home
node_vendor_home -->|"loads dashboard data"| node_mobile_api
node_vendor_actor -.->|"manages stock"| node_vendor_inventory
node_vendor_actor -.->|"requests restock"| node_vendor_demands
node_vendor_actor -.->|"reviews forecast"| node_vendor_forecast
node_vendor_actor -.->|"reviews risk"| node_vendor_risk
node_vendor_actor -.->|"manages profile"| node_vendor_profile
node_mobile_api -.->|"sends requests"| node_backend_api
node_manufacturer -.->|"uses portal"| node_admin_portal
node_admin_portal -.->|"requests platform data"| node_backend_api
node_backend_api -->|"reads and writes"| node_mongo
node_demand_training -.->|"may supply predictions"| node_vendor_forecast

click node_vendor_auth "https://github.com/prakash7474/b2p/tree/main/App/src/app/(auth)"
click node_vendor_session "https://github.com/prakash7474/b2p/blob/main/App/src/lib/auth.tsx"
click node_vendor_home "https://github.com/prakash7474/b2p/blob/main/App/src/app/(vendor)/index.tsx"
click node_vendor_inventory "https://github.com/prakash7474/b2p/blob/main/App/src/app/(vendor)/inventory.tsx"
click node_vendor_demands "https://github.com/prakash7474/b2p/blob/main/App/src/app/(vendor)/demands.tsx"
click node_vendor_forecast "https://github.com/prakash7474/b2p/blob/main/App/src/app/(vendor)/forecast.tsx"
click node_vendor_risk "https://github.com/prakash7474/b2p/blob/main/App/src/app/(vendor)/risk.tsx"
click node_vendor_profile "https://github.com/prakash7474/b2p/blob/main/App/src/app/(vendor)/profile.tsx"
click node_mobile_api "https://github.com/prakash7474/b2p/blob/main/App/src/lib/api.ts"
click node_admin_portal "https://github.com/prakash7474/b2p/blob/main/admin-web/src/App.jsx"
click node_backend_api "https://github.com/prakash7474/b2p/blob/main/backend/main.py"
click node_demand_training "https://github.com/prakash7474/b2p/blob/main/model_code_and_data/train_demand_model.py"
click node_spoilage_training "https://github.com/prakash7474/b2p/blob/main/model_code_and_data/train_spoilage_model.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_vendor_auth,node_vendor_session,node_vendor_home,node_vendor_inventory,node_vendor_demands,node_vendor_forecast,node_vendor_risk,node_vendor_profile,node_mobile_api toneBlue
class node_admin_portal toneAmber
class node_backend_api,node_mongo toneMint
class node_demand_training,node_spoilage_training toneRose
class node_vendor_actor,node_manufacturer toneIndigo
```

## Components

### Vendor mobile

- [Sign in / Sign up](https://github.com/prakash7474/b2p/tree/main/App/src/app/(auth)): `App/src/app/(auth)`
- [Auth session](https://github.com/prakash7474/b2p/blob/main/App/src/lib/auth.tsx): `App/src/lib/auth.tsx`
- [Shop dashboard](https://github.com/prakash7474/b2p/blob/main/App/src/app/(vendor)/index.tsx): `App/src/app/(vendor)/index.tsx`
- [Inventory](https://github.com/prakash7474/b2p/blob/main/App/src/app/(vendor)/inventory.tsx): `App/src/app/(vendor)/inventory.tsx`
- [Demand requests](https://github.com/prakash7474/b2p/blob/main/App/src/app/(vendor)/demands.tsx): `App/src/app/(vendor)/demands.tsx`
- [Demand forecast](https://github.com/prakash7474/b2p/blob/main/App/src/app/(vendor)/forecast.tsx): `App/src/app/(vendor)/forecast.tsx`
- [Risk view](https://github.com/prakash7474/b2p/blob/main/App/src/app/(vendor)/risk.tsx): `App/src/app/(vendor)/risk.tsx`
- [Shop profile](https://github.com/prakash7474/b2p/blob/main/App/src/app/(vendor)/profile.tsx): `App/src/app/(vendor)/profile.tsx`
- [API client](https://github.com/prakash7474/b2p/blob/main/App/src/lib/api.ts): `App/src/lib/api.ts`

### Manufacturer web

- [Manufacturer portal](https://github.com/prakash7474/b2p/blob/main/admin-web/src/App.jsx): `admin-web/src/App.jsx`

### Backend services

- [FastAPI service](https://github.com/prakash7474/b2p/blob/main/backend/main.py): `backend/main.py`
- **MongoDB collections**

### Forecast modeling

- [Demand model training](https://github.com/prakash7474/b2p/blob/main/model_code_and_data/train_demand_model.py): `model_code_and_data/train_demand_model.py`
- [Spoilage model training](https://github.com/prakash7474/b2p/blob/main/model_code_and_data/train_spoilage_model.py): `model_code_and_data/train_spoilage_model.py`

### Other components

- **Vendor**
- **Manufacturer staff**

## Connections

- Vendor → Sign in / Sign up: opens account
- Sign in / Sign up → Auth session: authenticates
- Auth session → API client: calls API (evidence: `App/src/lib/auth.tsx`)
- Vendor → Shop dashboard: uses portal
- Shop dashboard → API client: loads dashboard data (evidence: `App/src/app/(vendor)/index.tsx`)
- Vendor → Inventory: manages stock
- Vendor → Demand requests: requests restock
- Vendor → Demand forecast: reviews forecast
- Vendor → Risk view: reviews risk
- Vendor → Shop profile: manages profile
- API client → FastAPI service: sends requests
- Manufacturer staff → Manufacturer portal: uses portal
- Manufacturer portal → FastAPI service: requests platform data
- FastAPI service → MongoDB collections: reads and writes (evidence: `README.md`)
- Demand model training → Demand forecast: may supply predictions
