# matthewsnelgrove/chefswap architecture

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

- Interactive diagram: https://gitdiagram.com/matthewsnelgrove/chefswap
- Repository: https://github.com/matthewsnelgrove/chefswap

## Overview

This is a web application for finding and arranging person-to-person swaps, with account profiles, swap requests and ratings, plus real-time messaging. The main flow is a user searching and filtering profiles, then managing swaps; account creation, profile editing, and chat are supporting branches. The graph includes the client, HTTP API, messaging, and persistence layers. Several routes and UI modules are documented only by the source index, so their detailed internal behavior is not inferred.

Main entry points: [`client/utils/fetchFunctions.js`](https://github.com/matthewsnelgrove/chefswap/blob/main/client/utils/fetchFunctions.js) (HTTP client), [`server/routes/accounts.js`](https://github.com/matthewsnelgrove/chefswap/blob/main/server/routes/accounts.js) (Account routes), [`server/index.js`](https://github.com/matthewsnelgrove/chefswap/blob/main/server/index.js) (API server), [`server/configServices/dbConfig.js`](https://github.com/matthewsnelgrove/chefswap/blob/main/server/configServices/dbConfig.js) (PostgreSQL)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_find["Find swaps<br/>[index.js]"]
  node_search["Search state<br/>[useSwapSearch.js]"]
  node_filters["Search filters<br/>[FilterForm.js]"]
  node_results["Profile results"]
  node_profile["Account pages<br/>[index.js]"]
  node_signup["Signup<br/>[index.js]"]
  node_myprofile["Profile editor<br/>[index.js]"]
  node_swaps["My swaps<br/>[index.js]"]
  node_messagespage["Messages page<br/>[index.js]"]
  node_fetch["HTTP client<br/>[fetchFunctions.js]"]
  node_userstate["User state<br/>[useUser.js]"]
  node_socketclient["Socket client<br/>[useMessages.js]"]
end

subgraph group_api["HTTP API"]
  node_server["API server<br/>[index.js]"]
  node_session["Session routes<br/>[session.js]"]
  node_accounts["Account routes<br/>[accounts.js]"]
  node_swaproutes["Swap routes<br/>[swaps.js]"]
  node_ratings["Rating routes<br/>[ratings.js]"]
  node_auth["Account authorization<br/>[checkAuth.js]"]
end

subgraph group_chat["Messaging"]
  node_chatserver["Messaging events"]
end

subgraph group_data["Data and integrations"]
  node_database[("PostgreSQL<br/>[dbConfig.js]")]
  node_storage["Image storage config"]
  node_images["Image links<br/>[imageHelpers.js]"]
  node_maps["Address geocoding"]
end

node_user(("Swap seeker"))
node_mapsservice{{"Geocoding service"}}

node_user -->|"searches"| node_find
node_find -->|"renders"| node_filters
node_find -->|"renders"| node_results
node_find -->|"uses"| node_search
node_search -->|"requests profiles"| node_fetch
node_userstate -->|"loads user"| node_fetch
node_signup -->|"creates account"| node_fetch
node_profile -.->|"requests account data"| node_fetch
node_myprofile -.->|"updates profile"| node_fetch
node_swaps -.->|"loads swap status"| node_fetch
node_messagespage -->|"uses messages"| node_socketclient
node_fetch -->|"requests session"| node_session
node_fetch -->|"requests accounts"| node_accounts
node_fetch -->|"requests swaps"| node_swaproutes
node_fetch -->|"requests ratings"| node_ratings
node_server -->|"mounts routes"| node_session
node_server -->|"mounts routes"| node_accounts
node_server -->|"mounts routes"| node_swaproutes
node_server -->|"mounts routes"| node_ratings
node_server -->|"registers handler"| node_chatserver
node_accounts -->|"checks access"| node_auth
node_swaproutes -->|"checks access"| node_auth
node_session -->|"queries"| node_database
node_accounts -->|"reads and writes"| node_database
node_swaproutes -->|"reads and writes"| node_database
node_chatserver -->|"reads and writes"| node_database
node_server -->|"loads pool"| node_database
node_accounts -->|"creates image links"| node_images
node_chatserver -->|"creates image links"| node_images
node_accounts -->|"uploads images"| node_storage
node_accounts -->|"builds geocoding request"| node_maps
node_maps -->|"queries"| node_mapsservice

click node_find "https://github.com/matthewsnelgrove/chefswap/blob/main/client/pages/find-swap/index.js"
click node_search "https://github.com/matthewsnelgrove/chefswap/blob/main/client/components/useSwapSearch.js"
click node_filters "https://github.com/matthewsnelgrove/chefswap/blob/main/client/components/FilterForm.js"
click node_results "https://github.com/matthewsnelgrove/chefswap/blob/main/client/components/SwapResultsContainer.js"
click node_profile "https://github.com/matthewsnelgrove/chefswap/blob/main/client/pages/u/%5Bid%5D/index.js"
click node_signup "https://github.com/matthewsnelgrove/chefswap/blob/main/client/pages/signup/index.js"
click node_myprofile "https://github.com/matthewsnelgrove/chefswap/blob/main/client/pages/me/index.js"
click node_swaps "https://github.com/matthewsnelgrove/chefswap/blob/main/client/pages/my-swaps/index.js"
click node_messagespage "https://github.com/matthewsnelgrove/chefswap/blob/main/client/pages/my-messages/index.js"
click node_fetch "https://github.com/matthewsnelgrove/chefswap/blob/main/client/utils/fetchFunctions.js"
click node_userstate "https://github.com/matthewsnelgrove/chefswap/blob/main/client/components/useUser.js"
click node_socketclient "https://github.com/matthewsnelgrove/chefswap/blob/main/client/utils/useMessages.js"
click node_server "https://github.com/matthewsnelgrove/chefswap/blob/main/server/index.js"
click node_session "https://github.com/matthewsnelgrove/chefswap/blob/main/server/routes/session.js"
click node_accounts "https://github.com/matthewsnelgrove/chefswap/blob/main/server/routes/accounts.js"
click node_swaproutes "https://github.com/matthewsnelgrove/chefswap/blob/main/server/routes/swaps.js"
click node_ratings "https://github.com/matthewsnelgrove/chefswap/blob/main/server/routes/ratings.js"
click node_auth "https://github.com/matthewsnelgrove/chefswap/blob/main/server/middlewares/checkAuth.js"
click node_chatserver "https://github.com/matthewsnelgrove/chefswap/blob/main/server/socketEventHandlers/messagingHandler.js"
click node_database "https://github.com/matthewsnelgrove/chefswap/blob/main/server/configServices/dbConfig.js"
click node_storage "https://github.com/matthewsnelgrove/chefswap/blob/main/server/configServices/cloudStorageConfig.js"
click node_images "https://github.com/matthewsnelgrove/chefswap/blob/main/server/utils/imageHelpers.js"
click node_maps "https://github.com/matthewsnelgrove/chefswap/blob/main/server/utils/addressToGmapsUrl.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_find,node_search,node_filters,node_results,node_profile,node_signup,node_myprofile,node_swaps,node_messagespage,node_fetch,node_userstate,node_socketclient toneBlue
class node_server,node_session,node_accounts,node_swaproutes,node_ratings,node_auth toneAmber
class node_chatserver toneMint
class node_database,node_storage,node_images,node_maps toneRose
class node_user,node_mapsservice toneIndigo
```

## Components

### Client experience

- [Find swaps](https://github.com/matthewsnelgrove/chefswap/blob/main/client/pages/find-swap/index.js): `client/pages/find-swap/index.js`
- [Search state](https://github.com/matthewsnelgrove/chefswap/blob/main/client/components/useSwapSearch.js): `client/components/useSwapSearch.js`
- [Search filters](https://github.com/matthewsnelgrove/chefswap/blob/main/client/components/FilterForm.js): `client/components/FilterForm.js`
- [Profile results](https://github.com/matthewsnelgrove/chefswap/blob/main/client/components/SwapResultsContainer.js): `client/components/SwapResultsContainer.js`
- [Account pages](https://github.com/matthewsnelgrove/chefswap/blob/main/client/pages/u/%5Bid%5D/index.js): `client/pages/u/[id]/index.js`
- [Signup](https://github.com/matthewsnelgrove/chefswap/blob/main/client/pages/signup/index.js): `client/pages/signup/index.js`
- [Profile editor](https://github.com/matthewsnelgrove/chefswap/blob/main/client/pages/me/index.js): `client/pages/me/index.js`
- [My swaps](https://github.com/matthewsnelgrove/chefswap/blob/main/client/pages/my-swaps/index.js): `client/pages/my-swaps/index.js`
- [Messages page](https://github.com/matthewsnelgrove/chefswap/blob/main/client/pages/my-messages/index.js): `client/pages/my-messages/index.js`
- [HTTP client](https://github.com/matthewsnelgrove/chefswap/blob/main/client/utils/fetchFunctions.js): `client/utils/fetchFunctions.js`
- [User state](https://github.com/matthewsnelgrove/chefswap/blob/main/client/components/useUser.js): `client/components/useUser.js`
- [Socket client](https://github.com/matthewsnelgrove/chefswap/blob/main/client/utils/useMessages.js): `client/utils/useMessages.js`

### HTTP API

- [API server](https://github.com/matthewsnelgrove/chefswap/blob/main/server/index.js): `server/index.js`
- [Session routes](https://github.com/matthewsnelgrove/chefswap/blob/main/server/routes/session.js): `server/routes/session.js`
- [Account routes](https://github.com/matthewsnelgrove/chefswap/blob/main/server/routes/accounts.js): `server/routes/accounts.js`
- [Swap routes](https://github.com/matthewsnelgrove/chefswap/blob/main/server/routes/swaps.js): `server/routes/swaps.js`
- [Rating routes](https://github.com/matthewsnelgrove/chefswap/blob/main/server/routes/ratings.js): `server/routes/ratings.js`
- [Account authorization](https://github.com/matthewsnelgrove/chefswap/blob/main/server/middlewares/checkAuth.js): `server/middlewares/checkAuth.js`

### Messaging

- [Messaging events](https://github.com/matthewsnelgrove/chefswap/blob/main/server/socketEventHandlers/messagingHandler.js): `server/socketEventHandlers/messagingHandler.js`

### Data and integrations

- [PostgreSQL](https://github.com/matthewsnelgrove/chefswap/blob/main/server/configServices/dbConfig.js): `server/configServices/dbConfig.js`
- [Image storage config](https://github.com/matthewsnelgrove/chefswap/blob/main/server/configServices/cloudStorageConfig.js): `server/configServices/cloudStorageConfig.js`
- [Image links](https://github.com/matthewsnelgrove/chefswap/blob/main/server/utils/imageHelpers.js): `server/utils/imageHelpers.js`
- [Address geocoding](https://github.com/matthewsnelgrove/chefswap/blob/main/server/utils/addressToGmapsUrl.js): `server/utils/addressToGmapsUrl.js`

### Other components

- **Swap seeker**
- **Geocoding service**

## Connections

- Swap seeker → Find swaps: searches (evidence: `client/pages/find-swap/index.js`)
- Find swaps → Search filters: renders (evidence: `client/pages/find-swap/index.js`)
- Find swaps → Profile results: renders (evidence: `client/pages/find-swap/index.js`)
- Find swaps → Search state: uses (evidence: `client/pages/find-swap/index.js`)
- Search state → HTTP client: requests profiles (evidence: `client/components/useSwapSearch.js`)
- User state → HTTP client: loads user (evidence: `client/components/useUser.js`)
- Signup → HTTP client: creates account (evidence: `client/utils/fetchFunctions.js`)
- Account pages → HTTP client: requests account data
- Profile editor → HTTP client: updates profile
- My swaps → HTTP client: loads swap status
- Messages page → Socket client: uses messages (evidence: `client/utils/useMessages.js`)
- HTTP client → Session routes: requests session (evidence: `client/utils/fetchFunctions.js`)
- HTTP client → Account routes: requests accounts (evidence: `client/utils/fetchFunctions.js`)
- HTTP client → Swap routes: requests swaps (evidence: `client/utils/fetchFunctions.js`)
- HTTP client → Rating routes: requests ratings (evidence: `client/utils/fetchFunctions.js`)
- API server → Session routes: mounts routes (evidence: `server/index.js`)
- API server → Account routes: mounts routes (evidence: `server/index.js`)
- API server → Swap routes: mounts routes (evidence: `server/index.js`)
- API server → Rating routes: mounts routes (evidence: `server/index.js`)
- API server → Messaging events: registers handler (evidence: `server/index.js`)
- Account routes → Account authorization: checks access (evidence: `server/routes/accounts.js`)
- Swap routes → Account authorization: checks access (evidence: `server/routes/swaps.js`)
- Session routes → PostgreSQL: queries (evidence: `server/routes/session.js`)
- Account routes → PostgreSQL: reads and writes (evidence: `server/routes/accounts.js`)
- Swap routes → PostgreSQL: reads and writes (evidence: `server/routes/swaps.js`)
- Messaging events → PostgreSQL: reads and writes (evidence: `server/socketEventHandlers/messagingHandler.js`)
- API server → PostgreSQL: loads pool (evidence: `server/index.js`)
- Account routes → Image links: creates image links (evidence: `server/routes/accounts.js`)
- Messaging events → Image links: creates image links (evidence: `server/socketEventHandlers/messagingHandler.js`)
- Account routes → Image storage config: uploads images (evidence: `server/routes/accounts.js`)
- Account routes → Address geocoding: builds geocoding request (evidence: `server/routes/accounts.js`)
- Address geocoding → Geocoding service: queries
