Full Stack Overview
Polaris Pay is built with a modular architecture that integrates blockchain privacy, efficient data management, and user-friendly frontends.
graph TD
User([User]) <--> Frontend[Next.js 15 Frontend]
Frontend <--> APILayer[Next.js API Routes]
APILayer <--> MongoDB[(MongoDB Atlas)]
APILayer <--> Blockchain[Blockchain Layer]
Blockchain <--> FHEVM[FHEVM Privacy Layer]
Blockchain <--> SmartContracts[Lending & AMM Contracts]
Components
- Frontend Layer: Next.js 15 (React 19) applications for shoppers, merchants, and the core protocol.
- API Layer: Serverless functions handling data orchestration and proof verification.
- Database Layer: MongoDB Atlas for tracking user positions, protocol stats, and merchant configurations.
- Blockchain Layer: Ethereum-compatible network (Sepolia/Local) hosting the core protocol.
- Privacy Layer: Zama's FHEVM for encrypted lending and borrowing operations.
Data Flow
AMM Swap Flow
- Frontend: User enters amount, calls
getAmountOut(). - Blockchain: User approves tokens and executes
swap(). - UI: Updates with new balances after transaction confirmation.
Lending Pool Flow
- Frontend: User deposits collateral.
- Smart Contract: Transfers assets and mints LP tokens.
- API Route: Updates MongoDB with the new user position.