How ethereum/esp-website works
Project type and purpose
• This is a Next.js–based full-stack website for the Ethereum Ecosystem Support Program (ESP). It serves public marketing pages (SSG/SSR), handles a variety of grant application forms, and integrates with external systems (Salesforce API, Google Sheets, hCaptcha).
File structure
• Top-level directories:
• public – static assets (fonts, images, docs)
• src/pages – React pages + Next.js API routes under pages/api
• src/components – reusable UI and form components organized into UI, forms, layouts
• src/middlewares – server-side middleware for parsing multipart/form-data, sanitizing, captcha validation
• src/hooks, src/utils, src/theme – custom hooks, utilities, Chakra UI theme customizations
• Config files: next.config.js, netlify.toml (deployment), tsconfig.json, ESLint/Prettier
• Build script and dependencies in package.json
README for additional insights
• Confirms Next.js + TypeScript + Chakra UI + react-hook-form + Framer Motion
• Describes Salesforce integration via JSforce in API routes
• Describes Google Sheets → CSV → JSON parsing at build time for static “Latest Grantees” page
• Mentions hCaptcha testing keys, environment variable config
Main components & interactions (to show
a. Frontend (Browser + Next.js)
• Static assets (public) served by CDN/Netlify
• React pages (src/pages/*.tsx) using Chakra UI components and layouts
• Client-side form handling via react-hook-form, Framer Motion animations
b. API Layer (Serverless functions on Netlify)
• Next.js API routes in src/pages/api/*.ts
• Each route imports middlewares (multipartyParse, sanitizeFields, verifyCaptcha)
• Business logic for each form – builds formData, calls JSforce to insert/update Salesforce Lead/Objects
c. External Services
• Salesforce REST API (via JSforce) – storing form submissions
• hCaptcha – captcha verification in middleware
• Google Sheets (public CSV) – fetched at build time via getStaticProps to render static pages
• Netlify – CI/CD, hosting, function runtime
d. Build & Data-fetching
• Static generation (getStaticProps) for content pages including Latest Grantees
• Server-side rendering (SSR) for dynamic pages or incremental builds
Architectural patterns & design principles
• Layered architecture: Presentation (components & pages) → Business logic (API handlers + middlewares) → Data services (Salesforce, Google Sheets)
• Separation of concerns:
• UI vs. Layout vs. Forms vs. Data-fetching
• Middlewares handle cross-cutting concerns (parsing, sanitization, captcha)
• Next.js conventions:
• File-based routing for pages and API routes
• SSG/SSR mix for performance & SEO
Elements
• Legible labels (component name + core technology)
• Annotations for build-time vs. runtime processes