# subrata-2002/fiverr-freelance architecture

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

- Interactive diagram: https://gitdiagram.com/subrata-2002/fiverr-freelance
- Repository: https://github.com/subrata-2002/fiverr-freelance

## Overview

1. This repository is a two-tier marketplace app, split into a Node/Express-style API under `api/` and a React/Vite client under `client/`. The domain is clearly a Fiverr-like freelance platform: users publish gigs, buyers place orders, messages flow through conversations, and reviews are attached to completed work.

2. The backend is organized as a classic layered API boundary: `routes` define HTTP endpoints, `controllers` hold request handling logic, `models` define the persisted domain entities, and `middleware/jwt.js` enforces authenticated access where needed. `utils/createError.js` is the shared error-construction helper used across controllers.

3. The core backend domain model is centered on `user`, `gig`, `order`, `review`, `conversation`, and `message`. That tells you the system supports marketplace discovery, transactional ordering, post-delivery feedback, and a built-in inbox/messaging subsystem rather than just a catalog of listings.

4. The backend entrypoint is `api/index.js`, which likely wires the app together: route registration, middleware, and server startup. The route files map to the main resource groups: auth, users, gigs, orders, reviews, conversations, and messages. That separation is the primary API boundary an architecture diagram should show.

5. Authentication is a first-class subsystem. `auth.route.js` and `auth.controller.js` handle login/register-type flows, while `middleware/jwt.js` suggests token-based request protection for private resources such as order management, messaging, and profile-owned gig operations.

6. The client is a single-page React app built with Vite (`client/vite.config.js`, `main.jsx`, `App.jsx`). The UI is organized by route-level pages in `src/pages` and reusable visual components in `src/components`, with SCSS co-located beside each component/page for styling. This is a presentation layer sitting fully separate from the API.

7. The client pages reflect the marketplace workflow: home/discovery (`Home`, `Gigs`, `Gig`), account access (`Login`, `Register`), seller tools (`Add`, `MyGigs`), buyer workflows (`Orders`, `Pay`, `Success`), and communication (`Messages`, `Message`). `Error` is the fallback route. This gives the frontend a clear navigation and business-process structure.

8. There is a dedicated payment step in the frontend (`Pay`, `CheckoutForm`, `Success`), which indicates checkout is a distinct flow rather than embedded inside ordering. Even without seeing the payment provider code, the architecture includes a checkout boundary between order creation and completion.

9. Client-side state and API access are intentionally separated into utilities and reducers. `utils/newRequest.js` is the HTTP client wrapper for calling the API, `utils/getCurrentUser.jsx` handles session/user lookup on the client, `utils/upload.js` suggests file/image upload support, and `reducers/gigReducer.jsx` indicates at least some marketplace state is managed centrally.

10. The visual UI is composed from reusable marketplace widgets such as `Navbar`, `Footer`, `Featured`, `TrustedBy`, category cards, gig cards, project cards, and reviews. These are presentational components that support the home/discovery experience and individual gig detail pages.

11. Hosting and routing are also part of the architecture: `client/public/_redirects` implies the SPA is deployed to a static host that needs client-side route fallback. That matters because the frontend relies on browser routing while the backend remains a separate API service.

12. From an architecture-diagram perspective, the important flows are: user authentication through the API, gig discovery and creation through the gig endpoints, order/payment flow through order and pay pages, and buyer-seller communication through conversation/message endpoints. The main system boundary is the API-backed data layer versus the React SPA, with JWT-based access control connecting them.

