How prasad-abhay/earth works
Project Type and Purpose
• It’s a full-stack web application:
– Frontend: React SPA built with Vite, Tailwind CSS, custom UI library under client/components/ui.
– Backend: Node.js/TypeScript server in server/ plus serverless functions in netlify/functions.
– Shared code: API type definitions and utilities under shared/api.ts.
– Deployment: Netlify (netlify.toml), plus local dev via server/index.ts.
File Structure for Architectural Boundaries
• Top-level directories:
– client/ → React application
– server/ → Express-style or custom HTTP server
– netlify/functions/ → serverless endpoints (edge functions)
– shared/ → DTOs, API clients, shared types
– public/ → static assets
• Config and build scripts:
– Vite configs (vite.config.ts, vite.config.server.ts)
– Tailwind (tailwind.config.ts), PostCSS (postcss.config.js)
– TypeScript (tsconfig.json)
– Netlify config (netlify.toml)
Main Components
• Frontend SPA
– UI components (client/components)
– Pages & routes (client/pages)
– Contexts & hooks (AuthContext, ThemeContext, custom hooks)
– Shared API client (shared/api.ts)
• Backend API
– Netlify Functions (API entrypoints in netlify/functions/api.ts)
– Express server (server/index.ts) and routes (server/routes/*.ts)
– Business logic and controllers (demonstrated in server/routes/demo.ts)
• Database
– MongoDB (hinted by mongodb.txt)
• Deployment Infrastructure
– Netlify CDN & edge functions
– Optional local Node server for development
• External Services
– Authentication provider (if any), third-party APIs, analytics, etc. (not explicitly shown)
Relationships and Data Flow
• The React SPA issues HTTP requests (REST or RPC) via shared/api.ts →
Netlify serverless functions OR local Node server →
Business logic →
Database (MongoDB).
• Responses flow back to the SPA, updating UI state via contexts/hooks.
• Static assets (images, robots.txt) served from public/ or Netlify CDN.
Architectural Patterns and Principles
• Separation of Concerns:
– UI layer (React) vs. API layer (server/functions) vs. Data layer (MongoDB).
• Shared contract:
– shared/api.ts enforces type safety across client and server.
• Component-based UI:
– Reusable UI primitives under client/components/ui.
• Serverless + Traditional Node mix:
Final Checklist
– [ ] All components (frontend, backend, DB, infra) present
– [ ] Data flows and dependencies clearly marked
– [ ] Tech stack labels on each component
– [ ] Optional notes on build & deployment (Vite build → Netlify/CND)