# lepoly-create/codealpha_fs_01 architecture

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

- Interactive diagram: https://gitdiagram.com/lepoly-create/codealpha_fs_01
- Repository: https://github.com/lepoly-create/codealpha_fs_01

## Overview

MarketElectro is a customer-facing electronics storefront with an administrative interface. Customers enter through the frontend, where routes expose product browsing, cart and checkout, account/profile, and dashboard pages; administrators have separate management pages. The backend mounts API routes that dispatch to controllers and, where shown, service logic and MongoDB models. Messaging, favorites, orders, and store settings are represented as documented route capabilities, but their full runtime wiring is not shown. Frontend-to-backend request links are omitted because the excerpts do not establish them.

Main entry points: [`backend/src/app.ts`](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/app.ts) (Express API), [`backend/src/middleware`](https://github.com/lepoly-create/codealpha_fs_01/tree/main/backend/src/middleware) (Access middleware), [`backend/src/models`](https://github.com/lepoly-create/codealpha_fs_01/tree/main/backend/src/models) (MongoDB models), [`frontend/src/routes/AppRoutes.tsx`](https://github.com/lepoly-create/codealpha_fs_01/blob/main/frontend/src/routes/AppRoutes.tsx) (Web routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend experience"]
  node_web_routes["Web routes<br/>[AppRoutes.tsx]"]
  node_customer_pages["Customer pages"]
  node_admin_pages["Admin pages"]
  node_auth_context["Auth context<br/>[AuthContext.tsx]"]
end

subgraph group_api["API and access"]
  node_api_app["Express API<br/>[app.ts]"]
  node_auth_routes["Auth routes<br/>[auth.routes.ts]"]
  node_product_routes["Product routes<br/>[product.routes.ts]"]
  node_cart_routes["Cart routes<br/>[cart.routes.ts]"]
  node_order_routes["Order routes<br/>[order.routes.ts]"]
  node_user_routes["User routes<br/>[user.routes.ts]"]
  node_admin_routes["Admin routes<br/>[admin.routes.ts]"]
  node_message_routes["Message routes<br/>[message.routes.ts]"]
  node_access_middleware["Access middleware"]
end

subgraph group_commerce["Commerce services"]
  node_product_controller["Product controller"]
  node_product_service["Product service"]
  node_admin_controller["Admin controller"]
  node_admin_service["Admin service<br/>[admin.services.ts]"]
  node_data_models[("MongoDB models")]
end

subgraph group_accounts["Accounts and support"]
  node_auth_controller["Auth controller"]
  node_user_controller["User controller"]
  node_message_controller["Message controller"]
  node_auth_service["Auth service<br/>[auth.services.ts]"]
  node_user_service["User service<br/>[user.services.ts]"]
  node_message_service["Message service"]
  node_jwt["JWT utility<br/>[jwt.ts]"]
end

node_shopper(("Shopper or admin"))

node_shopper -->|"visits"| node_web_routes
node_web_routes -->|"routes to"| node_customer_pages
node_web_routes -->|"routes to"| node_admin_pages
node_api_app -->|"mounts"| node_auth_routes
node_api_app -->|"mounts"| node_product_routes
node_api_app -->|"mounts"| node_cart_routes
node_api_app -->|"mounts"| node_order_routes
node_api_app -->|"mounts"| node_user_routes
node_api_app -->|"mounts"| node_admin_routes
node_api_app -->|"mounts"| node_message_routes
node_auth_routes -->|"dispatches"| node_auth_controller
node_auth_routes -->|"uses"| node_access_middleware
node_admin_routes -->|"dispatches"| node_admin_controller
node_admin_routes -->|"guards"| node_access_middleware
node_message_routes -->|"dispatches"| node_message_controller
node_message_routes -->|"guards"| node_access_middleware
node_auth_controller -->|"calls"| node_auth_service
node_user_controller -->|"calls"| node_user_service
node_message_controller -->|"calls"| node_message_service
node_product_controller -->|"calls"| node_product_service
node_admin_controller -->|"calls"| node_admin_service
node_auth_service -->|"uses User, Cart"| node_data_models
node_auth_service -->|"generates token"| node_jwt
node_user_service -->|"uses User"| node_data_models
node_admin_service -->|"queries models"| node_data_models
node_access_middleware -->|"loads User"| node_data_models

click node_web_routes "https://github.com/lepoly-create/codealpha_fs_01/blob/main/frontend/src/routes/AppRoutes.tsx"
click node_customer_pages "https://github.com/lepoly-create/codealpha_fs_01/tree/main/frontend/src/pages"
click node_admin_pages "https://github.com/lepoly-create/codealpha_fs_01/tree/main/frontend/src/pages/admin"
click node_auth_context "https://github.com/lepoly-create/codealpha_fs_01/blob/main/frontend/src/contexts/AuthContext.tsx"
click node_api_app "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/app.ts"
click node_auth_routes "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/auth.routes.ts"
click node_product_routes "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/product.routes.ts"
click node_cart_routes "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/cart.routes.ts"
click node_order_routes "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/order.routes.ts"
click node_user_routes "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/user.routes.ts"
click node_admin_routes "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/admin.routes.ts"
click node_message_routes "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/message.routes.ts"
click node_access_middleware "https://github.com/lepoly-create/codealpha_fs_01/tree/main/backend/src/middleware"
click node_auth_controller "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/controllers/auth.controllers.ts"
click node_user_controller "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/controllers/user.controllers.ts"
click node_message_controller "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/controllers/message.controllers.ts"
click node_auth_service "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/services/auth.services.ts"
click node_user_service "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/services/user.services.ts"
click node_message_service "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/services/message.services.ts"
click node_product_controller "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/controllers/product.controllers.ts"
click node_product_service "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/services/product.services.ts"
click node_admin_controller "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/controllers/admin.controllers.ts"
click node_admin_service "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/services/admin.services.ts"
click node_data_models "https://github.com/lepoly-create/codealpha_fs_01/tree/main/backend/src/models"
click node_jwt "https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/utils/jwt.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_web_routes,node_customer_pages,node_admin_pages,node_auth_context toneBlue
class node_api_app,node_auth_routes,node_product_routes,node_cart_routes,node_order_routes,node_user_routes,node_admin_routes,node_message_routes,node_access_middleware toneAmber
class node_product_controller,node_product_service,node_admin_controller,node_admin_service,node_data_models toneMint
class node_auth_controller,node_user_controller,node_message_controller,node_auth_service,node_user_service,node_message_service,node_jwt toneRose
class node_shopper toneIndigo
```

## Components

### Frontend experience

- [Web routes](https://github.com/lepoly-create/codealpha_fs_01/blob/main/frontend/src/routes/AppRoutes.tsx): `frontend/src/routes/AppRoutes.tsx`
- [Customer pages](https://github.com/lepoly-create/codealpha_fs_01/tree/main/frontend/src/pages): `frontend/src/pages`
- [Admin pages](https://github.com/lepoly-create/codealpha_fs_01/tree/main/frontend/src/pages/admin): `frontend/src/pages/admin`
- [Auth context](https://github.com/lepoly-create/codealpha_fs_01/blob/main/frontend/src/contexts/AuthContext.tsx): `frontend/src/contexts/AuthContext.tsx`

### API and access

- [Express API](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/app.ts): `backend/src/app.ts`
- [Auth routes](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/auth.routes.ts): `backend/src/routes/auth.routes.ts`
- [Product routes](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/product.routes.ts): `backend/src/routes/product.routes.ts`
- [Cart routes](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/cart.routes.ts): `backend/src/routes/cart.routes.ts`
- [Order routes](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/order.routes.ts): `backend/src/routes/order.routes.ts`
- [User routes](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/user.routes.ts): `backend/src/routes/user.routes.ts`
- [Admin routes](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/admin.routes.ts): `backend/src/routes/admin.routes.ts`
- [Message routes](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/routes/message.routes.ts): `backend/src/routes/message.routes.ts`
- [Access middleware](https://github.com/lepoly-create/codealpha_fs_01/tree/main/backend/src/middleware): `backend/src/middleware`

### Commerce services

- [Product controller](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/controllers/product.controllers.ts): `backend/src/controllers/product.controllers.ts`
- [Product service](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/services/product.services.ts): `backend/src/services/product.services.ts`
- [Admin controller](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/controllers/admin.controllers.ts): `backend/src/controllers/admin.controllers.ts`
- [Admin service](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/services/admin.services.ts): `backend/src/services/admin.services.ts`
- [MongoDB models](https://github.com/lepoly-create/codealpha_fs_01/tree/main/backend/src/models): `backend/src/models`

### Accounts and support

- [Auth controller](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/controllers/auth.controllers.ts): `backend/src/controllers/auth.controllers.ts`
- [User controller](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/controllers/user.controllers.ts): `backend/src/controllers/user.controllers.ts`
- [Message controller](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/controllers/message.controllers.ts): `backend/src/controllers/message.controllers.ts`
- [Auth service](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/services/auth.services.ts): `backend/src/services/auth.services.ts`
- [User service](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/services/user.services.ts): `backend/src/services/user.services.ts`
- [Message service](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/services/message.services.ts): `backend/src/services/message.services.ts`
- [JWT utility](https://github.com/lepoly-create/codealpha_fs_01/blob/main/backend/src/utils/jwt.ts): `backend/src/utils/jwt.ts`

### Other components

- **Shopper or admin**

## Connections

- Shopper or admin → Web routes: visits (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Web routes → Customer pages: routes to (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Web routes → Admin pages: routes to (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Express API → Auth routes: mounts (evidence: `backend/src/app.ts`)
- Express API → Product routes: mounts (evidence: `backend/src/app.ts`)
- Express API → Cart routes: mounts (evidence: `backend/src/app.ts`)
- Express API → Order routes: mounts (evidence: `backend/src/app.ts`)
- Express API → User routes: mounts (evidence: `backend/src/app.ts`)
- Express API → Admin routes: mounts (evidence: `backend/src/app.ts`)
- Express API → Message routes: mounts (evidence: `backend/src/app.ts`)
- Auth routes → Auth controller: dispatches (evidence: `backend/src/routes/auth.routes.ts`)
- Auth routes → Access middleware: uses (evidence: `backend/src/routes/auth.routes.ts`)
- Admin routes → Admin controller: dispatches (evidence: `backend/src/routes/admin.routes.ts`)
- Admin routes → Access middleware: guards (evidence: `backend/src/routes/admin.routes.ts`)
- Message routes → Message controller: dispatches (evidence: `backend/src/routes/message.routes.ts`)
- Message routes → Access middleware: guards (evidence: `backend/src/routes/message.routes.ts`)
- Auth controller → Auth service: calls (evidence: `backend/src/controllers/auth.controllers.ts`)
- User controller → User service: calls (evidence: `backend/src/controllers/user.controllers.ts`)
- Message controller → Message service: calls (evidence: `backend/src/controllers/message.controllers.ts`)
- Product controller → Product service: calls (evidence: `backend/src/controllers/product.controllers.ts`)
- Admin controller → Admin service: calls (evidence: `backend/src/controllers/admin.controllers.ts`)
- Auth service → MongoDB models: uses User, Cart (evidence: `backend/src/services/auth.services.ts`)
- Auth service → JWT utility: generates token (evidence: `backend/src/services/auth.services.ts`)
- User service → MongoDB models: uses User (evidence: `backend/src/services/user.services.ts`)
- Admin service → MongoDB models: queries models (evidence: `backend/src/services/admin.services.ts`)
- Access middleware → MongoDB models: loads User (evidence: `backend/src/middleware/auth.middleware.ts`)
