# allanrye9/piitrade-videos architecture

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

- Interactive diagram: https://gitdiagram.com/allanrye9/piitrade-videos
- Repository: https://github.com/allanrye9/piitrade-videos

## Overview

Piitrade Videos is a short-video social product with mobile and web clients backed by an Express API. The principal mobile workflow lets guests browse and watch the feed; signed-in users can upload and interact, while uploads are processed and videos become available through the service. Visual search is a distinct discovery path, and the web client also provides share links, legal pages, and administration. The graph preserves documented capabilities, but several backend route implementations and client screens were not sampled; those links rely on README documentation rather than claims of source inspection.

Main entry points: [`backend/src/index.ts`](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/index.ts) (Express API), [`mobile/src/App.tsx`](https://github.com/allanrye9/piitrade-videos/blob/main/mobile/src/App.tsx) (Mobile shell), [`backend/src/routes/visualSearch.ts`](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/visualSearch.ts) (Visual search route), [`frontend/src/main.tsx`](https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/main.tsx) (Web routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile app"]
  node_mobile_shell["Mobile shell<br/>[App.tsx]"]
  node_mobile_feed["Feed and playback<br/>[FeedScreen.tsx]"]
  node_mobile_sheets["Action sheets"]
  node_mobile_state["Session and app state<br/>[AppContext.tsx]"]
  node_mobile_upload["Mobile upload<br/>[UploadSheet.tsx]"]
  node_mobile_api["Mobile API client<br/>[api.ts]"]
end

subgraph group_web["Web app"]
  node_web_router["Web routes<br/>[main.tsx]"]
  node_web_app["Web feed<br/>[App.tsx]"]
  node_web_auth["Web authentication<br/>[AuthGate.tsx]"]
  node_web_upload["Web upload manager<br/>[uploadManager.ts]"]
  node_web_discovery["Web discovery<br/>[DiscoverPage.tsx]"]
  node_web_share["Share and legal pages"]
  node_web_admin["Admin dashboard<br/>[AdminDashboard.tsx]"]
  node_web_api["Web API client<br/>[api.ts]"]
end

subgraph group_api["API and domain"]
  node_api_server["Express API<br/>[index.ts]"]
  node_video_routes["Video routes<br/>[videos.ts]"]
  node_auth_routes["Authentication<br/>[auth.ts]"]
  node_profile_routes["Profiles and accounts<br/>[profile.ts]"]
  node_social_routes["Social interactions<br/>[account.ts]"]
  node_notification_routes["Notifications<br/>[notifications.ts]"]
  node_visual_routes["Visual search route<br/>[visualSearch.ts]"]
  node_image_hash["Image similarity<br/>[phash.ts]"]
  node_ai_search["Image identification<br/>[aiSearch.ts]"]
  node_marketplace["Marketplace search<br/>[marketplace.ts]"]
end

subgraph group_services["Data and media"]
  node_database[("Prisma database<br/>[db.ts]")]
  node_media_storage[("Media storage<br/>[r2.ts]")]
end

node_viewer(("Viewer"))
node_marketplace_service["Marketplace service"]
node_ai_service["AI identification service"]

node_viewer -->|"opens"| node_mobile_shell
node_mobile_shell -->|"renders"| node_mobile_feed
node_mobile_shell -->|"dispatches"| node_mobile_sheets
node_mobile_shell -->|"provides state"| node_mobile_state
node_mobile_feed -->|"requests feed"| node_mobile_api
node_mobile_sheets -->|"uses state"| node_mobile_state
node_mobile_upload -->|"uploads video"| node_mobile_api
node_mobile_api -->|"calls API"| node_api_server
node_web_router -->|"routes to"| node_web_app
node_web_router -->|"routes to"| node_web_share
node_web_router -->|"routes to"| node_web_admin
node_web_app -->|"registers handler"| node_web_upload
node_web_upload -->|"uploads video"| node_web_api
node_web_app -->|"requests feed"| node_web_api
node_web_auth -->|"authenticates"| node_web_api
node_web_api -->|"calls API"| node_api_server
node_api_server -->|"mounts"| node_video_routes
node_api_server -->|"mounts"| node_visual_routes
node_api_server -->|"mounts"| node_auth_routes
node_api_server -->|"mounts"| node_profile_routes
node_api_server -->|"mounts"| node_social_routes
node_api_server -->|"mounts"| node_notification_routes
node_visual_routes -->|"identifies image"| node_ai_search
node_visual_routes -->|"searches products"| node_marketplace
node_visual_routes -->|"computes similarity"| node_image_hash
node_ai_search -.->|"queries"| node_ai_service
node_marketplace -.->|"searches"| node_marketplace_service
node_viewer -->|"opens"| node_web_router
node_viewer -->|"discovers videos"| node_web_discovery
node_viewer -->|"requests actions"| node_mobile_sheets
node_mobile_state -->|"loads profile"| node_mobile_api
node_video_routes -.->|"uses persistence"| node_database
node_video_routes -.->|"stores media"| node_media_storage

click node_mobile_shell "https://github.com/allanrye9/piitrade-videos/blob/main/mobile/src/App.tsx"
click node_mobile_feed "https://github.com/allanrye9/piitrade-videos/blob/main/mobile/src/screens/FeedScreen.tsx"
click node_mobile_sheets "https://github.com/allanrye9/piitrade-videos/tree/main/mobile/src/sheets"
click node_mobile_state "https://github.com/allanrye9/piitrade-videos/blob/main/mobile/src/state/AppContext.tsx"
click node_mobile_upload "https://github.com/allanrye9/piitrade-videos/blob/main/mobile/src/sheets/UploadSheet.tsx"
click node_mobile_api "https://github.com/allanrye9/piitrade-videos/blob/main/mobile/src/api.ts"
click node_web_router "https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/main.tsx"
click node_web_app "https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/App.tsx"
click node_web_auth "https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/components/AuthGate.tsx"
click node_web_upload "https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/uploadManager.ts"
click node_web_discovery "https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/components/DiscoverPage.tsx"
click node_web_share "https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/components/VideoPermalinkPage.tsx"
click node_web_admin "https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/admin/AdminDashboard.tsx"
click node_web_api "https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/api.ts"
click node_api_server "https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/index.ts"
click node_video_routes "https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/videos.ts"
click node_auth_routes "https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/auth.ts"
click node_profile_routes "https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/profile.ts"
click node_social_routes "https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/account.ts"
click node_notification_routes "https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/notifications.ts"
click node_visual_routes "https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/visualSearch.ts"
click node_image_hash "https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/lib/phash.ts"
click node_ai_search "https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/lib/aiSearch.ts"
click node_marketplace "https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/lib/marketplace.ts"
click node_database "https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/db.ts"
click node_media_storage "https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/lib/r2.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_mobile_shell,node_mobile_feed,node_mobile_sheets,node_mobile_state,node_mobile_upload,node_mobile_api,node_viewer toneBlue
class node_web_router,node_web_app,node_web_auth,node_web_upload,node_web_discovery,node_web_share,node_web_admin,node_web_api toneAmber
class node_api_server,node_video_routes,node_auth_routes,node_profile_routes,node_social_routes,node_notification_routes,node_visual_routes,node_image_hash,node_ai_search,node_marketplace toneMint
class node_database,node_media_storage toneRose
class node_marketplace_service,node_ai_service toneIndigo
```

## Components

### Mobile app

- [Mobile shell](https://github.com/allanrye9/piitrade-videos/blob/main/mobile/src/App.tsx): `mobile/src/App.tsx`
- [Feed and playback](https://github.com/allanrye9/piitrade-videos/blob/main/mobile/src/screens/FeedScreen.tsx): `mobile/src/screens/FeedScreen.tsx`
- [Action sheets](https://github.com/allanrye9/piitrade-videos/tree/main/mobile/src/sheets): `mobile/src/sheets`
- [Session and app state](https://github.com/allanrye9/piitrade-videos/blob/main/mobile/src/state/AppContext.tsx): `mobile/src/state/AppContext.tsx`
- [Mobile upload](https://github.com/allanrye9/piitrade-videos/blob/main/mobile/src/sheets/UploadSheet.tsx): `mobile/src/sheets/UploadSheet.tsx`
- [Mobile API client](https://github.com/allanrye9/piitrade-videos/blob/main/mobile/src/api.ts): `mobile/src/api.ts`

### Web app

- [Web routes](https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/main.tsx): `frontend/src/main.tsx`
- [Web feed](https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Web authentication](https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/components/AuthGate.tsx): `frontend/src/components/AuthGate.tsx`
- [Web upload manager](https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/uploadManager.ts): `frontend/src/uploadManager.ts`
- [Web discovery](https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/components/DiscoverPage.tsx): `frontend/src/components/DiscoverPage.tsx`
- [Share and legal pages](https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/components/VideoPermalinkPage.tsx): `frontend/src/components/VideoPermalinkPage.tsx`
- [Admin dashboard](https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/admin/AdminDashboard.tsx): `frontend/src/admin/AdminDashboard.tsx`
- [Web API client](https://github.com/allanrye9/piitrade-videos/blob/main/frontend/src/api.ts): `frontend/src/api.ts`

### API and domain

- [Express API](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/index.ts): `backend/src/index.ts`
- [Video routes](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/videos.ts): `backend/src/routes/videos.ts`
- [Authentication](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/auth.ts): `backend/src/routes/auth.ts`
- [Profiles and accounts](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/profile.ts): `backend/src/routes/profile.ts`
- [Social interactions](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/account.ts): `backend/src/routes/account.ts`
- [Notifications](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/notifications.ts): `backend/src/routes/notifications.ts`
- [Visual search route](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/routes/visualSearch.ts): `backend/src/routes/visualSearch.ts`
- [Image similarity](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/lib/phash.ts): `backend/src/lib/phash.ts`
- [Image identification](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/lib/aiSearch.ts): `backend/src/lib/aiSearch.ts`
- [Marketplace search](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/lib/marketplace.ts): `backend/src/lib/marketplace.ts`

### Data and media

- [Prisma database](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/db.ts): `backend/src/db.ts`
- [Media storage](https://github.com/allanrye9/piitrade-videos/blob/main/backend/src/lib/r2.ts): `backend/src/lib/r2.ts`

### Other components

- **Viewer**
- **Marketplace service**
- **AI identification service**

## Connections

- Viewer → Mobile shell: opens (evidence: `README.md`)
- Mobile shell → Feed and playback: renders (evidence: `mobile/src/App.tsx`)
- Mobile shell → Action sheets: dispatches (evidence: `mobile/src/App.tsx`)
- Mobile shell → Session and app state: provides state (evidence: `mobile/src/App.tsx`)
- Feed and playback → Mobile API client: requests feed (evidence: `mobile/src/screens/FeedScreen.tsx`)
- Action sheets → Session and app state: uses state (evidence: `mobile/src/sheets/AuthSheet.tsx`)
- Mobile upload → Mobile API client: uploads video (evidence: `mobile/src/sheets/UploadSheet.tsx`)
- Mobile API client → Express API: calls API (evidence: `README.md`)
- Web routes → Web feed: routes to (evidence: `frontend/src/main.tsx`)
- Web routes → Share and legal pages: routes to (evidence: `frontend/src/main.tsx`)
- Web routes → Admin dashboard: routes to (evidence: `frontend/src/main.tsx`)
- Web feed → Web upload manager: registers handler (evidence: `frontend/src/App.tsx`)
- Web upload manager → Web API client: uploads video (evidence: `frontend/src/uploadManager.ts`)
- Web feed → Web API client: requests feed (evidence: `frontend/src/App.tsx`)
- Web authentication → Web API client: authenticates (evidence: `frontend/src/components/AuthGate.tsx`)
- Web API client → Express API: calls API (evidence: `README.md`)
- Express API → Video routes: mounts (evidence: `backend/src/index.ts`)
- Express API → Visual search route: mounts (evidence: `backend/src/index.ts`)
- Express API → Authentication: mounts (evidence: `backend/src/index.ts`)
- Express API → Profiles and accounts: mounts (evidence: `backend/src/index.ts`)
- Express API → Social interactions: mounts (evidence: `backend/src/index.ts`)
- Express API → Notifications: mounts (evidence: `backend/src/index.ts`)
- Visual search route → Image identification: identifies image (evidence: `backend/src/routes/visualSearch.ts`)
- Visual search route → Marketplace search: searches products (evidence: `backend/src/routes/visualSearch.ts`)
- Visual search route → Image similarity: computes similarity (evidence: `backend/src/routes/visualSearch.ts`)
- Image identification → AI identification service: queries
- Marketplace search → Marketplace service: searches
- Viewer → Web routes: opens (evidence: `README.md`)
- Viewer → Web discovery: discovers videos (evidence: `README.md`)
- Viewer → Action sheets: requests actions (evidence: `README.md`)
- Session and app state → Mobile API client: loads profile (evidence: `mobile/src/state/AppContext.tsx`)
- Video routes → Prisma database: uses persistence
- Video routes → Media storage: stores media