Main entry points: [`client/src/pages`](https://github.com/subrata-2002/fiverr-freelance/tree/main/client/src/pages) (Pages), [`api/routes`](https://github.com/subrata-2002/fiverr-freelance/tree/main/api/routes) (API routes), [`api/routes/gig.route.js`](https://github.com/subrata-2002/fiverr-freelance/blob/main/api/routes/gig.route.js) (Marketplace routes), [`api/controllers/gig.controller.js`](https://github.com/subrata-2002/fiverr-freelance/blob/main/api/controllers/gig.controller.js) (Marketplace logic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API"]
  node_api_index["Server entry<br/>express app<br/>[index.js]"]
  node_api_routes["API routes<br/>http routes"]
  node_api_controllers["Controllers<br/>request handlers"]
  node_api_models[("Models")]
  node_api_jwt{{"JWT guard<br/>auth middleware<br/>[jwt.js]"}}
  node_api_error["Error helper<br/>[createError.js]"]
  node_route_auth["Auth route<br/>auth endpoints<br/>[auth.route.js]"]
  node_route_market["Marketplace routes<br/>resource endpoints<br/>[gig.route.js]"]
  node_ctrl_auth["Auth logic<br/>auth controller<br/>[auth.controller.js]"]
  node_ctrl_market["Marketplace logic<br/>domain controllers<br/>[gig.controller.js]"]
end

subgraph group_client["Client"]
  node_client_app["SPA shell<br/>react app<br/>[App.jsx]"]
  node_client_pages["Pages"]
  node_client_ui["UI components<br/>presentational components"]
  node_client_checkout["Checkout UI<br/>payment flow<br/>[CheckoutForm.jsx]"]
  node_client_state["Client state<br/>state + api utils"]
  node_page_home["Home<br/>discovery page<br/>[Home.jsx]"]
  node_page_gig["Gig flow<br/>listing pages<br/>[Gigs.jsx]"]
  node_page_seller["Seller flow<br/>seller pages<br/>[Add.jsx]"]
  node_page_buyer["Buyer flow<br/>buyer pages<br/>[Orders.jsx]"]
  node_page_messages["Inbox flow<br/>messaging pages<br/>[Messages.jsx]"]
end

node_api_index -->|"registers"| node_api_routes
node_api_index -->|"uses"| node_api_jwt
node_api_routes -->|"includes"| node_route_auth
node_api_routes -->|"includes"| node_route_market
node_route_auth -->|"delegates"| node_ctrl_auth
node_route_market -->|"delegates"| node_ctrl_market
node_ctrl_auth -->|"reads/writes"| node_api_models
node_ctrl_market -->|"reads/writes"| node_api_models
node_ctrl_market -->|"throws"| node_api_error
node_route_market -->|"protects"| node_api_jwt
node_client_app -->|"routes to"| node_client_pages
node_client_app -->|"composes"| node_client_ui
node_client_pages -->|"includes"| node_page_home
node_client_pages -->|"includes"| node_page_gig
node_client_pages -->|"includes"| node_page_seller
node_client_pages -->|"includes"| node_page_buyer
node_client_pages -->|"includes"| node_page_messages
node_page_buyer -->|"uses"| node_client_checkout
node_client_state -->|"calls"| node_api_index
node_client_state -->|"supports"| node_client_app
node_client_ui -->|"supports"| node_page_home
node_client_ui -->|"supports"| node_page_gig

click node_api_index "https://github.com/subrata-2002/fiverr-freelance/blob/main/api/index.js"
click node_api_routes "https://github.com/subrata-2002/fiverr-freelance/tree/main/api/routes"
click node_api_controllers "https://github.com/subrata-2002/fiverr-freelance/tree/main/api/controllers"
click node_api_models "https://github.com/subrata-2002/fiverr-freelance/tree/main/api/models"
click node_api_jwt "https://github.com/subrata-2002/fiverr-freelance/blob/main/api/middleware/jwt.js"
click node_api_error "https://github.com/subrata-2002/fiverr-freelance/blob/main/api/utils/createError.js"
click node_route_auth "https://github.com/subrata-2002/fiverr-freelance/blob/main/api/routes/auth.route.js"
click node_route_market "https://github.com/subrata-2002/fiverr-freelance/blob/main/api/routes/gig.route.js"
click node_ctrl_auth "https://github.com/subrata-2002/fiverr-freelance/blob/main/api/controllers/auth.controller.js"
click node_ctrl_market "https://github.com/subrata-2002/fiverr-freelance/blob/main/api/controllers/gig.controller.js"
click node_client_app "https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/App.jsx"
click node_client_pages "https://github.com/subrata-2002/fiverr-freelance/tree/main/client/src/pages"
click node_client_ui "https://github.com/subrata-2002/fiverr-freelance/tree/main/client/src/components"
click node_client_checkout "https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/components/checkoutForm/CheckoutForm.jsx"
click node_client_state "https://github.com/subrata-2002/fiverr-freelance/tree/main/client/src/utils"
click node_page_home "https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/pages/home/Home.jsx"
click node_page_gig "https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/pages/gigs/Gigs.jsx"
click node_page_seller "https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/pages/add/Add.jsx"
click node_page_buyer "https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/pages/orders/Orders.jsx"
click node_page_messages "https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/pages/messages/Messages.jsx"

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_api_index,node_api_routes,node_api_controllers,node_api_models,node_api_jwt,node_api_error,node_route_auth,node_route_market,node_ctrl_auth,node_ctrl_market toneBlue
class node_client_app,node_client_pages,node_client_ui,node_client_checkout,node_client_state,node_page_home,node_page_gig,node_page_seller,node_page_buyer,node_page_messages toneAmber
```

## Components

### API

Node/Express backend with routes, controllers, models, and shared middleware.

- [Server entry](https://github.com/subrata-2002/fiverr-freelance/blob/main/api/index.js): express app · Bootstraps the API server, registers middleware and routes, and starts the backend. · `api/index.js`
- [API routes](https://github.com/subrata-2002/fiverr-freelance/tree/main/api/routes): http routes · Resource-level HTTP boundaries for auth, users, gigs, orders, reviews, conversations, and messages. · `api/routes`
- [Controllers](https://github.com/subrata-2002/fiverr-freelance/tree/main/api/controllers): request handlers · Business logic layer for API requests and responses. · `api/controllers`
- [Models](https://github.com/subrata-2002/fiverr-freelance/tree/main/api/models): domain models · Persisted marketplace entities for users, gigs, orders, reviews, conversations, and messages. · `api/models`
- [JWT guard](https://github.com/subrata-2002/fiverr-freelance/blob/main/api/middleware/jwt.js): auth middleware · Protects private API endpoints with token-based access control. · `api/middleware/jwt.js`
- [Error helper](https://github.com/subrata-2002/fiverr-freelance/blob/main/api/utils/createError.js): utility · Shared helper for constructing API errors in controllers. · `api/utils/createError.js`
- [Auth route](https://github.com/subrata-2002/fiverr-freelance/blob/main/api/routes/auth.route.js): auth endpoints · Login and registration entrypoints. · `api/routes/auth.route.js`
- [Marketplace routes](https://github.com/subrata-2002/fiverr-freelance/blob/main/api/routes/gig.route.js): resource endpoints · Routes for users, gigs, orders, reviews, conversations, and messages. · `api/routes/gig.route.js`
- [Auth logic](https://github.com/subrata-2002/fiverr-freelance/blob/main/api/controllers/auth.controller.js): auth controller · Handles account creation and sign-in flows. · `api/controllers/auth.controller.js`
- [Marketplace logic](https://github.com/subrata-2002/fiverr-freelance/blob/main/api/controllers/gig.controller.js): domain controllers · Coordinates gig discovery, ordering, reviews, user profiles, conversations, and messages. · `api/controllers/gig.controller.js`

### Client

React/Vite single-page app with pages, components, and client utilities.

- [SPA shell](https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/App.jsx): react app · Vite-powered React application root and client-side router shell. · `client/src/App.jsx`
- [Pages](https://github.com/subrata-2002/fiverr-freelance/tree/main/client/src/pages): route pages · Route-level screens for discovery, account access, seller tools, checkout, orders, and messaging. · `client/src/pages`
- [UI components](https://github.com/subrata-2002/fiverr-freelance/tree/main/client/src/components): presentational components · Reusable marketplace widgets for navigation, discovery, gig cards, reviews, and footers. · `client/src/components`
- [Checkout UI](https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/components/checkoutForm/CheckoutForm.jsx): payment flow · Dedicated checkout component used by the payment flow. · `client/src/components/checkoutForm/CheckoutForm.jsx`
- [Client state](https://github.com/subrata-2002/fiverr-freelance/tree/main/client/src/utils): state + api utils · Centralized client-side request helpers, session lookup, uploads, and gig state. · `client/src/utils`
- [Home](https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/pages/home/Home.jsx): discovery page · Landing and marketplace discovery experience. · `client/src/pages/home/Home.jsx`
- [Gig flow](https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/pages/gigs/Gigs.jsx): listing pages · Gig browsing and detail views. · `client/src/pages/gigs/Gigs.jsx`
- [Seller flow](https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/pages/add/Add.jsx): seller pages · Gig creation and seller inventory management. · `client/src/pages/add/Add.jsx`
- [Buyer flow](https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/pages/orders/Orders.jsx): buyer pages · Orders, payment, and success screens for completed purchases. · `client/src/pages/orders/Orders.jsx`
- [Inbox flow](https://github.com/subrata-2002/fiverr-freelance/blob/main/client/src/pages/messages/Messages.jsx): messaging pages · Conversation list and individual message threads. · `client/src/pages/messages/Messages.jsx`

## Connections

- Server entry → API routes: registers · The server entry mounts the route layer.
- Server entry → JWT guard: uses · Private endpoints rely on JWT protection.
- API routes → Auth route: includes · Auth endpoints are one route group.
- API routes → Marketplace routes: includes · Marketplace endpoints are grouped as resources.
- Auth route → Auth logic: delegates · Auth routing hands requests to auth controllers.
- Marketplace routes → Marketplace logic: delegates · Resource routing hands requests to marketplace controllers.
- Auth logic → Models: reads/writes · Auth logic operates on user records.
- Marketplace logic → Models: reads/writes · Marketplace controllers operate on all core domain entities.
- Marketplace logic → Error helper: throws · Shared error helper standardizes controller failures.
- Marketplace routes → JWT guard: protects · Authenticated resources are guarded by JWT middleware.
- SPA shell → Pages: routes to · The app shell renders route-level screens.
- SPA shell → UI components: composes · Pages are built from shared UI components.
- Pages → Home: includes · Home and discovery entrypoint.
- Pages → Gig flow: includes · Browsing and gig detail screens.
- Pages → Seller flow: includes · Seller creation and management screens.
- Pages → Buyer flow: includes · Order, pay, and success screens.
- Pages → Inbox flow: includes · Inbox and thread screens.
- Buyer flow → Checkout UI: uses · Checkout form powers the payment step.
- Client state → Server entry: calls · Client request helpers talk to the backend API.
- Client state → SPA shell: supports · Session, upload, and state utilities support the app shell and pages.
- UI components → Home: supports · Reusable widgets support discovery pages.
- UI components → Gig flow: supports · Cards and reviews support gig detail and listing views.
