Developer Guide For developers maintaining the codebase: architecture, local setup, the content and data layer, components, integrations, the CMS configuration, and deployment. Architecture Overview Stack Concern Choice Framework Next.js 16.2 (App Router), React 19.2, TypeScript 5 (strict) Styling Tailwind CSS v4, with CSS-first @theme tokens in src/app/globals.css and no tailwind.config.js Rendering Static export ( output: "export", trailingSlash: true) → plain HTML/CSS/JS in out/ Hosting Cloudflare Pages, Git-integrated; every push to main deploys Server code One Cloudflare Pages Function: functions/api/event-inquiry.ts CMS Decap CMS 3.x at /admin, GitHub backend, commits JSON to content/ Media public/ for committed images; Cloudflare R2 ( cdn.r2.fortadams.org) for video and PDFs Tours FareHarbor Auto-Lightframe (script plus booking URLs; no API) CRM / payments HighLevel (LeadConnector API, inbound webhooks, hosted payment links and forms) Tooling ESLint 9 ( eslint-config-next), Prettier 3 with prettier-plugin-tailwindcss Next.js 16 differs from older versions. The repo's AGENTS.md warns that APIs, conventions, and file structure may differ from what you know. Read the bundled docs in node_modules/next/dist/docs/ before using an unfamiliar API, and heed deprecation notices. Request flow Browser ──GET──▶ Cloudflare Pages CDN ──▶ out/**/index.html + /_next/static/* │ ├─ POST /api/event-inquiry ──▶ Pages Function ──▶ HighLevel API │ (contacts/upsert, opportunities) ├─ POST (no-cors) ─────────────▶ HighLevel inbound webhooks │ (volunteer, corporate, newsletter) ├─ fareharbor.com/embeds/api/v1/?autolightframe=yes (booking overlay) ├─ cdn.r2.fortadams.org/video/*.mp4, /documents/*.pdf └─ links out to crm.fortadams.org (donation form, membership payment links) Key design decisions Static export, no Node server. Hosting is effectively free, fast, and has very little attack surface. Consequences: No Next.js image optimisation server. A custom loader ( src/lib/image-loader.ts) passes URLs through, or routes them via Cloudflare Image Resizing when NEXT_PUBLIC_CF_IMAGE_BASE is set. No route handlers, server actions, ISR, or middleware. Dynamic behaviour is client-side, or lives in functions/. Anything time-based is evaluated at build time. For example, getUpcomingEvents() compares against Date.now() during the build, and the footer year comes from the build. Content only "ages" when the site rebuilds. process.env.NEXT_PUBLIC_* values are inlined at build time and are public. Changing them requires a rebuild. sitemap.ts and robots.ts use export const dynamic = "force-static". Content in Git. CMS-editable data is JSON in content/, imported statically by loaders in src/lib/. Everything else is typed TypeScript data in src/lib/*.ts. There's no database. Git history is the audit log and the backup. Constrained CMS. Decap only edits a few JSON files with validated fields. Page layout and copy stay in code, so editors can't break the design. Third parties own their domains. FareHarbor owns tours, pricing, and checkout. HighLevel owns contacts, payments, and subscriptions. The site holds URLs, not product data. Integrations are isolated in a few files so a provider can be swapped locally (see HighLevel Integrations and FareHarbor Integration). One server-side secret path. The event inquiry needs a real success/failure response and a private API token, so it runs as a Pages Function. The other lead forms use fire-and-forget webhooks from the browser. Local Development Setup Prerequisites Node.js 20 or newer. The project has been run on Node 24. npm (bundled with Node) Git, with access to github.com/pmgasset/fortadamswebsite First run git clone https://github.com/pmgasset/fortadamswebsite.git cd fortadamswebsite npm install cp .env.example .env.local # fill in what you need (see below) npm run dev # http://localhost:3000 .env* files are git-ignored except .env.example. Never commit real secrets. Scripts Command Purpose npm run dev Dev server with hot reload npm run build Production static export to out/. Run this before pushing; it catches type errors and export-incompatible code. npm run start Not useful with output: "export". Serve out/ with any static server instead, for example npx serve out. npm run lint ESLint npm run format Prettier (writes), including Tailwind class sorting npm run format:check Prettier check (CI-friendly) Environment for local development Most features work with an empty .env.local: Webhook forms (volunteer, corporate, newsletter) detect placeholder or empty URLs (anything without http(s)://, or containing example.com). Instead of sending, they simulate success after 500 ms. That's safe locally, but see Known Issues and Open Items for production. Explore the Fort videos default to https://cdn.r2.fortadams.org. FareHarbor reads its URL from content/tour-booking.json, so no environment variable is needed. Testing the event inquiry function locally next dev doesn't run Cloudflare Pages Functions, so POST /api/event-inquiry returns 404 and the form shows its error state. To test end to end, build and run with Wrangler: npm run build npx wrangler pages dev out Wrangler reads the GHL_* secrets from a .dev.vars file in the project root. The existing .env* ignore rule does not cover .dev.vars, so add .dev.vars to .gitignore before creating it. Use a HighLevel test pipeline or sub-account, because this creates real contacts and opportunities. Editing CMS content locally public/admin/config.yml has local_backend: true, so you can use the CMS without GitHub auth: npm run dev # terminal 1 npx decap-server # terminal 2 (proxy on port 8081) Then open http://localhost:3000/admin/edit/ (or start from the workspace at /admin/). Changes are written straight to your working copy. Review them with git diff and commit as usual. Before you push npm run lint && npm run format:check && npm run build There's no CI in the repository (no .github/workflows). Cloudflare Pages is the only automated build, so a broken build only shows up there. Run the build locally. Repository Structure fortadamswebsite/ ├── AGENTS.md / CLAUDE.md # AI-assistant notes (Next 16 warning) ├── README.md # Project readme (partly outdated — this book is current) ├── .env.example # All env vars, documented ├── next.config.ts # output: export, trailingSlash, custom image loader ├── eslint.config.mjs # next core-web-vitals + typescript; `_`-prefixed unused vars allowed ├── .prettierrc.json # 100 cols, double quotes, trailing commas, Tailwind plugin ├── postcss.config.mjs # @tailwindcss/postcss ├── tsconfig.json # strict; alias @/* → src/* │ ├── content/ # ◀ CMS-editable JSON (Decap writes here) │ ├── alert.json # site alert banner │ ├── tour-booking.json # FareHarbor default + guided URLs │ ├── events.json # special events │ ├── event-categories.json # event filter categories │ ├── staff.json # staff members + board │ └── sponsors.json # annual corporate sponsors │ ├── functions/ │ └── api/event-inquiry.ts # ◀ Cloudflare Pages Function → HighLevel API │ ├── public/ │ ├── _redirects # Cloudflare Pages redirects (old WordPress URLs) │ ├── admin/ │ │ ├── index.html # Staff workspace (task dashboard + help) │ │ ├── workspace.css/.js # workspace styles; old-bookmark redirect │ │ ├── edit/index.html # Decap editor shell (/admin/edit/) │ │ ├── editor-loader.js # loads pinned decap-cms@3.8.4 from unpkg │ │ └── config.yml # CMS collections & fields │ └── images/ │ ├── events/ staff/ sponsors/ # CMS upload folders │ ├── venues/ visit/ home/ history/ explore/ logo/ layout/ │ └── placeholders/ # branded fallbacks (fort-fallback.svg, etc.) │ ├── docs/bookstack/ # This book (Markdown sources + ZIP builder) │ └── src/ ├── app/ # App Router routes │ ├── layout.tsx # root layout: fonts, metadata, alert, header, footer, FareHarbor script │ ├── globals.css # Tailwind import + @theme design tokens + base styles │ ├── page.tsx # / │ ├── visit/ events/ history/ host-an-event/ support-us/ about/ │ ├── architecture-and-terminology/ │ ├── sitemap.ts # /sitemap.xml │ └── robots.ts # /robots.txt ├── components/ │ ├── layout/ # Header, Footer, AlertBanner, Logo, PageHero │ ├── ui/ # Button, Card, Badge, Tag, FilterPill, Accordion, StickyTabNav, │ │ # Breadcrumb, Container, FortImage │ ├── home/ # HomeHero, QuickInfoStrip, ExploreFort, UpcomingEvents, │ │ # AudienceRouter, VenueTeaser, FortressStory │ ├── visit/ # TourCard, FareharborWidget (+ FareharborScript) │ ├── events/ # EventsExplorer, EventsCalendar, EventCard, FeaturedEventCard, │ │ # EventsSidebar, EmailSignup │ ├── history/ # HistoryExperience, RestorationTimeline │ ├── host/ # VenueCard, EventInquiryForm │ └── support/ # DonateWidget, DafPanel, MembershipTiers, LeadForm, SponsorGrid └── lib/ # Data + loaders (no React) ├── site-config.ts # org info, nav, CTAs, footer links ├── content.ts # alert + tour-booking loaders, FareHarbor URL validation ├── events.ts # events loader, sorting, grouping, date formatting ├── event-calendar.ts # calendar-grid helpers (Eastern Time) ├── staff.ts sponsors.ts ├── tours.ts faq.ts venues.ts host-content.ts support-content.ts ├── history.ts # chapters, map hotspots, restoration projects ├── fort-terminology.ts ├── explore-fort.ts # six Explore the Fort videos (build-time validated) └── image-loader.ts # next/image custom loader Git conventions main is production. Every push deploys. Decap commits directly to main, so CMS-authored commits appear in history alongside code commits. Pull before you start work to avoid conflicts in content/. .gitattributes normalises line endings to LF and marks images as binary. Routes and Pages All routes are statically exported with trailing slashes ( /visit/ → out/visit/index.html). Each page exports metadata with title, description, and alternates.canonical. The root layout applies the title template %s · Fort Adams Trust. Route File Data sources Notes / src/app/page.tsx getUpcomingEvents(6), explore-fort.ts Sections: HomeHero → QuickInfoStrip → ExploreFort ( #explore-the-fort) → UpcomingEvents → AudienceRouter → VenueTeaser → FortressStory. UpcomingEvents renders nothing when there are no events. /visit/ src/app/visit/page.tsx tours.ts, faq.ts, getTourBooking(), site-config StickyTabNav anchors: #tours, #hours, #getting-here, #faq. Hours and tour times are hard-coded in this file. The Google Maps embed uses a place cid. The Guided card uses guidedBookingUrl; other cards use bookingUrl. /events/ src/app/events/page.tsx getUpcomingEvents(), getFeaturedEvent() EventsExplorer (client) handles the list/calendar toggle and category filter. The calendar's initial month is the build month. /history/ src/app/history/page.tsx history.ts HistoryExperience (chapters ↔ map hotspots, mobile Story/Map toggle), #the-trust, #restoration-projects ( RestorationTimeline). /architecture-and-terminology/ src/app/architecture-and-terminology/page.tsx fort-terminology.ts Glossary grouped by first letter, with a #terms-X index. /host-an-event/ src/app/host-an-event/page.tsx venues.ts, host-content.ts Anchors: #venues, #whats-included, #inquire. EventInquiryForm posts to /api/event-inquiry. /support-us/ src/app/support-us/page.tsx support-content.ts, getSponsorDirectory(), env webhooks Anchors: #donate, #membership, #corporate (sponsors), #volunteer. /about/ src/app/about/page.tsx getStaff(), getBoard() Mission and vision copy and report PDF links (R2) are hard-coded here. /admin/ public/admin/index.html Staff workspace (static task dashboard and help). noindex, disallowed in robots. /admin/edit/ public/admin/edit/index.html public/admin/config.yml Decap editor, loaded by editor-loader.js. /sitemap.xml src/app/sitemap.ts route list in file Update the routes array when adding a page. /robots.txt src/app/robots.ts Disallows /admin. POST /api/event-inquiry functions/api/event-inquiry.ts Pages secrets See HighLevel Integrations. Navigation src/lib/site-config.ts defines: primaryNav: header links. They collapse to a hamburger menu below the lg breakpoint. cta.buyTickets ( /visit/#tours) and cta.donate ( /support-us/#donate): always visible. When a valid FareHarbor URL exists, the header's Buy Tickets becomes a direct FareHarbor link and opens the Lightframe. footerLinks.explore | connect | legal footerLinks.legal links to /privacy, but no src/app/privacy/page.tsx exists, so that link returns a 404. See Known Issues and Open Items. Adding a page See Common Development Tasks → Add a new page. Content and Data Layer The site has two kinds of data. Both are read at build time only. Kind Location Edited by Loaded via CMS content content/*.json Staff via Decap, or developers Static JSON imports in src/lib/* loaders Structured code content src/lib/*.ts exports Developers Direct imports CMS content files File Shape Loader Consumers content/alert.json { enabled: boolean, message: string } getSiteAlert() in content.ts, which returns enabled only if the trimmed message is non-empty AlertBanner (root layout) content/tour-booking.json { bookingUrl: string, guidedBookingUrl: string } getTourBooking(). Both are validated with isFareharborBookingUrl() (https, host fareharbor.com, path starts /embeds/book/). An invalid default becomes ""; an invalid or empty guided URL falls back to the default. Header, Visit page, root layout (loads the script only if a URL exists) content/events.json { events: StoredFortEvent[] } getPublicEvents(), getUpcomingEvents(limit?), getFeaturedEvent() Home, Events content/event-categories.json { categories: { name }[] } EVENT_CATEGORIES (trimmed, deduped, order preserved) Events filters content/staff.json { members: StaffMember[], board: BoardMember[] } getStaff(), getBoard() About content/sponsors.json { year, heading, intro, sponsors: CorporateSponsor[] } getSponsorDirectory() (drops isPublished === false) Support Us Loaders use type assertions, not runtime schema validation. Decap enforces field rules in the editor, but hand-edited JSON isn't checked. Run npm run build after editing content/ by hand. The events pipeline interface FortEvent { id: string; // optional in JSON; generated if missing title: string; description: string; startDate: string; // ISO 8601 with offset, e.g. "2026-10-03T09:30:00-04:00" endDate: string; // "" allowed → treated as startDate location: string; imageUrl: string; // "" → FortImage fallback isPublished?: boolean; // omitted = visible isFeatured: boolean; category: string; externalUrl?: string; // → "Get tickets" (new tab); takes precedence bookingUrl?: string; // site path → "Book now" } getPublicEvents() filters out isPublished === false, fills in missing IDs ( slug(startDate + "-" + title), since Decap's id field is hidden and never set for new entries), and sorts by startDate. getUpcomingEvents() keeps events whose endDate || startDate is at or after Date.now() at build time. getFeaturedEvent() returns the first upcoming event with isFeatured. Time zone handling. Display helpers ( monthKey, formatEventWhen, eventDateKey) all format in America/New_York, so labels don't depend on the build machine or the visitor's time zone. formatEventWhen shows a date range for multi-day events, and omits the time when the start is exactly midnight Eastern ("all-day"). Calendar. event-calendar.ts builds a Sunday-first month grid. Multi-day events appear on every day in their range. Structured code content ( src/lib) Module Exports Drives site-config.ts siteConfig (name, URL, org address/phone/email/EIN, social), primaryNav, cta, footerLinks Header, footer, metadata, sitemap, DAF panel, form error messages tours.ts tours: Tour[] (guided, self-guided, private-group) Visit tour cards (copy only; FareHarbor holds the real products) faq.ts visitFaqGroups: FaqGroup[] (3 groups, about 30 Q&As) Visit FAQ accordion venues.ts venues: Venue[] Host venue cards host-content.ts eventTypes, inquiryEventTypes, guestCountOptions, budgetOptions, whatsIncluded, whyFortAdams, hostTestimonials (unused placeholder) Host page and inquiry form support-content.ts membershipTiers (with HighLevel payment-link URLs), impactStats, isJoinable(), plus legacy donationPresets/ donationImpact() (unused since the hosted-form switch) Support Us history.ts historyChapters, mapHotspots, restorationProjects History page. Supports any number of chapters and hotspots; mapId links a chapter to a hotspot. fort-terminology.ts architectureFeatures, fortTerms (about 100) Architecture & Terminology explore-fort.ts exploreVideos (exactly 6), getExploreMediaUrl() Home Explore the Fort. Throws at build if not exactly six complete, unique entries with 0–100 coordinates. Placeholders Content awaiting the client is marked [PLACEHOLDER: …]. Find it all with: grep -rn "PLACEHOLDER" src content public/admin functions Component Library Components are grouped by feature under src/components/. Server components are the default. Only components that need browser state are marked "use client". UI primitives ( components/ui) Component Purpose / API Button / buttonClasses(variant, size, extra?) Renders as a link ( href) or a