How agile-growth-hackers/agile-productions works
1. Top-level shape
- This repo is a two-part application: a React frontend in frontend/ and a Cloudflare Workers backend in workers/.
- The frontend is deployed to Cloudflare Pages; the backend is deployed to the Cloudflare edge as an API.
2. Frontend boundary
- The frontend is a single SPA built with React + Vite.
- It contains both the public website and the admin dashboard in the same client app, separated by routing and protected admin routes.
- Public UI is composed from page sections like Hero, About, Services, Gallery, Clients, Navbar, and Footer.
3. Admin UI subsystem
- Admin functionality lives under frontend/src/admin/.
- It includes content editors and management panels for sliders, galleries, logos, page content, services, team members, section images, regions, users, profile, and activity logs.
- The admin area uses reusable modals, drag-and-drop cards, a rich text editor, and a region switcher to manage region-specific content.
4. Client-side data flow
- The frontend talks to the backend through a dedicated API layer in frontend/src/services/api.js.
- State is coordinated through React contexts such as AuthContext, RegionContext, and ToastContext.
- Hooks like usePageContent and useSectionImages fetch CMS-style content for the public pages, while the admin UI performs authenticated writes.
5. Backend API boundary
- The backend is organized as a set of resource routes in workers/src/routes/.
- Route groups map closely to the domain model: auth, slider, gallery, logos, storage, users, activity-logs, page-content, services, team, section-images, regions, and profile.
- This makes the API the main boundary between public content delivery and administrative content management.
6. Backend request pipeline
- Requests pass through layered middleware for CORS, CSRF, HTTPS enforcement, rate limiting, request size limits, RBAC, auth, region handling, validation, and security headers.
- This indicates a security-first edge API, with separate controls for public read endpoints and admin write endpoints.
- JWT-based authentication is used for admin sessions.
7. Persistence and storage
- Structured data is stored in Cloudflare D1 (SQLite).
- The schema is centered around content and admin entities: slider images, gallery images, logos, page content, services, team members, section images, regions, admins, users, and activity logs.
- Media files are stored in Cloudflare R2, which serves as the binary asset layer for uploaded images and profile pictures.
8. Region-aware content model
- Multi-region support is a first-class architectural concern.
- The frontend has a region switcher, and the backend has region config and region middleware.
- Content tables and API endpoints are region-scoped, so the same site can serve different content sets for domains like India and UAE without changing the app structure.
9. Media processing and content safety
- Image handling is not just upload/download; the backend includes utilities for file validation, MIME checking, WebP conversion, and optional TinyPNG compression.
- Rich text content is sanitized before rendering, and the frontend also uses DOMPurify for safe HTML output.
- This creates a clear trust boundary around user-generated content and media uploads.
10. Operational and audit layer
- Admin actions are recorded through an activity logging subsystem, which is exposed to super admins.
- There is also profile management and user management, with role-based access separating normal admins from super admins.
- This means the system tracks both content changes and administrative accountability.
11. Public runtime concerns
- The frontend includes PWA support, update/install prompts, error boundary handling, and monitoring hooks such as Sentry and web vitals.
- These pieces support a production-facing experience with offline/installability and client-side resilience.
12. CI/CD and maintenance
- GitHub Actions provide separate pipelines for frontend, backend, and database backup.
- Database migrations live under workers/migrations/, and utility scripts support seeding, local admin creation, deployment verification, and test users.
- Testing is split by layer: Playwright for frontend E2E and Vitest for backend utilities.
13. How to draw the architecture
- A good diagram would show: browser → React SPA → Cloudflare Workers API → D1/R2, with a separate admin path overlaying the same frontend and API.
- The main trust boundaries are public vs authenticated admin routes, and client UI vs edge API vs persistent storage.
Main entry points: App.jsx React SPA · middleware Middleware Stack · routes Content Routes · migrations D1 Schema
Components 22
Frontend
React + Vite SPA deployed to Cloudflare Pages
- React SPA · Single-page app bootstrap and routing
frontend/src/App.jsx - Public Site · Hero, About, Services, Gallery, Clients, Navbar, Footer
frontend/src/components - Admin Console · Protected dashboard for content and user management
frontend/src/admin - Auth Context · Session and auth state for protected routes
frontend/src/context/AuthContext.jsx - Region Context · Region selection and region-scoped content state
frontend/src/context/RegionContext.jsx - Toast Context · Shared UI notifications
frontend/src/context/ToastContext.jsx - API Client · Frontend data access layer for CMS and admin operations
frontend/src/services/api.js - Content Hooks · Fetches page content and section images for public pages
frontend/src/hooks - Admin Widgets · Modals, drag-and-drop cards, rich text editor, and region switcher
frontend/src/admin/components
Backend
Cloudflare Workers API at the edge
- Workers API · Cloudflare Workers application entry and route assembly
workers/src/index.js - Middleware Stack · CORS, CSRF, HTTPS, rate limits, RBAC, auth, region, validation, and security headers
workers/src/middleware - Auth Routes · Login, session, and JWT-based admin auth
workers/src/routes/auth.js - Content Routes · Page content, services, sliders, galleries, logos, section images, and team
workers/src/routes - Admin Routes · Users, profile, activity logs, regions, and usage/account management
workers/src/routes - Storage Routes · Upload and media asset handling
workers/src/routes/storage.js - Media Safety · File validation, MIME checks, WebP conversion, and optional TinyPNG compression
workers/src/utils - Sanitization · HTML sanitization and password validation helpers
workers/src/utils/sanitize.js
Data Layer
Persistent storage and media assets
Operations
CI, migrations, and maintenance scripts
- CI/CD · Frontend, backend, and database backup workflows
.github/workflows - Ops Scripts · Seeding, local admin creation, deployment verification, and test users
workers/scripts
Other components
- Browser · End-user entry point for the site and admin UI
Connections 26
- Browser → React SPA: loads · Browser loads the SPA bundle
- React SPA → Public Site: renders · Public pages are composed from reusable site sections
- React SPA → Admin Console: routes to · Same client app also hosts the protected admin area
- React SPA → Auth Context: uses · Auth state gates protected routes and admin actions
- React SPA → Region Context: uses · Region selection affects which content set is shown
- React SPA → Toast Context: uses · Shared notification layer across the app
- React SPA → API Client: calls · All backend interactions flow through the API layer
- Public Site → Content Hooks: fetches · Public pages hydrate CMS-style content through hooks
- Admin Console → Admin Widgets: composes · Editors and management panels reuse modals and drag-drop widgets
- API Client → Workers API: requests · Frontend sends reads and authenticated writes to Workers
- Workers API → Middleware Stack: passes through · All API traffic is filtered by layered security and request controls
- Middleware Stack → Auth Routes: protects · Auth endpoints handle login and session issuance
- Middleware Stack → Content Routes: protects · Content endpoints serve region-scoped public data and admin writes
- Middleware Stack → Admin Routes: protects · Administrative endpoints require RBAC and auth checks
- Middleware Stack → Storage Routes: protects · Upload endpoints enforce request and security policies
- Auth Routes → D1 Schema: reads/writes · Admin identity and session data live in D1
- Content Routes → D1 Schema: reads/writes · CMS content is stored in the SQLite schema
- Admin Routes → D1 Schema: reads/writes · Users, regions, profiles, and activity logs persist in D1
- Storage Routes → Media Safety: validates · Uploads are checked and transformed before persistence
- Storage Routes → R2 Bucket: stores · Binary assets are placed in R2
- Content Routes → Sanitization: sanitizes · Rich text and user content are cleaned before use
- Content Routes → Media Safety: processes · Media-related content uses validation and conversion helpers
- Admin Routes → Sanitization: sanitizes · Administrative text inputs and profile data are validated
- CI/CD → React SPA: builds/tests · Frontend pipeline covers client build and E2E checks
- CI/CD → Workers API: builds/tests · Backend pipeline covers Workers code and utility tests
- Ops Scripts → D1 Schema: initializes · Scripts seed and maintain the D1 schema and test data