# rin442666/convenience-finder architecture

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

- Interactive diagram: https://gitdiagram.com/rin442666/convenience-finder
- Repository: https://github.com/rin442666/convenience-finder

## Overview

Convenience Finder helps users locate nearby convenience stores, inspect map results, and find stores through a rule-based chat assistant. Supporting workflows include account access, favorites and ratings, user-submitted store requests, and administrator management and statistics. The store and account layers use a shared database abstraction with SQLite/PostgreSQL modes; store search can also use Google Places and road-distance calculations. The README is empty, and several UI pages and API routes were not sampled, so the graph limits relationships to those shown in excerpts or the source index.

Main entry points: [`src/lib/server-auth.ts`](https://github.com/rin442666/convenience-finder/blob/main/src/lib/server-auth.ts) (Server authentication), [`src/lib/store-db.ts`](https://github.com/rin442666/convenience-finder/blob/main/src/lib/store-db.ts) (Store catalog and reviews), [`src/lib/db.ts`](https://github.com/rin442666/convenience-finder/blob/main/src/lib/db.ts) (Application database), [`src/components/ChatBot.tsx`](https://github.com/rin442666/convenience-finder/blob/main/src/components/ChatBot.tsx) (Chat widget)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_discovery["Store discovery"]
  node_home["Store finder page<br/>[page.tsx]"]
  node_store_api["Store search API<br/>[route.ts]"]
  node_map["Map view<br/>[MapView.tsx]"]
  node_catalog_api["Catalog API<br/>[route.ts]"]
end

subgraph group_assistant["Chat assistant"]
  node_chat_ui["Chat widget<br/>[ChatBot.tsx]"]
  node_chat_api["Chat endpoint<br/>[route.ts]"]
  node_chat_rules["Intent and response logic<br/>[chatbot.ts]"]
  node_voice["Voice input<br/>[use-voice-input.ts]"]
end

subgraph group_accounts["Accounts and community"]
  node_auth_ui["Sign-in dialog<br/>[AuthModal.tsx]"]
  node_app_state["App session provider<br/>[app-provider.tsx]"]
  node_session_storage["Browser session storage<br/>[client-session.ts]"]
  node_auth_rules["Roles and permissions<br/>[auth-system.ts]"]
  node_server_auth["Server authentication<br/>[server-auth.ts]"]
  node_favorites_api["Favorites API<br/>[route.ts]"]
  node_requests_api["Store requests API<br/>[route.ts]"]
  node_request_logic["Store request operations<br/>[store-requests.ts]"]
  node_auth_api["Authentication API<br/>[route.ts]"]
  node_toast["Toast notifications<br/>[Toast.tsx]"]
  node_escape_key["Escape-key handling<br/>[use-escape.ts]"]
end

subgraph group_administration["Administration"]
  node_admin_ui["Admin dashboard<br/>[page.tsx]"]
  node_admin_stats["Admin statistics API<br/>[route.ts]"]
end

subgraph group_data["Data and integrations"]
  node_store_data["Store catalog and reviews<br/>[store-db.ts]"]
  node_database[("Application database<br/>[db.ts]")]
  node_road_distance["Road distance service<br/>[osrm.ts]"]
  node_places["Google Places"]
end

node_visitor(("Visitor"))

node_store_api -->|"queries catalog"| node_store_data
node_store_api -->|"sorts by roads"| node_road_distance
node_store_api -->|"queries places"| node_places
node_catalog_api -->|"loads catalog"| node_store_data
node_chat_ui -->|"sends messages"| node_chat_api
node_chat_ui -->|"uses voice input"| node_voice
node_chat_api -->|"detects intent"| node_chat_rules
node_chat_api -->|"searches stores"| node_store_data
node_chat_api -->|"ranks by roads"| node_road_distance
node_auth_ui -->|"calls login"| node_app_state
node_app_state -->|"persists session"| node_session_storage
node_app_state -->|"uses user types"| node_auth_rules
node_auth_ui -->|"shows messages"| node_toast
node_auth_ui -->|"handles escape"| node_escape_key
node_chat_ui -->|"shows messages"| node_toast
node_chat_ui -->|"handles escape"| node_escape_key
node_auth_api -->|"authenticates users"| node_server_auth
node_server_auth -->|"reads and writes"| node_database
node_server_auth -->|"checks permissions"| node_auth_rules
node_favorites_api -->|"checks session"| node_server_auth
node_favorites_api -->|"reads and writes"| node_database
node_requests_api -->|"checks permissions"| node_server_auth
node_requests_api -->|"manages requests"| node_request_logic
node_requests_api -->|"adds approved store"| node_store_data
node_request_logic -->|"reads and writes"| node_database
node_admin_stats -->|"checks admin"| node_server_auth
node_admin_stats -->|"queries statistics"| node_database
node_store_data -->|"reads and writes"| node_database

click node_home "https://github.com/rin442666/convenience-finder/blob/main/src/app/page.tsx"
click node_store_api "https://github.com/rin442666/convenience-finder/blob/main/src/app/api/stores/route.ts"
click node_map "https://github.com/rin442666/convenience-finder/blob/main/src/components/MapView.tsx"
click node_catalog_api "https://github.com/rin442666/convenience-finder/blob/main/src/app/api/catalog/route.ts"
click node_chat_ui "https://github.com/rin442666/convenience-finder/blob/main/src/components/ChatBot.tsx"
click node_chat_api "https://github.com/rin442666/convenience-finder/blob/main/src/app/api/chat/route.ts"
click node_chat_rules "https://github.com/rin442666/convenience-finder/blob/main/src/lib/chatbot.ts"
click node_voice "https://github.com/rin442666/convenience-finder/blob/main/src/lib/use-voice-input.ts"
click node_auth_ui "https://github.com/rin442666/convenience-finder/blob/main/src/components/AuthModal.tsx"
click node_app_state "https://github.com/rin442666/convenience-finder/blob/main/src/components/app-provider.tsx"
click node_session_storage "https://github.com/rin442666/convenience-finder/blob/main/src/lib/client-session.ts"
click node_auth_rules "https://github.com/rin442666/convenience-finder/blob/main/src/lib/auth-system.ts"
click node_server_auth "https://github.com/rin442666/convenience-finder/blob/main/src/lib/server-auth.ts"
click node_favorites_api "https://github.com/rin442666/convenience-finder/blob/main/src/app/api/favorites/route.ts"
click node_requests_api "https://github.com/rin442666/convenience-finder/blob/main/src/app/api/store-requests/route.ts"
click node_request_logic "https://github.com/rin442666/convenience-finder/blob/main/src/lib/store-requests.ts"
click node_admin_ui "https://github.com/rin442666/convenience-finder/blob/main/src/app/admin/page.tsx"
click node_admin_stats "https://github.com/rin442666/convenience-finder/blob/main/src/app/api/admin/stats/route.ts"
click node_auth_api "https://github.com/rin442666/convenience-finder/blob/main/src/app/api/auth/route.ts"
click node_store_data "https://github.com/rin442666/convenience-finder/blob/main/src/lib/store-db.ts"
click node_database "https://github.com/rin442666/convenience-finder/blob/main/src/lib/db.ts"
click node_road_distance "https://github.com/rin442666/convenience-finder/blob/main/src/lib/osrm.ts"
click node_toast "https://github.com/rin442666/convenience-finder/blob/main/src/components/Toast.tsx"
click node_escape_key "https://github.com/rin442666/convenience-finder/blob/main/src/lib/use-escape.ts"

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_home,node_store_api,node_map,node_catalog_api toneBlue
class node_chat_ui,node_chat_api,node_chat_rules,node_voice toneAmber
class node_auth_ui,node_app_state,node_session_storage,node_auth_rules,node_server_auth,node_favorites_api,node_requests_api,node_request_logic,node_auth_api,node_toast,node_escape_key toneMint
class node_admin_ui,node_admin_stats toneRose
class node_store_data,node_database,node_road_distance,node_places,node_visitor toneIndigo
```

## Components

### Store discovery

- [Store finder page](https://github.com/rin442666/convenience-finder/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Store search API](https://github.com/rin442666/convenience-finder/blob/main/src/app/api/stores/route.ts): `src/app/api/stores/route.ts`
- [Map view](https://github.com/rin442666/convenience-finder/blob/main/src/components/MapView.tsx): `src/components/MapView.tsx`
- [Catalog API](https://github.com/rin442666/convenience-finder/blob/main/src/app/api/catalog/route.ts): `src/app/api/catalog/route.ts`

### Chat assistant

- [Chat widget](https://github.com/rin442666/convenience-finder/blob/main/src/components/ChatBot.tsx): `src/components/ChatBot.tsx`
- [Chat endpoint](https://github.com/rin442666/convenience-finder/blob/main/src/app/api/chat/route.ts): `src/app/api/chat/route.ts`
- [Intent and response logic](https://github.com/rin442666/convenience-finder/blob/main/src/lib/chatbot.ts): `src/lib/chatbot.ts`
- [Voice input](https://github.com/rin442666/convenience-finder/blob/main/src/lib/use-voice-input.ts): `src/lib/use-voice-input.ts`

### Accounts and community

- [Sign-in dialog](https://github.com/rin442666/convenience-finder/blob/main/src/components/AuthModal.tsx): `src/components/AuthModal.tsx`
- [App session provider](https://github.com/rin442666/convenience-finder/blob/main/src/components/app-provider.tsx): `src/components/app-provider.tsx`
- [Browser session storage](https://github.com/rin442666/convenience-finder/blob/main/src/lib/client-session.ts): `src/lib/client-session.ts`
- [Roles and permissions](https://github.com/rin442666/convenience-finder/blob/main/src/lib/auth-system.ts): `src/lib/auth-system.ts`
- [Server authentication](https://github.com/rin442666/convenience-finder/blob/main/src/lib/server-auth.ts): `src/lib/server-auth.ts`
- [Favorites API](https://github.com/rin442666/convenience-finder/blob/main/src/app/api/favorites/route.ts): `src/app/api/favorites/route.ts`
- [Store requests API](https://github.com/rin442666/convenience-finder/blob/main/src/app/api/store-requests/route.ts): `src/app/api/store-requests/route.ts`
- [Store request operations](https://github.com/rin442666/convenience-finder/blob/main/src/lib/store-requests.ts): `src/lib/store-requests.ts`
- [Authentication API](https://github.com/rin442666/convenience-finder/blob/main/src/app/api/auth/route.ts): `src/app/api/auth/route.ts`
- [Toast notifications](https://github.com/rin442666/convenience-finder/blob/main/src/components/Toast.tsx): `src/components/Toast.tsx`
- [Escape-key handling](https://github.com/rin442666/convenience-finder/blob/main/src/lib/use-escape.ts): `src/lib/use-escape.ts`

### Administration

- [Admin dashboard](https://github.com/rin442666/convenience-finder/blob/main/src/app/admin/page.tsx): `src/app/admin/page.tsx`
- [Admin statistics API](https://github.com/rin442666/convenience-finder/blob/main/src/app/api/admin/stats/route.ts): `src/app/api/admin/stats/route.ts`

### Data and integrations

- [Store catalog and reviews](https://github.com/rin442666/convenience-finder/blob/main/src/lib/store-db.ts): `src/lib/store-db.ts`
- [Application database](https://github.com/rin442666/convenience-finder/blob/main/src/lib/db.ts): `src/lib/db.ts`
- [Road distance service](https://github.com/rin442666/convenience-finder/blob/main/src/lib/osrm.ts): `src/lib/osrm.ts`
- **Google Places**

### Other components

- **Visitor**

## Connections

- Store search API → Store catalog and reviews: queries catalog (evidence: `src/app/api/stores/route.ts`)
- Store search API → Road distance service: sorts by roads (evidence: `src/app/api/stores/route.ts`)
- Store search API → Google Places: queries places (evidence: `src/app/api/stores/route.ts`)
- Catalog API → Store catalog and reviews: loads catalog (evidence: `src/app/api/catalog/route.ts`)
- Chat widget → Chat endpoint: sends messages (evidence: `src/components/ChatBot.tsx`)
- Chat widget → Voice input: uses voice input (evidence: `src/components/ChatBot.tsx`)
- Chat endpoint → Intent and response logic: detects intent (evidence: `src/app/api/chat/route.ts`)
- Chat endpoint → Store catalog and reviews: searches stores (evidence: `src/app/api/chat/route.ts`)
- Chat endpoint → Road distance service: ranks by roads (evidence: `src/app/api/chat/route.ts`)
- Sign-in dialog → App session provider: calls login (evidence: `src/components/AuthModal.tsx`)
- App session provider → Browser session storage: persists session (evidence: `src/components/app-provider.tsx`)
- App session provider → Roles and permissions: uses user types (evidence: `src/components/app-provider.tsx`)
- Sign-in dialog → Toast notifications: shows messages (evidence: `src/components/AuthModal.tsx`)
- Sign-in dialog → Escape-key handling: handles escape (evidence: `src/components/AuthModal.tsx`)
- Chat widget → Toast notifications: shows messages (evidence: `src/components/ChatBot.tsx`)
- Chat widget → Escape-key handling: handles escape (evidence: `src/components/ChatBot.tsx`)
- Authentication API → Server authentication: authenticates users (evidence: `src/app/api/auth/route.ts`)
- Server authentication → Application database: reads and writes (evidence: `src/lib/server-auth.ts`)
- Server authentication → Roles and permissions: checks permissions (evidence: `src/lib/server-auth.ts`)
- Favorites API → Server authentication: checks session (evidence: `src/app/api/favorites/route.ts`)
- Favorites API → Application database: reads and writes (evidence: `src/app/api/favorites/route.ts`)
- Store requests API → Server authentication: checks permissions (evidence: `src/app/api/store-requests/route.ts`)
- Store requests API → Store request operations: manages requests (evidence: `src/app/api/store-requests/route.ts`)
- Store requests API → Store catalog and reviews: adds approved store (evidence: `src/app/api/store-requests/route.ts`)
- Store request operations → Application database: reads and writes (evidence: `src/lib/store-requests.ts`)
- Admin statistics API → Server authentication: checks admin (evidence: `src/app/api/admin/stats/route.ts`)
- Admin statistics API → Application database: queries statistics (evidence: `src/app/api/admin/stats/route.ts`)
- Store catalog and reviews → Application database: reads and writes (evidence: `src/lib/store-db.ts`)
