How greengeneers/emeraldchip works
Project Type and Purpose
• This is a full-stack web application with a React frontend and an Express/Node backend, persisting data in a PostgreSQL database via Knex.
• From the README: user auth, dashboards, events, donations, and RSVPs are core features.
File Structure
• Top-level:
• frontend/ – React SPA (Vite-powered)
• server/ – Express API server
• frontend/src structure follows a component- and adapter-driven pattern:
• adapters – encapsulate all HTTP calls to backend endpoints
• contexts – global state (current user)
• components/pages – UI building blocks and routes
• server/ structure follows MVC-like organization:
• controllers – HTTP request handlers
• models – ORM wrappers (Knex Query Builders)
• db/ – Knex configuration, migrations, seeds
• middleware – sessions, auth checks, logging
• Config & build scripts:
• vite.config.js, package.json (frontend)
• knexfile.js, .env.template (server)
README for Additional Insights
• Stack: Node, Express, PostgreSQL, React, Knex.
• Auth uses cookie-based sessions encrypted with SESSION_SECRET.
• Build flow: frontend build → server migrations/seeds → start server.
a. Main Components
• Client (Browser/React SPA)
• API Server (Express)
• Database (PostgreSQL via Knex)
• External/Dev Tools (Vite, Knex migrations, seeds)
b. Relationships & Data Flows
1. User interacts with React UI (components/pages).
2. Components call adapters → fetch/POST JSON to Express endpoints.
3. Express routes → middleware (session, auth) → controllers.
4. Controllers invoke models (Knex) → SQL queries to Postgres.
5. Responses bubble back: DB → model → controller → adapter → UI.
c. Architectural Patterns
• Layered Architecture (Presentation → API → Data)
• Adapter pattern in frontend to decouple UI from HTTP details
• MVC-style on server (controllers + models)
• Cookie-based session management middleware
d. Key Technologies & Frameworks
• React + Vite (frontend build/server)
• Express + cookie-session (server)
• Knex + PostgreSQL (database)
• ESLint / Airbnb style guide