# rutujthakare0/pocket-stock architecture

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

- Interactive diagram: https://gitdiagram.com/rutujthakare0/pocket-stock
- Repository: https://github.com/rutujthakare0/pocket-stock

## Overview

PocketStock is a household inventory product for tracking supplies, purchases, members, and restocking needs. Users authenticate, select a household, and manage its inventory in the dashboard; inventory can also be added by barcode or bill scan, while purchase and inventory events support prediction features. The frontend’s dashboard and account pages call the backend API, whose routers dispatch to controllers and PostgreSQL. Notification and prediction services are present as distinct backend subsystems. Some service wiring is documented only by the source index, so unverified connections are omitted.

Main entry points: [`frontend/src/App.jsx`](https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/App.jsx) (App routing), [`backend/src/controllers/householdController.js`](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/controllers/householdController.js) (Household inventory), [`frontend/src/config/api.js`](https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/config/api.js) (API endpoints), [`backend/src/config/db.js`](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/config/db.js) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_app["App routing<br/>[App.jsx]"]
  node_authui["Auth context<br/>[AuthContext.jsx]"]
  node_authpages["Login and signup<br/>[LoginPage.jsx]"]
  node_dashboard["Inventory dashboard<br/>[DashboardPage.jsx]"]
  node_memberpage["Household members<br/>[MembersPage.jsx]"]
  node_settings["User settings"]
  node_joinpage["Join household"]
  node_apiconfig["API endpoints<br/>[api.js]"]
end

subgraph group_api["Backend API"]
  node_backend["HTTP application<br/>[app.js]"]
  node_useroutes["User routes<br/>[userRouter.js]"]
  node_houseroutes["Household routes<br/>[householdRoutes.js]"]
  node_auth["Authentication<br/>[authController.js]"]
  node_googleauth["Google sign-in"]
  node_users["User management<br/>[userController.js]"]
end

subgraph group_inventory["Inventory domain"]
  node_households["Household inventory"]
  node_postgres[("PostgreSQL<br/>[db.js]")]
  node_redis[("Redis cache<br/>[redis.js]")]
  node_billparse["Bill parsing<br/>[billParser.js]"]
  node_matcher["Inventory matching"]
end

subgraph group_insights["Background services"]
  node_prediction["Prediction service"]
  node_kafka["Event producer<br/>[producer.js]"]
  node_notifications["Notifications"]
  node_delivery["Push delivery<br/>[deliveryService.js]"]
  node_push["Push providers<br/>[pushProviders.js]"]
end

node_user(("Household user"))

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_authpages
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_memberpage
node_app -->|"routes to"| node_settings
node_app -->|"routes to"| node_joinpage
node_app -->|"provides"| node_authui
node_authui -->|"calls endpoints"| node_apiconfig
node_dashboard -->|"calls endpoints"| node_apiconfig
node_memberpage -->|"calls endpoints"| node_apiconfig
node_settings -->|"calls endpoints"| node_apiconfig
node_joinpage -->|"calls endpoints"| node_apiconfig
node_apiconfig -.->|"HTTP requests"| node_backend
node_backend -->|"mounts routes"| node_useroutes
node_backend -->|"mounts routes"| node_houseroutes
node_useroutes -->|"dispatches"| node_auth
node_useroutes -->|"dispatches"| node_googleauth
node_useroutes -->|"dispatches"| node_users
node_houseroutes -->|"dispatches"| node_households
node_auth -->|"queries"| node_postgres
node_googleauth -->|"queries"| node_postgres
node_users -->|"queries"| node_postgres
node_households -->|"reads and writes"| node_postgres
node_households -->|"checks cache"| node_redis
node_households -->|"parses bill"| node_billparse
node_households -->|"matches items"| node_matcher
node_households -->|"publishes events"| node_kafka
node_kafka -.->|"feeds events"| node_prediction
node_prediction -->|"queries"| node_postgres
node_prediction -->|"uses cache"| node_redis
node_notifications -->|"queries"| node_postgres
node_delivery -->|"uses providers"| node_push

