# iam8373/copy-web architecture

> Architecture diagram of the GitHub repository iam8373/copy-web, 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/iam8373/copy-web
- Repository: https://github.com/iam8373/copy-web

## Overview

BharatPredict is an India-focused prediction-market interface: users browse event markets, inspect probabilities and market details, and place simulated trades; signed-in users can review positions and profit. The README describes the default experience as a browser-mocked demo, while the repository also contains Supabase-backed auth, portfolio, and order services for configured deployments. The graph preserves those distinct paths and documented capabilities. Some UI-to-service wiring is supported only by README or SOURCE INDEX references, so unsampled relationships are omitted.

Main entry points: [`src/store/useMarketStore.ts`](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/store/useMarketStore.ts) (Client market state), [`src/services/auth/server.ts`](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/services/auth/server.ts) (Auth service), [`src/lib/supabase/server.ts`](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/lib/supabase/server.ts) (Supabase database), [`src/app/market/[slug]/page.tsx`](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/market/%5Bslug%5D/page.tsx) (Market detail)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_markets["Market discovery"]
  node_home["Home feed<br/>[page.tsx]"]
  node_category["Category browsing<br/>[page.tsx]"]
  node_market_detail["Market detail<br/>[page.tsx]"]
  node_market_data["Market data<br/>[markets.ts]"]
  node_market_reads["Market reads<br/>[read.ts]"]
  node_market_prices["Price and activity<br/>[market-data.ts]"]
  node_search["Market search<br/>[SearchModal.tsx]"]
  node_price_chart["Price chart<br/>[PriceChart.tsx]"]
  node_order_book["Quote order book<br/>[OrderBook.tsx]"]
end

subgraph group_trading["Trading and portfolio"]
  node_trade_ui["Trade interface<br/>[TradeForm.tsx]"]
  node_trade_modal["Quick trade<br/>[TradeModal.tsx]"]
  node_store["Client market state<br/>[useMarketStore.ts]"]
  node_trade_action["Order action<br/>[trade.ts]"]
  node_trading_service["Order service<br/>[server.ts]"]
  node_portfolio_api["Portfolio endpoint<br/>[route.ts]"]
  node_portfolio_service["Portfolio reads<br/>[server.ts]"]
  node_dashboard["Positions dashboard<br/>[DashboardView.tsx]"]
  node_profit["Profit view<br/>[ProfitView.tsx]"]
end

subgraph group_identity["Identity and access"]
  node_auth_modal["Sign-in dialog<br/>[AuthModal.tsx]"]
  node_auth_action["Auth actions<br/>[auth.ts]"]
  node_auth_service["Auth service<br/>[server.ts]"]
  node_auth_callback["OAuth callback<br/>[route.ts]"]
  node_session_api["Session endpoint<br/>[route.ts]"]
  node_supabase[("Supabase database<br/>[server.ts]")]
end

subgraph group_shared["Shared experience"]
  node_language["Language provider"]
  node_dictionaries["Six locale dictionaries<br/>[index.ts]"]
  node_legal_pages["Legal and help pages<br/>[page.tsx]"]
end

node_visitor(("Market visitor"))
node_user(("User"))
node_external_scheduler(("External scheduler"))

node_visitor -->|"browses"| node_home
node_home -->|"shows markets"| node_market_data
node_visitor -->|"filters markets"| node_category
node_visitor -->|"opens market"| node_market_detail
node_search -->|"searches state"| node_store
node_market_detail -->|"shows chart"| node_price_chart
node_market_detail -->|"shows quotes"| node_order_book
node_market_data -->|"provides markets"| node_market_reads
node_market_reads -.->|"uses market data"| node_market_prices
node_user -->|"signs in"| node_auth_modal
node_auth_modal -->|"requests auth"| node_auth_action
node_auth_action -->|"delegates auth"| node_auth_service
node_auth_callback -->|"finishes OAuth"| node_auth_service
node_auth_service -->|"uses session client"| node_supabase
node_session_api -->|"reads session"| node_auth_service
node_trade_ui -.->|"submits trade"| node_store
node_trade_modal -.->|"submits trade"| node_store
node_store -->|"calls order action"| node_trade_action
node_trade_action -->|"delegates order"| node_trading_service
node_trading_service -->|"places order"| node_supabase
node_store -->|"loads portfolio"| node_portfolio_api
node_portfolio_api -->|"reads portfolio"| node_portfolio_service
node_portfolio_service -->|"reads account data"| node_supabase
node_dashboard -.->|"shows positions"| node_store
node_profit -.->|"shows profit"| node_store
node_language -->|"loads translations"| node_dictionaries
node_user -->|"reads guidance"| node_legal_pages
node_external_scheduler -.->|"triggers jobs"| node_supabase

