How swapanrishi/de-centrilized_market_place works
1. Overall shape
BlockMart is a hybrid dApp marketplace: user-facing commerce flows are split between an off-chain web/app layer for metadata and UX, and an on-chain settlement layer for escrow and asset transfer. The main architectural boundary is between fast relational data handling and trustless blockchain execution.
2. Frontend subsystem
The frontend/ package is a React + TypeScript single-page app built with Vite and styled with Tailwind CSS. It is the primary user interface for browsing, listing, and trading assets, and it likely uses Ethers.js / wallet connectors to connect the browser to a crypto wallet for blockchain actions.
3. Backend subsystem
The backend/ package is a Node.js backend (compiled to backend/dist/index.js) that acts as the off-chain service boundary. From the repo layout and README, this layer is responsible for serving marketplace metadata, coordinating application state, and persisting data in the relational database through Prisma.
4. Database / persistence layer
The persistent off-chain store is PostgreSQL, accessed via Prisma ORM. The repo contains Prisma schemas and migrations under both backend/prisma/ and a root-level prisma/, which suggests either:
- a shared schema reused across parts of the repo, or
- an earlier/alternate schema location from the project’s evolution.
For architecture diagrams, treat the database as the off-chain source of truth for product listings, user metadata, reviews, and other non-transactional content.
5. Blockchain subsystem
The blockchain/ package is a separate Hardhat-based Solidity workspace. It contains contracts, tests, deployment/ignition modules, and utility scripts. This is the on-chain execution boundary where escrow, payment settlement, and trust-sensitive logic live.
6. On-chain/off-chain split
The key data-flow distinction is:
- Off-chain: product images, descriptions, user profiles, reviews, search-friendly marketplace metadata
- On-chain: payment transfer, escrow release, and asset settlement
The README explicitly positions the design as a gas-efficient hybrid model, with blockchain used only where trustlessness matters.
7. Transaction lifecycle
A typical marketplace flow is:
1. User browses listings in the frontend.
2. Listing metadata comes from the backend/database.
3. User connects a wallet and initiates a blockchain transaction.
4. Smart contract holds funds in escrow.
5. The buyer confirms receipt.
6. The contract releases funds / finalizes settlement.
This is the core cross-boundary flow the diagram should emphasize.
8. Smart contract tooling
The blockchain package includes:
- hardhat.config.ts for local/testnet chain setup
- test/BlockMartEscrow.test.ts for contract-level verification
- ignition/modules/ for deployment orchestration
- scripts/send-op-tx.ts for manual transaction execution
These files indicate the on-chain side is treated as a standalone deployable system with its own CI/test boundary.
9. Authentication / legacy entry points
The repo also includes php/login.php, php/register.php, login-pg.html, and RegisterSign.html. These look like an alternate or legacy auth path separate from the React frontend and Node backend. If you draw the architecture, place these as a parallel web entry path rather than part of the main React/Node flow unless the code confirms otherwise.
10. Containerization and runtime environment
The backend has Docker files, indicating it can be packaged independently with its runtime dependencies. The README also calls out Docker for local backend/database environment. That makes the deployment boundary likely:
- frontend served separately,
- backend in a container,
- PostgreSQL as a local or managed service,
- blockchain contracts deployed to Sepolia for testnet usage.
11. External dependencies / services
The main external service is the Ethereum Sepolia testnet, which is the on-chain runtime target. Wallets such as MetaMask or WalletConnect are also part of the runtime boundary, because they authorize and sign user transactions from the browser.
12. Repo-level organization
The repository is effectively a multi-package monorepo:
- frontend/ for UI
- backend/ for API and database access
- blockchain/ for contracts and deployment
- php/ plus standalone HTML files for alternate auth pages
- root-level Prisma assets and package files, suggesting shared or historical infrastructure
This separation is important for the diagram because it shows three primary runtime domains: browser, server/database, and blockchain.
13. What to emphasize in the diagram
The most important architecture boundaries are:
- Browser ↔ Backend for marketplace metadata and app state
- Browser ↔ Wallet ↔ Blockchain for signing and escrow transactions
- Backend ↔ PostgreSQL/Prisma for persistent off-chain data
- Contracts ↔ Sepolia for settlement execution
If you only highlight one thing, highlight the hybrid split between off-chain commerce data and on-chain settlement logic.
Main entry points: index.ts API Server · App.tsx Marketplace UI · schema.prisma DB Schema · hardhat.config.ts Hardhat Config
Components 18
Browser App
React/Vite SPA for marketplace browsing, listing, and wallet-driven transactions.
- Marketplace UI · Main user interface for browsing listings, trading assets, and initiating wallet actions.
frontend/src/App.tsx - App Entry · Client bootstrap and app mounting for the SPA.
frontend/src/main.tsx - UI Styling · Presentation layer and global styling for the browser app.
frontend/src/index.css
Off-chain Service
Node backend and Prisma-backed persistence for marketplace metadata and app state.
- API Server · Backend process that serves the off-chain service boundary and application state.
backend/src/index.ts - Built Server · Packaged backend runtime entry used for deployment.
backend/dist/index.js - DB Schema · Primary backend data model for marketplace metadata and persistence.
backend/prisma/schema.prisma - Shared Schema · Root-level Prisma schema, likely shared or legacy database definition.
prisma/schema.prisma - Migrations · Database evolution history for the relational store.
backend/prisma/migrations/20260425124057_init/migration.sql
On-chain System
Hardhat Solidity workspace for escrow, deployment, and settlement logic.
- Hardhat Config · Chain and tooling configuration for the Solidity workspace.
blockchain/hardhat.config.ts - Escrow Tests · Contract-level verification for marketplace settlement behavior.
blockchain/test/BlockMartEscrow.test.ts - Deploy Module · Deployment orchestration for on-chain contracts.
blockchain/ignition/modules/Counter.ts - Tx Script · Manual transaction helper for sending on-chain operations.
blockchain/scripts/send-op-tx.ts
Legacy Web
Alternate PHP/HTML entry points separate from the main React + Node flow.
- Legacy Login · Alternate login page outside the main SPA flow.
php/login.php - Legacy Register · Alternate registration page outside the main SPA flow.
php/register.php - Auth Page · Standalone HTML login/register entry point.
login-pg.html - Auth Page · Standalone HTML sign-up entry point.
RegisterSign.html
Other components
- Wallet · External wallet connector used to sign marketplace transactions.
- Sepolia · External blockchain runtime where settlement and escrow execute.
Connections 19
- App Entry → Marketplace UI: mounts · Bootstraps the React marketplace UI.
- Marketplace UI → UI Styling: styles · Uses shared Tailwind/global styling.
- Marketplace UI → API Server: fetches metadata · Browser UI loads listings and marketplace state from the backend.
- Marketplace UI → Wallet: signs tx · Connects to a browser wallet for user authorization.
- Wallet → Sepolia: submits tx · Wallet relays signed transactions to the blockchain network.
- API Server → DB Schema: reads/writes · Backend persists off-chain marketplace data through Prisma.
- API Server → Shared Schema: uses model · Backend may rely on the root Prisma schema as a shared or legacy definition.
- DB Schema → Migrations: evolves via · Schema changes are applied through migrations.
- Built Server → API Server: deploys · Built artifact packages the server for runtime deployment.
- API Server → Marketplace UI: serves data · Provides marketplace metadata and application state to the UI.
- Hardhat Config → Deploy Module: orchestrates · Hardhat configuration drives deployment modules.
- Deploy Module → Sepolia: deploys to · Deploys smart contracts onto the target network.
- Escrow Tests → Hardhat Config: verifies · Tests run against the configured Hardhat environment.
- Tx Script → Sepolia: executes on · Manual script sends transactions to the testnet.
- Marketplace UI → Sepolia: initiates escrow · User-facing commerce flow triggers on-chain settlement actions.
- Auth Page → Legacy Login: links to · Standalone HTML entry can route into the PHP auth flow.
- Auth Page → Legacy Register: links to · Standalone HTML entry can route into the PHP auth flow.
- Legacy Login → API Server: parallel auth path · Separate web entry path that may overlap with the main service boundary.
- Legacy Register → API Server: parallel auth path · Separate web entry path that may overlap with the main service boundary.