click node_app "https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/App.jsx"
click node_authui "https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/context/AuthContext.jsx"
click node_authpages "https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/pages/LoginPage.jsx"
click node_dashboard "https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/pages/DashboardPage.jsx"
click node_memberpage "https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/pages/MembersPage.jsx"
click node_settings "https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/pages/UserSettingsPage.jsx"
click node_joinpage "https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/pages/JoinHouseholdPage.jsx"
click node_apiconfig "https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/config/api.js"
click node_backend "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/app.js"
click node_useroutes "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/routers/userRouter.js"
click node_houseroutes "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/routers/householdRoutes.js"
click node_auth "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/controllers/authController.js"
click node_googleauth "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/controllers/googleAuthController.js"
click node_users "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/controllers/userController.js"
click node_households "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/controllers/householdController.js"
click node_postgres "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/config/db.js"
click node_redis "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/config/redis.js"
click node_billparse "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/utils/billParser.js"
click node_matcher "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/utils/inventoryMatcher.js"
click node_prediction "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/prediction-service/services/predictionService.js"
click node_kafka "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/prediction-service/kafka/producer.js"
click node_notifications "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/notification-service/services/notificationService.js"
click node_delivery "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/notification-service/services/deliveryService.js"
click node_push "https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/notification-service/providers/pushProviders.js"

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_app,node_authui,node_authpages,node_dashboard,node_memberpage,node_settings,node_joinpage,node_apiconfig,node_user toneBlue
class node_backend,node_useroutes,node_houseroutes,node_auth,node_googleauth,node_users toneAmber
class node_households,node_postgres,node_redis,node_billparse,node_matcher toneMint
class node_prediction,node_kafka,node_notifications,node_delivery,node_push toneRose
```

## Components

### Web client

- [App routing](https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Auth context](https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/context/AuthContext.jsx): `frontend/src/context/AuthContext.jsx`
- [Login and signup](https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/pages/LoginPage.jsx): `frontend/src/pages/LoginPage.jsx`
- [Inventory dashboard](https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/pages/DashboardPage.jsx): `frontend/src/pages/DashboardPage.jsx`
- [Household members](https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/pages/MembersPage.jsx): `frontend/src/pages/MembersPage.jsx`
- [User settings](https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/pages/UserSettingsPage.jsx): `frontend/src/pages/UserSettingsPage.jsx`
- [Join household](https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/pages/JoinHouseholdPage.jsx): `frontend/src/pages/JoinHouseholdPage.jsx`
- [API endpoints](https://github.com/rutujthakare0/pocket-stock/blob/main/frontend/src/config/api.js): `frontend/src/config/api.js`

### Backend API

- [HTTP application](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/app.js): `backend/app.js`
- [User routes](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/routers/userRouter.js): `backend/src/routers/userRouter.js`
- [Household routes](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/routers/householdRoutes.js): `backend/src/routers/householdRoutes.js`
- [Authentication](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/controllers/authController.js): `backend/src/controllers/authController.js`
- [Google sign-in](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/controllers/googleAuthController.js): `backend/src/controllers/googleAuthController.js`
- [User management](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/controllers/userController.js): `backend/src/controllers/userController.js`

### Inventory domain

- [Household inventory](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/controllers/householdController.js): `backend/src/controllers/householdController.js`
- [PostgreSQL](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/config/db.js): `backend/src/config/db.js`
- [Redis cache](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/config/redis.js): `backend/src/config/redis.js`
- [Bill parsing](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/utils/billParser.js): `backend/src/utils/billParser.js`
- [Inventory matching](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/utils/inventoryMatcher.js): `backend/src/utils/inventoryMatcher.js`

### Background services

- [Prediction service](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/prediction-service/services/predictionService.js): `backend/src/prediction-service/services/predictionService.js`
- [Event producer](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/prediction-service/kafka/producer.js): `backend/src/prediction-service/kafka/producer.js`
- [Notifications](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/notification-service/services/notificationService.js): `backend/src/notification-service/services/notificationService.js`
- [Push delivery](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/notification-service/services/deliveryService.js): `backend/src/notification-service/services/deliveryService.js`
- [Push providers](https://github.com/rutujthakare0/pocket-stock/blob/main/backend/src/notification-service/providers/pushProviders.js): `backend/src/notification-service/providers/pushProviders.js`

### Other components

- **Household user**

## Connections

- Household user → App routing: uses (evidence: `frontend/src/App.jsx`)
- App routing → Login and signup: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Inventory dashboard: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Household members: routes to (evidence: `frontend/src/App.jsx`)
- App routing → User settings: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Join household: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Auth context: provides (evidence: `frontend/src/App.jsx`)
- Auth context → API endpoints: calls endpoints (evidence: `frontend/src/context/AuthContext.jsx`)
- Inventory dashboard → API endpoints: calls endpoints (evidence: `frontend/src/pages/DashboardPage.jsx`)
- Household members → API endpoints: calls endpoints (evidence: `frontend/src/pages/MembersPage.jsx`)
- User settings → API endpoints: calls endpoints (evidence: `frontend/src/pages/UserSettingsPage.jsx`)
- Join household → API endpoints: calls endpoints (evidence: `frontend/src/pages/JoinHouseholdPage.jsx`)
- API endpoints → HTTP application: HTTP requests
- HTTP application → User routes: mounts routes (evidence: `backend/app.js`)
- HTTP application → Household routes: mounts routes (evidence: `backend/app.js`)
- User routes → Authentication: dispatches (evidence: `backend/src/routers/userRouter.js`)
- User routes → Google sign-in: dispatches (evidence: `backend/src/routers/userRouter.js`)
- User routes → User management: dispatches (evidence: `backend/src/routers/userRouter.js`)
- Household routes → Household inventory: dispatches (evidence: `backend/src/routers/householdRoutes.js`)
- Authentication → PostgreSQL: queries (evidence: `backend/src/controllers/authController.js`)
- Google sign-in → PostgreSQL: queries (evidence: `backend/src/controllers/googleAuthController.js`)
- User management → PostgreSQL: queries (evidence: `backend/src/controllers/userController.js`)
- Household inventory → PostgreSQL: reads and writes (evidence: `backend/src/controllers/householdController.js`)
- Household inventory → Redis cache: checks cache (evidence: `backend/src/controllers/householdController.js`)
- Household inventory → Bill parsing: parses bill (evidence: `backend/src/controllers/householdController.js`)
- Household inventory → Inventory matching: matches items (evidence: `backend/src/controllers/householdController.js`)
- Household inventory → Event producer: publishes events (evidence: `backend/src/controllers/householdController.js`)
- Event producer → Prediction service: feeds events
- Prediction service → PostgreSQL: queries (evidence: `backend/src/prediction-service/services/predictionService.js`)
- Prediction service → Redis cache: uses cache (evidence: `backend/src/prediction-service/services/predictionService.js`)
- Notifications → PostgreSQL: queries (evidence: `backend/src/notification-service/services/notificationService.js`)
- Push delivery → Push providers: uses providers (evidence: `backend/src/notification-service/services/deliveryService.js`)
