# mohithjk/flashdrop architecture

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

- Interactive diagram: https://gitdiagram.com/mohithjk/flashdrop
- Repository: https://github.com/mohithjk/flashdrop

## Overview

FlashDrop is a limited-inventory product storefront with OTP-confirmed checkout and an admin area for drops, orders, sales, and users. The main customer flow loads products, filters and opens a product, then initiates and confirms an order through API routes that persist state in a JSON-backed database. The graph includes the documented-by-source-index admin and authentication branches; unsampled implementations are represented at their exact tree paths, with relationships included only where the excerpts or source index show them.

Main entry points: [`src/lib/db.ts`](https://github.com/mohithjk/flashdrop/blob/main/src/lib/db.ts) (JSON database access), [`src/app/page.tsx`](https://github.com/mohithjk/flashdrop/blob/main/src/app/page.tsx) (Home page), [`src/components/StorefrontClient.tsx`](https://github.com/mohithjk/flashdrop/blob/main/src/components/StorefrontClient.tsx) (Product storefront), [`src/components/CheckoutButton.tsx`](https://github.com/mohithjk/flashdrop/blob/main/src/components/CheckoutButton.tsx) (OTP checkout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_home["Home page<br/>[page.tsx]"]
  node_spotlight["Hero spotlight<br/>[HeroSpotlight.tsx]"]
  node_storefront_ui["Product storefront"]
  node_category["Category filter<br/>[CategoryFilter.tsx]"]
  node_product_card["Product card<br/>[ProductCard.tsx]"]
  node_product_page["Product details<br/>[page.tsx]"]
  node_product_modal["Product detail modal"]
  node_products_api["Products API<br/>[route.ts]"]
  node_drops_api["Drops API<br/>[route.ts]"]
end

subgraph group_checkout["Checkout and orders"]
  node_checkout_button["OTP checkout<br/>[CheckoutButton.tsx]"]
  node_initiate_api["Order initiation API<br/>[route.ts]"]
  node_confirm_api["Order confirmation API<br/>[route.ts]"]
end

subgraph group_admin["Admin operations"]
  node_admin_layout["Admin layout<br/>[layout.tsx]"]
  node_admin_dashboard["Admin dashboard<br/>[page.tsx]"]
  node_order_table["Admin order table"]
  node_sales_chart["Sales chart<br/>[SalesChart.tsx]"]
  node_drop_form_page["Create-drop page<br/>[page.tsx]"]
  node_drop_form["Drop form<br/>[CreateDropForm.tsx]"]
  node_users_page["Admin users page<br/>[page.tsx]"]
  node_users_table["Users table<br/>[UsersTable.tsx]"]
end

subgraph group_auth["Authentication and layout"]
  node_auth_guard["Authentication guard<br/>[AuthGuard.tsx]"]
  node_login["Login screen<br/>[LoginScreen.tsx]"]
  node_admin_guard["Admin guard<br/>[AdminGuard.tsx]"]
  node_register_api["Registration API<br/>[route.ts]"]
  node_layout_wrapper["Layout wrapper<br/>[LayoutWrapper.tsx]"]
  node_navbar["Navigation bar<br/>[Navbar.tsx]"]
  node_splash["Splash screen<br/>[SplashScreen.tsx]"]
  node_announcement["Announcement ticker"]
end

subgraph group_storage["Data storage"]
  node_db[("JSON database access<br/>[db.ts]")]
end

node_visitor(("Shopper"))

node_visitor -->|"visits"| node_home
node_home -->|"reads products"| node_db
node_home -->|"renders"| node_spotlight
node_home -->|"renders products"| node_storefront_ui
node_storefront_ui -->|"renders"| node_category
node_storefront_ui -->|"renders"| node_product_card
node_storefront_ui -->|"opens selected"| node_product_modal
node_product_page -->|"reads product"| node_db
node_product_page -->|"renders checkout"| node_checkout_button
node_product_modal -->|"renders checkout"| node_checkout_button
node_checkout_button -->|"requests OTP"| node_initiate_api
node_checkout_button -->|"submits OTP"| node_confirm_api
node_initiate_api -->|"reads and writes order"| node_db
node_confirm_api -->|"confirms and updates"| node_db
node_products_api -->|"reads and writes products"| node_db
node_admin_layout -->|"guards admin"| node_admin_guard
node_admin_dashboard -->|"reads orders and products"| node_db
node_admin_dashboard -->|"renders orders"| node_order_table
node_admin_dashboard -->|"renders chart"| node_sales_chart
node_drop_form_page -->|"renders"| node_drop_form
node_users_page -->|"reads users"| node_db
node_users_page -->|"renders users"| node_users_table
node_register_api -->|"persists registration"| node_db
node_auth_guard -->|"shows login"| node_login
node_layout_wrapper -->|"renders"| node_splash
node_layout_wrapper -->|"renders"| node_navbar
node_layout_wrapper -->|"renders"| node_announcement

click node_home "https://github.com/mohithjk/flashdrop/blob/main/src/app/page.tsx"
click node_spotlight "https://github.com/mohithjk/flashdrop/blob/main/src/components/HeroSpotlight.tsx"
click node_storefront_ui "https://github.com/mohithjk/flashdrop/blob/main/src/components/StorefrontClient.tsx"
click node_category "https://github.com/mohithjk/flashdrop/blob/main/src/components/CategoryFilter.tsx"
click node_product_card "https://github.com/mohithjk/flashdrop/blob/main/src/components/ProductCard.tsx"
click node_product_page "https://github.com/mohithjk/flashdrop/blob/main/src/app/product/%5Bid%5D/page.tsx"
click node_product_modal "https://github.com/mohithjk/flashdrop/blob/main/src/components/ProductFullScreen.tsx"
click node_checkout_button "https://github.com/mohithjk/flashdrop/blob/main/src/components/CheckoutButton.tsx"
click node_products_api "https://github.com/mohithjk/flashdrop/blob/main/src/app/api/products/route.ts"
click node_drops_api "https://github.com/mohithjk/flashdrop/blob/main/src/app/api/drops/route.ts"
click node_initiate_api "https://github.com/mohithjk/flashdrop/blob/main/src/app/api/orders/initiate/route.ts"
click node_confirm_api "https://github.com/mohithjk/flashdrop/blob/main/src/app/api/orders/confirm/route.ts"
click node_admin_layout "https://github.com/mohithjk/flashdrop/blob/main/src/app/admin/layout.tsx"
click node_admin_dashboard "https://github.com/mohithjk/flashdrop/blob/main/src/app/admin/page.tsx"
click node_order_table "https://github.com/mohithjk/flashdrop/blob/main/src/components/AdminOrderTable.tsx"
click node_sales_chart "https://github.com/mohithjk/flashdrop/blob/main/src/components/SalesChart.tsx"
click node_drop_form_page "https://github.com/mohithjk/flashdrop/blob/main/src/app/admin/create/page.tsx"
click node_drop_form "https://github.com/mohithjk/flashdrop/blob/main/src/components/CreateDropForm.tsx"
click node_users_page "https://github.com/mohithjk/flashdrop/blob/main/src/app/admin/users/page.tsx"
click node_users_table "https://github.com/mohithjk/flashdrop/blob/main/src/components/UsersTable.tsx"
click node_auth_guard "https://github.com/mohithjk/flashdrop/blob/main/src/components/AuthGuard.tsx"
click node_login "https://github.com/mohithjk/flashdrop/blob/main/src/components/LoginScreen.tsx"
click node_admin_guard "https://github.com/mohithjk/flashdrop/blob/main/src/components/AdminGuard.tsx"
click node_register_api "https://github.com/mohithjk/flashdrop/blob/main/src/app/api/auth/register/route.ts"
click node_layout_wrapper "https://github.com/mohithjk/flashdrop/blob/main/src/components/LayoutWrapper.tsx"
click node_navbar "https://github.com/mohithjk/flashdrop/blob/main/src/components/Navbar.tsx"
click node_splash "https://github.com/mohithjk/flashdrop/blob/main/src/components/SplashScreen.tsx"
click node_announcement "https://github.com/mohithjk/flashdrop/blob/main/src/components/AnnouncementTicker.tsx"
click node_db "https://github.com/mohithjk/flashdrop/blob/main/src/lib/db.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_spotlight,node_storefront_ui,node_category,node_product_card,node_product_page,node_product_modal,node_products_api,node_drops_api toneBlue
class node_checkout_button,node_initiate_api,node_confirm_api toneAmber
class node_admin_layout,node_admin_dashboard,node_order_table,node_sales_chart,node_drop_form_page,node_drop_form,node_users_page,node_users_table toneMint
class node_auth_guard,node_login,node_admin_guard,node_register_api,node_layout_wrapper,node_navbar,node_splash,node_announcement toneRose
class node_db,node_visitor toneIndigo
```

## Components

### Storefront

- [Home page](https://github.com/mohithjk/flashdrop/blob/main/src/app/page.tsx): `src/app/page.tsx`
- [Hero spotlight](https://github.com/mohithjk/flashdrop/blob/main/src/components/HeroSpotlight.tsx): `src/components/HeroSpotlight.tsx`
- [Product storefront](https://github.com/mohithjk/flashdrop/blob/main/src/components/StorefrontClient.tsx): `src/components/StorefrontClient.tsx`
- [Category filter](https://github.com/mohithjk/flashdrop/blob/main/src/components/CategoryFilter.tsx): `src/components/CategoryFilter.tsx`
- [Product card](https://github.com/mohithjk/flashdrop/blob/main/src/components/ProductCard.tsx): `src/components/ProductCard.tsx`
- [Product details](https://github.com/mohithjk/flashdrop/blob/main/src/app/product/%5Bid%5D/page.tsx): `src/app/product/[id]/page.tsx`
- [Product detail modal](https://github.com/mohithjk/flashdrop/blob/main/src/components/ProductFullScreen.tsx): `src/components/ProductFullScreen.tsx`
- [Products API](https://github.com/mohithjk/flashdrop/blob/main/src/app/api/products/route.ts): `src/app/api/products/route.ts`
- [Drops API](https://github.com/mohithjk/flashdrop/blob/main/src/app/api/drops/route.ts): `src/app/api/drops/route.ts`

### Checkout and orders

- [OTP checkout](https://github.com/mohithjk/flashdrop/blob/main/src/components/CheckoutButton.tsx): `src/components/CheckoutButton.tsx`
- [Order initiation API](https://github.com/mohithjk/flashdrop/blob/main/src/app/api/orders/initiate/route.ts): `src/app/api/orders/initiate/route.ts`
- [Order confirmation API](https://github.com/mohithjk/flashdrop/blob/main/src/app/api/orders/confirm/route.ts): `src/app/api/orders/confirm/route.ts`

### Admin operations

- [Admin layout](https://github.com/mohithjk/flashdrop/blob/main/src/app/admin/layout.tsx): `src/app/admin/layout.tsx`
- [Admin dashboard](https://github.com/mohithjk/flashdrop/blob/main/src/app/admin/page.tsx): `src/app/admin/page.tsx`
- [Admin order table](https://github.com/mohithjk/flashdrop/blob/main/src/components/AdminOrderTable.tsx): `src/components/AdminOrderTable.tsx`
- [Sales chart](https://github.com/mohithjk/flashdrop/blob/main/src/components/SalesChart.tsx): `src/components/SalesChart.tsx`
- [Create-drop page](https://github.com/mohithjk/flashdrop/blob/main/src/app/admin/create/page.tsx): `src/app/admin/create/page.tsx`
- [Drop form](https://github.com/mohithjk/flashdrop/blob/main/src/components/CreateDropForm.tsx): `src/components/CreateDropForm.tsx`
- [Admin users page](https://github.com/mohithjk/flashdrop/blob/main/src/app/admin/users/page.tsx): `src/app/admin/users/page.tsx`
- [Users table](https://github.com/mohithjk/flashdrop/blob/main/src/components/UsersTable.tsx): `src/components/UsersTable.tsx`

### Authentication and layout

- [Authentication guard](https://github.com/mohithjk/flashdrop/blob/main/src/components/AuthGuard.tsx): `src/components/AuthGuard.tsx`
- [Login screen](https://github.com/mohithjk/flashdrop/blob/main/src/components/LoginScreen.tsx): `src/components/LoginScreen.tsx`
- [Admin guard](https://github.com/mohithjk/flashdrop/blob/main/src/components/AdminGuard.tsx): `src/components/AdminGuard.tsx`
- [Registration API](https://github.com/mohithjk/flashdrop/blob/main/src/app/api/auth/register/route.ts): `src/app/api/auth/register/route.ts`
- [Layout wrapper](https://github.com/mohithjk/flashdrop/blob/main/src/components/LayoutWrapper.tsx): `src/components/LayoutWrapper.tsx`
- [Navigation bar](https://github.com/mohithjk/flashdrop/blob/main/src/components/Navbar.tsx): `src/components/Navbar.tsx`
- [Splash screen](https://github.com/mohithjk/flashdrop/blob/main/src/components/SplashScreen.tsx): `src/components/SplashScreen.tsx`
- [Announcement ticker](https://github.com/mohithjk/flashdrop/blob/main/src/components/AnnouncementTicker.tsx): `src/components/AnnouncementTicker.tsx`

### Data storage

- [JSON database access](https://github.com/mohithjk/flashdrop/blob/main/src/lib/db.ts): `src/lib/db.ts`

### Other components

- **Shopper**

## Connections

- Shopper → Home page: visits (evidence: `src/app/page.tsx`)
- Home page → JSON database access: reads products (evidence: `src/app/page.tsx`)
- Home page → Hero spotlight: renders (evidence: `src/app/page.tsx`)
- Home page → Product storefront: renders products (evidence: `src/app/page.tsx`)
- Product storefront → Category filter: renders (evidence: `src/components/StorefrontClient.tsx`)
- Product storefront → Product card: renders (evidence: `src/components/StorefrontClient.tsx`)
- Product storefront → Product detail modal: opens selected (evidence: `src/components/StorefrontClient.tsx`)
- Product details → JSON database access: reads product (evidence: `src/app/product/[id]/page.tsx`)
- Product details → OTP checkout: renders checkout (evidence: `src/app/product/[id]/page.tsx`)
- Product detail modal → OTP checkout: renders checkout (evidence: `src/components/ProductFullScreen.tsx`)
- OTP checkout → Order initiation API: requests OTP (evidence: `src/components/CheckoutButton.tsx`)
- OTP checkout → Order confirmation API: submits OTP (evidence: `src/components/CheckoutButton.tsx`)
- Order initiation API → JSON database access: reads and writes order (evidence: `src/app/api/orders/initiate/route.ts`)
- Order confirmation API → JSON database access: confirms and updates (evidence: `src/app/api/orders/confirm/route.ts`)
- Products API → JSON database access: reads and writes products (evidence: `src/app/api/products/route.ts`)
- Admin layout → Admin guard: guards admin (evidence: `src/app/admin/layout.tsx`)
- Admin dashboard → JSON database access: reads orders and products (evidence: `src/app/admin/page.tsx`)
- Admin dashboard → Admin order table: renders orders (evidence: `src/app/admin/page.tsx`)
- Admin dashboard → Sales chart: renders chart (evidence: `src/app/admin/page.tsx`)
- Create-drop page → Drop form: renders (evidence: `src/app/admin/create/page.tsx`)
- Admin users page → JSON database access: reads users (evidence: `src/app/admin/users/page.tsx`)
- Admin users page → Users table: renders users (evidence: `src/app/admin/users/page.tsx`)
- Registration API → JSON database access: persists registration (evidence: `src/app/api/auth/register/route.ts`)
- Authentication guard → Login screen: shows login (evidence: `src/components/AuthGuard.tsx`)
- Layout wrapper → Splash screen: renders (evidence: `src/components/LayoutWrapper.tsx`)
- Layout wrapper → Navigation bar: renders (evidence: `src/components/LayoutWrapper.tsx`)
- Layout wrapper → Announcement ticker: renders (evidence: `src/components/LayoutWrapper.tsx`)
