# froggorrr/matscan-wsserver architecture

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

- Interactive diagram: https://gitdiagram.com/froggorrr/matscan-wsserver
- Repository: https://github.com/froggorrr/matscan-wsserver

## Overview

This is a Discord transaction monitor and lookup service. Its live workflow listens to configured Discord messages, parses transaction embeds, persists transaction/user records, and broadcasts new transactions over Socket.IO. A separate search controller can look up transactions or users, consulting Supabase first and Discord’s message-search API on misses. The server imports that controller but does not register a route or otherwise invoke it in the shown excerpt, so no user-to-search entry edge is asserted.

Main entry points: [`src/app/controllers/search.js`](https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/controllers/search.js) (Transaction and user search), [`src/app/services/discord.js`](https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/services/discord.js) (Discord listener), [`src/app/models/insert.js`](https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/models/insert.js) (Transaction and user writes), [`src/app/services/supabaseClient.js`](https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/services/supabaseClient.js) (Supabase client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Server and live feed"]
  node_server["HTTP and Socket.IO server<br/>[server.js]"]
  node_discord_listener["Discord listener<br/>[discord.js]"]
end

subgraph group_lookup["Transaction lookup"]
  node_search["Transaction and user search<br/>[search.js]"]
  node_discord_search["Discord message search API<br/>[discordAPI.js]"]
  node_embed_parser["Embed parser<br/>[embedParser.js]"]
end

subgraph group_persistence["Persistence"]
  node_insert["Transaction and user writes<br/>[insert.js]"]
  node_update["User updates<br/>[update.js]"]
  node_supabase_client["Supabase client<br/>[supabaseClient.js]"]
  node_logger["Application logger<br/>[logger.js]"]
end

node_live_clients(("Socket.IO clients"))
node_supabase[("Supabase database")]

node_server -->|"starts with Socket.IO"| node_discord_listener
node_discord_listener -->|"parses embeds"| node_embed_parser
node_discord_listener -->|"inserts records"| node_insert
node_discord_listener -->|"emits transactions"| node_live_clients
node_search -->|"queries records"| node_supabase_client
node_search -->|"searches on miss"| node_discord_search
node_search -->|"parses results"| node_embed_parser
node_search -->|"inserts search results"| node_insert
node_search -->|"updates users"| node_update
node_update -->|"updates users"| node_supabase_client
node_update -->|"counts matching transactions"| node_search
node_insert -->|"reads and writes"| node_supabase_client
node_insert -->|"logs write outcomes"| node_logger
node_supabase_client -.->|"connects to"| node_supabase

click node_server "https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/server.js"
click node_discord_listener "https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/services/discord.js"
click node_search "https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/controllers/search.js"
click node_discord_search "https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/services/discordAPI.js"
click node_embed_parser "https://github.com/froggorrr/matscan-wsserver/blob/master/src/utils/embedParser.js"
click node_insert "https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/models/insert.js"
click node_update "https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/models/update.js"
click node_supabase_client "https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/services/supabaseClient.js"
click node_logger "https://github.com/froggorrr/matscan-wsserver/blob/master/src/utils/logger.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_server,node_discord_listener,node_live_clients toneBlue
class node_search,node_discord_search,node_embed_parser,node_supabase toneAmber
class node_insert,node_update,node_supabase_client,node_logger toneMint
```

## Components

### Server and live feed

- [HTTP and Socket.IO server](https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/server.js): `src/app/server.js`
- [Discord listener](https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/services/discord.js): `src/app/services/discord.js`

### Transaction lookup

- [Transaction and user search](https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/controllers/search.js): `src/app/controllers/search.js`
- [Discord message search API](https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/services/discordAPI.js): `src/app/services/discordAPI.js`
- [Embed parser](https://github.com/froggorrr/matscan-wsserver/blob/master/src/utils/embedParser.js): `src/utils/embedParser.js`

### Persistence

- [Transaction and user writes](https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/models/insert.js): `src/app/models/insert.js`
- [User updates](https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/models/update.js): `src/app/models/update.js`
- [Supabase client](https://github.com/froggorrr/matscan-wsserver/blob/master/src/app/services/supabaseClient.js): `src/app/services/supabaseClient.js`
- [Application logger](https://github.com/froggorrr/matscan-wsserver/blob/master/src/utils/logger.js): `src/utils/logger.js`

### Other components

- **Socket.IO clients**
- **Supabase database**

## Connections

- HTTP and Socket.IO server → Discord listener: starts with Socket.IO (evidence: `src/app/server.js`)
- Discord listener → Embed parser: parses embeds (evidence: `src/app/services/discord.js`)
- Discord listener → Transaction and user writes: inserts records (evidence: `src/app/services/discord.js`)
- Discord listener → Socket.IO clients: emits transactions (evidence: `src/app/services/discord.js`)
- Transaction and user search → Supabase client: queries records (evidence: `src/app/controllers/search.js`)
- Transaction and user search → Discord message search API: searches on miss (evidence: `src/app/controllers/search.js`)
- Transaction and user search → Embed parser: parses results (evidence: `src/app/controllers/search.js`)
- Transaction and user search → Transaction and user writes: inserts search results (evidence: `src/app/controllers/search.js`)
- Transaction and user search → User updates: updates users (evidence: `src/app/controllers/search.js`)
- User updates → Supabase client: updates users (evidence: `src/app/models/update.js`)
- User updates → Transaction and user search: counts matching transactions (evidence: `src/app/models/update.js`)
- Transaction and user writes → Supabase client: reads and writes (evidence: `src/app/models/insert.js`)
- Transaction and user writes → Application logger: logs write outcomes (evidence: `src/app/models/insert.js`)
- Supabase client → Supabase database: connects to