click node_home "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/(home)/page.tsx"
click node_category "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/markets/%5Bcategory%5D/page.tsx"
click node_market_detail "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/market/%5Bslug%5D/page.tsx"
click node_market_data "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/data/markets.ts"
click node_market_reads "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/services/markets/read.ts"
click node_market_prices "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/services/markets/market-data.ts"
click node_search "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/SearchModal.tsx"
click node_price_chart "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/market/PriceChart.tsx"
click node_order_book "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/market/OrderBook.tsx"
click node_trade_ui "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/TradeForm.tsx"
click node_trade_modal "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/TradeModal.tsx"
click node_store "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/store/useMarketStore.ts"
click node_trade_action "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/actions/trade.ts"
click node_trading_service "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/services/trading/server.ts"
click node_portfolio_api "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/api/portfolio/route.ts"
click node_portfolio_service "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/services/portfolio/server.ts"
click node_dashboard "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/DashboardView.tsx"
click node_profit "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/ProfitView.tsx"
click node_auth_modal "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/AuthModal.tsx"
click node_auth_action "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/actions/auth.ts"
click node_auth_service "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/services/auth/server.ts"
click node_auth_callback "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/auth/callback/route.ts"
click node_session_api "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/api/session/route.ts"
click node_supabase "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/lib/supabase/server.ts"
click node_language "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/i18n/LanguageProvider.tsx"
click node_dictionaries "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/i18n/index.ts"
click node_legal_pages "https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/learn/page.tsx"

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_category,node_market_detail,node_market_data,node_market_reads,node_market_prices,node_search,node_price_chart,node_order_book,node_user toneBlue
class node_trade_ui,node_trade_modal,node_store,node_trade_action,node_trading_service,node_portfolio_api,node_portfolio_service,node_dashboard,node_profit toneAmber
class node_auth_modal,node_auth_action,node_auth_service,node_auth_callback,node_session_api,node_supabase toneMint
class node_language,node_dictionaries,node_legal_pages,node_external_scheduler toneRose
class node_visitor toneIndigo
```

## Components

### Market discovery

- [Home feed](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/(home)/page.tsx): `src/app/(home)/page.tsx`
- [Category browsing](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/markets/%5Bcategory%5D/page.tsx): `src/app/markets/[category]/page.tsx`
- [Market detail](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/market/%5Bslug%5D/page.tsx): `src/app/market/[slug]/page.tsx`
- [Market data](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/data/markets.ts): `src/data/markets.ts`
- [Market reads](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/services/markets/read.ts): `src/services/markets/read.ts`
- [Price and activity](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/services/markets/market-data.ts): `src/services/markets/market-data.ts`
- [Market search](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/SearchModal.tsx): `src/components/SearchModal.tsx`
- [Price chart](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/market/PriceChart.tsx): `src/components/market/PriceChart.tsx`
- [Quote order book](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/market/OrderBook.tsx): `src/components/market/OrderBook.tsx`

### Trading and portfolio

- [Trade interface](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/TradeForm.tsx): `src/components/TradeForm.tsx`
- [Quick trade](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/TradeModal.tsx): `src/components/TradeModal.tsx`
- [Client market state](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/store/useMarketStore.ts): `src/store/useMarketStore.ts`
- [Order action](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/actions/trade.ts): `src/app/actions/trade.ts`
- [Order service](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/services/trading/server.ts): `src/services/trading/server.ts`
- [Portfolio endpoint](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/api/portfolio/route.ts): `src/app/api/portfolio/route.ts`
- [Portfolio reads](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/services/portfolio/server.ts): `src/services/portfolio/server.ts`
- [Positions dashboard](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/DashboardView.tsx): `src/components/DashboardView.tsx`
- [Profit view](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/ProfitView.tsx): `src/components/ProfitView.tsx`

### Identity and access

- [Sign-in dialog](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/components/AuthModal.tsx): `src/components/AuthModal.tsx`
- [Auth actions](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/actions/auth.ts): `src/app/actions/auth.ts`
- [Auth service](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/services/auth/server.ts): `src/services/auth/server.ts`
- [OAuth callback](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/auth/callback/route.ts): `src/app/auth/callback/route.ts`
- [Session endpoint](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/api/session/route.ts): `src/app/api/session/route.ts`
- [Supabase database](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/lib/supabase/server.ts): `src/lib/supabase/server.ts`

### Shared experience

- [Language provider](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/i18n/LanguageProvider.tsx): `src/i18n/LanguageProvider.tsx`
- [Six locale dictionaries](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/i18n/index.ts): `src/i18n/index.ts`
- [Legal and help pages](https://github.com/iam8373/copy-web/blob/surajsk70743/set-up-this-codebase-for-DZu725/src/app/learn/page.tsx): `src/app/learn/page.tsx`

### Other components

- **Market visitor**
- **User**
- **External scheduler**

## Connections

- Market visitor → Home feed: browses
- Home feed → Market data: shows markets
- Market visitor → Category browsing: filters markets
- Market visitor → Market detail: opens market
- Market search → Client market state: searches state (evidence: `src/components/SearchModal.tsx`)
- Market detail → Price chart: shows chart
- Market detail → Quote order book: shows quotes
- Market data → Market reads: provides markets (evidence: `src/data/markets.ts`)
- Market reads → Price and activity: uses market data
- User → Sign-in dialog: signs in
- Sign-in dialog → Auth actions: requests auth (evidence: `src/components/AuthModal.tsx`)
- Auth actions → Auth service: delegates auth (evidence: `src/app/actions/auth.ts`)
- OAuth callback → Auth service: finishes OAuth (evidence: `src/app/auth/callback/route.ts`)
- Auth service → Supabase database: uses session client (evidence: `src/services/auth/server.ts`)
- Session endpoint → Auth service: reads session (evidence: `src/app/api/session/route.ts`)
- Trade interface → Client market state: submits trade
- Quick trade → Client market state: submits trade
- Client market state → Order action: calls order action (evidence: `src/store/useMarketStore.ts`)
- Order action → Order service: delegates order (evidence: `src/app/actions/trade.ts`)
- Order service → Supabase database: places order (evidence: `src/services/trading/server.ts`)
- Client market state → Portfolio endpoint: loads portfolio (evidence: `src/store/useMarketStore.ts`)
- Portfolio endpoint → Portfolio reads: reads portfolio (evidence: `src/app/api/portfolio/route.ts`)
- Portfolio reads → Supabase database: reads account data (evidence: `src/services/portfolio/server.ts`)
- Positions dashboard → Client market state: shows positions
- Profit view → Client market state: shows profit
- Language provider → Six locale dictionaries: loads translations (evidence: `src/i18n/LanguageProvider.tsx`)
- User → Legal and help pages: reads guidance
- External scheduler → Supabase database: triggers jobs
