# mayeraasingh/toolshare architecture

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

- Interactive diagram: https://gitdiagram.com/mayeraasingh/toolshare
- Repository: https://github.com/mayeraasingh/toolshare

## Overview

ToolShare is a community tool-lending application. Residents browse or search listings, inspect a tool, then borrow, renew, return, or save it; lenders register and manage listings. Account flows support password and Google sign-in, while profiles and borrower/lender dashboards expose user and rental information. The frontend routes these experiences to an Express API backed by MongoDB models, with Firebase used for Google authentication and profile-image storage. Relationships for unsampled features are included only where documented in the README; source-level details are cited where shown.

Main entry points: [`frontend/src/App.jsx`](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/App.jsx) (App routing), [`backend/routes/toolRoutes.js`](https://github.com/mayeraasingh/toolshare/blob/main/backend/routes/toolRoutes.js) (API routes), [`frontend/src/components/OAuth.jsx`](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/components/OAuth.jsx) (Google sign-in), [`backend/controllers/UserController.js`](https://github.com/mayeraasingh/toolshare/blob/main/backend/controllers/UserController.js) (Account operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_app["App routing<br/>[App.jsx]"]
  node_discovery["Browse and search<br/>[Explore.jsx]"]
  node_search["Search results<br/>[SearchResults.jsx]"]
  node_detail["Tool details<br/>[Tool.jsx]"]
  node_listing["List a tool<br/>[AddTool.jsx]"]
  node_borrowed["Borrowed tools<br/>[BorrowedTools.jsx]"]
  node_owned["Lender dashboard"]
  node_saved["Saved tools<br/>[ReviewedTools.jsx]"]
  node_profile["Profile management<br/>[Manageprofile.jsx]"]
end

subgraph group_accounts["Accounts and state"]
  node_authpages["Sign-in and registration<br/>[Login.jsx]"]
  node_oauth["Google sign-in<br/>[OAuth.jsx]"]
  node_userstate["User state<br/>[userSlice.js]"]
end

subgraph group_api["API and domain logic"]
  node_routes["API routes<br/>[toolRoutes.js]"]
  node_toollogic["Tool operations<br/>[ToolController.js]"]
  node_userlogic["Account operations<br/>[UserController.js]"]
  node_auth["Session verification<br/>[auth.js]"]
end

subgraph group_persistence["Persistence and integrations"]
  node_toolmodel["Tool model<br/>[Tool.js]"]
  node_usermodel["User model<br/>[User.js]"]
  node_mongodb[("MongoDB")]
  node_firebase["Firebase services"]
end

node_resident(("Resident"))

node_resident -->|"uses"| node_app
node_app -->|"routes to"| node_discovery
node_app -->|"routes to"| node_search
node_app -->|"routes to"| node_detail
node_app -->|"routes to"| node_listing
node_app -->|"routes to"| node_borrowed
node_app -->|"routes to"| node_owned
node_app -->|"routes to"| node_saved
node_app -->|"routes to"| node_profile
node_app -->|"routes to"| node_authpages
node_discovery -->|"requests catalogue"| node_routes
node_search -->|"requests matches"| node_routes
node_detail -->|"rents or manages"| node_routes
node_listing -->|"submits listing"| node_routes
node_borrowed -->|"renews or returns"| node_routes
node_owned -->|"manages listings"| node_routes
node_saved -->|"loads or removes"| node_routes
node_profile -->|"uploads image"| node_firebase
node_authpages -->|"offers Google sign-in"| node_oauth
node_oauth -->|"authenticates with"| node_firebase
node_oauth -->|"updates"| node_userstate
node_oauth -->|"posts ID token"| node_userlogic
node_routes -->|"dispatches tool routes"| node_toollogic
node_routes -->|"dispatches account routes"| node_userlogic
node_routes -->|"guards protected routes"| node_auth
node_toollogic -->|"reads and updates"| node_toolmodel
node_toollogic -->|"updates borrower records"| node_usermodel
node_userlogic -->|"reads and updates"| node_usermodel
node_toolmodel -->|"persists tools"| node_mongodb
node_usermodel -->|"persists users"| node_mongodb
node_userlogic -->|"verifies Google token"| node_firebase

click node_app "https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/App.jsx"
click node_discovery "https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/Explore.jsx"
click node_search "https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/SearchResults.jsx"
click node_detail "https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/Tool.jsx"
click node_listing "https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/AddTool.jsx"
click node_borrowed "https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/BorrowedTools.jsx"
click node_owned "https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/RegisteredTools.jsx"
click node_saved "https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/ReviewedTools.jsx"
click node_profile "https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/Manageprofile.jsx"
click node_authpages "https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/Login.jsx"
click node_oauth "https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/components/OAuth.jsx"
click node_userstate "https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/redux/userSlice.js"
click node_routes "https://github.com/mayeraasingh/toolshare/blob/main/backend/routes/toolRoutes.js"
click node_toollogic "https://github.com/mayeraasingh/toolshare/blob/main/backend/controllers/ToolController.js"
click node_userlogic "https://github.com/mayeraasingh/toolshare/blob/main/backend/controllers/UserController.js"
click node_auth "https://github.com/mayeraasingh/toolshare/blob/main/backend/middleware/auth.js"
click node_toolmodel "https://github.com/mayeraasingh/toolshare/blob/main/backend/models/Tool.js"
click node_usermodel "https://github.com/mayeraasingh/toolshare/blob/main/backend/models/User.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_discovery,node_search,node_detail,node_listing,node_borrowed,node_owned,node_saved,node_profile toneBlue
class node_authpages,node_oauth,node_userstate toneAmber
class node_routes,node_toollogic,node_userlogic,node_auth toneMint
class node_toolmodel,node_usermodel,node_mongodb,node_firebase toneRose
class node_resident toneIndigo
```

## Components

### Web experience

- [App routing](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Browse and search](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/Explore.jsx): `frontend/src/pages/Explore.jsx`
- [Search results](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/SearchResults.jsx): `frontend/src/pages/SearchResults.jsx`
- [Tool details](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/Tool.jsx): `frontend/src/pages/Tool.jsx`
- [List a tool](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/AddTool.jsx): `frontend/src/pages/AddTool.jsx`
- [Borrowed tools](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/BorrowedTools.jsx): `frontend/src/pages/BorrowedTools.jsx`
- [Lender dashboard](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/RegisteredTools.jsx): `frontend/src/pages/RegisteredTools.jsx`
- [Saved tools](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/ReviewedTools.jsx): `frontend/src/pages/ReviewedTools.jsx`
- [Profile management](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/Manageprofile.jsx): `frontend/src/pages/Manageprofile.jsx`

### Accounts and state

- [Sign-in and registration](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/pages/Login.jsx): `frontend/src/pages/Login.jsx`
- [Google sign-in](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/components/OAuth.jsx): `frontend/src/components/OAuth.jsx`
- [User state](https://github.com/mayeraasingh/toolshare/blob/main/frontend/src/redux/userSlice.js): `frontend/src/redux/userSlice.js`

### API and domain logic

- [API routes](https://github.com/mayeraasingh/toolshare/blob/main/backend/routes/toolRoutes.js): `backend/routes/toolRoutes.js`
- [Tool operations](https://github.com/mayeraasingh/toolshare/blob/main/backend/controllers/ToolController.js): `backend/controllers/ToolController.js`
- [Account operations](https://github.com/mayeraasingh/toolshare/blob/main/backend/controllers/UserController.js): `backend/controllers/UserController.js`
- [Session verification](https://github.com/mayeraasingh/toolshare/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`

### Persistence and integrations

- [Tool model](https://github.com/mayeraasingh/toolshare/blob/main/backend/models/Tool.js): `backend/models/Tool.js`
- [User model](https://github.com/mayeraasingh/toolshare/blob/main/backend/models/User.js): `backend/models/User.js`
- **MongoDB**
- **Firebase services**

### Other components

- **Resident**

## Connections

- Resident → App routing: uses (evidence: `README.md`)
- App routing → Browse and search: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Search results: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Tool details: routes to (evidence: `frontend/src/App.jsx`)
- App routing → List a tool: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Borrowed tools: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Lender dashboard: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Saved tools: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Profile management: routes to (evidence: `frontend/src/App.jsx`)
- App routing → Sign-in and registration: routes to (evidence: `frontend/src/App.jsx`)
- Browse and search → API routes: requests catalogue (evidence: `README.md`)
- Search results → API routes: requests matches (evidence: `README.md`)
- Tool details → API routes: rents or manages (evidence: `README.md`)
- List a tool → API routes: submits listing (evidence: `README.md`)
- Borrowed tools → API routes: renews or returns (evidence: `README.md`)
- Lender dashboard → API routes: manages listings (evidence: `README.md`)
- Saved tools → API routes: loads or removes (evidence: `frontend/src/pages/ReviewedTools.jsx`)
- Profile management → Firebase services: uploads image (evidence: `README.md`)
- Sign-in and registration → Google sign-in: offers Google sign-in (evidence: `frontend/src/pages/Login.jsx`)
- Google sign-in → Firebase services: authenticates with (evidence: `frontend/src/components/OAuth.jsx`)
- Google sign-in → User state: updates (evidence: `frontend/src/components/OAuth.jsx`)
- Google sign-in → Account operations: posts ID token (evidence: `frontend/src/components/OAuth.jsx`)
- API routes → Tool operations: dispatches tool routes (evidence: `backend/routes/toolRoutes.js`)
- API routes → Account operations: dispatches account routes
- API routes → Session verification: guards protected routes (evidence: `backend/routes/toolRoutes.js`)
- Tool operations → Tool model: reads and updates (evidence: `backend/controllers/ToolController.js`)
- Tool operations → User model: updates borrower records (evidence: `backend/controllers/ToolController.js`)
- Account operations → User model: reads and updates (evidence: `backend/controllers/UserController.js`)
- Tool model → MongoDB: persists tools (evidence: `backend/models/Tool.js`)
- User model → MongoDB: persists users (evidence: `backend/models/User.js`)
- Account operations → Firebase services: verifies Google token
