A comprehensive full-stack DeFi application for monitoring and interacting with ERC4626 vaults. Built with modern technologies and best practices for educational and demo purposes.
This monorepo contains two main applications:
/indexer- Node.js/TypeScript indexing service with GraphQL API/web- Next.js React frontend with wallet integration
- Node.js + TypeScript - Runtime and language
- PostgreSQL + Prisma - Database and ORM
- Apollo GraphQL - API layer with caching
- viem - Ethereum client for blockchain interactions
- Docker - Containerization and deployment
- Next.js 14 - React framework with App Router
- TypeScript - Type safety
- Tailwind CSS - Styling
- wagmi + viem - Ethereum wallet integration
- RainbowKit - Wallet connection UI
- React Query - Data fetching and caching
- GraphQL - API communication
- Node.js 18+
- PostgreSQL 14+
- Docker (optional)
git clone <repository-url>
cd vault-fullstack
# Install dependencies for both apps
cd indexer && npm install
cd ../web && npm installCreate /indexer/.env:
# Database
DATABASE_URL="postgresql://username:password@localhost:5432/vault_indexer"
# Blockchain
RPC_URL="https://eth-mainnet.g.alchemy.com/v2/your-api-key"
VAULT_ADDRESS="0x..." # Your ERC4626 vault address
START_BLOCK=18000000 # Starting block number
# GraphQL
GRAPHQL_PORT=4000Create /web/.env:
# API
NEXT_PUBLIC_GRAPHQL_URL="http://localhost:4000/graphql"
NEXT_PUBLIC_VAULT_ADDRESS="0x..." # Same as indexer
# Wallet Connect
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID="your-project-id"cd indexer
npm run db:generate # Generate Prisma client
npm run db:push # Create tablescd indexer
npm run devcd web
npm run devVisit:
- Frontend: http://localhost:3000
- GraphQL Playground: http://localhost:4000/graphql
vault-fullstack/
├── indexer/ # Backend indexing service
│ ├── src/
│ │ ├── abis/ # Contract ABIs
│ │ ├── services/ # Indexing logic
│ │ ├── graphql/ # GraphQL schema & resolvers
│ │ └── index.ts # Entry point
│ ├── prisma/ # Database schema
│ ├── docker-compose.yml # Local PostgreSQL
│ └── package.json
│
├── web/ # Frontend Next.js app
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── lib/ # Utilities & ABIs
│ │ ├── contexts/ # React contexts
│ │ └── config/ # wagmi configuration
│ ├── app/ # Next.js App Router
│ └── package.json
│
└── README.md # This file
- Real-time Event Indexing: Processes vault deposits, withdrawals, and harvests
- Historical Data: Batch processes past events from specified block
- Vault Snapshots: Creates time-series data for analytics
- User Positions: Tracks individual user interactions
- GraphQL API: Provides efficient data access with caching
- Database Persistence: Stores all indexed data in PostgreSQL
- Wallet Integration: Connect with MetaMask, WalletConnect, etc.
- Live Blockchain Data: Real-time TVL and share prices
- Vault Actions: Deposit and withdraw directly from the UI
- User Dashboard: View personal positions and P&L
- Analytics Charts: Historical performance visualization
- Responsive Design: Works on desktop and mobile
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request