Skip to main content

Overview

CAFH Platform is built with modern web technologies focused on developer experience, type safety, and performance.

Frontend Stack

React 19.2.3

UI library with latest features including hooks, suspense, and concurrent rendering

TypeScript 5.8.2

Type-safe JavaScript with full IDE support

React Router 7.10.1

Hash-based routing for SPA navigation

Tailwind CSS

Utility-first CSS framework (configured inline)

React 19 Features Used

App.tsx
import React, { useEffect } from 'react';
import { HashRouter, Routes, Route } from 'react-router-dom';

// React 19 automatic batching, concurrent features
const App: React.FC = () => {
  useEffect(() => {
    db.init();  // Initialize storage on mount
  }, []);

  return (
    <HashRouter>
      <Routes>
        {/* Routes */}
      </Routes>
    </HashRouter>
  );
};

TypeScript Configuration

From tsconfig.json:
tsconfig.json
{
  "compilerOptions": {
    "target": "ES2022",
    "module": "ESNext",
    "lib": ["ES2022", "DOM", "DOM.Iterable"],
    "jsx": "react-jsx",
    "moduleResolution": "bundler",
    "types": ["node"],
    "paths": {
      "@/*": ["./*"]
    }
  }
}

Backend Stack

Express 5.2.1

Web server framework for API endpoints

Nodemailer 8.0.1

Email sending with SMTP support

CORS 2.8.6

Cross-origin resource sharing

dotenv 17.3.1

Environment variable management

Server Implementation

server.ts
import express from "express";
import { createServer as createViteServer } from "vite";
import nodemailer from "nodemailer";
import cors from "cors";
import dotenv from "dotenv";

dotenv.config();

const app = express();
const PORT = 3000;

app.use(cors());
app.use(express.json());

// API Routes
app.get("/api/health", (req, res) => {
  res.json({ status: "ok", time: new Date().toISOString() });
});

app.post("/api/email/queue", (req, res) => {
  // Email queueing logic
});

// Vite middleware for dev server
if (process.env.NODE_ENV !== "production") {
  const vite = await createViteServer({
    server: { middlewareMode: true },
    appType: "spa",
  });
  app.use(vite.middlewares);
}

Build Tools

Vite 6.2.0

Lightning-fast build tool and dev server

tsx 4.21.0

TypeScript execution for server

@vitejs/plugin-react 5.0.0

Vite plugin for React Fast Refresh

Vite Configuration

From vite.config.ts:
vite.config.ts
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';

export default defineConfig({
  server: {
    port: 3000,
    host: '0.0.0.0',
  },
  plugins: [react()],
  resolve: {
    alias: {
      '@': path.resolve(__dirname, '.'),
    }
  }
});

UI Components & Libraries

Lucide React 0.561.0

600+ SVG icons

Recharts 3.6.0

Analytics charts and graphs

@xyflow/react 12.10.1

Visual automation flow builder

React Markdown 10.1.0

Markdown rendering

Icon Usage

import { Users, Mail, Calendar, Settings } from 'lucide-react';

<Users className="w-5 h-5 text-blue-600" />
<Mail className="w-4 h-4" />

Charts Example

import { LineChart, Line, XAxis, YAxis } from 'recharts';

<LineChart width={600} height={300} data={emailMetrics}>
  <XAxis dataKey="date" />
  <YAxis />
  <Line type="monotone" dataKey="sent" stroke="#8884d8" />
</LineChart>

Automation Flow Builder

components/AutomationFlowBuilder.tsx
import { ReactFlow, Node, Edge } from '@xyflow/react';

<ReactFlow
  nodes={flowNodes}
  edges={flowEdges}
  onNodesChange={onNodesChange}
  onEdgesChange={onEdgesChange}
/>

Data Storage

localStorage

Browser-based data persistence with versioned keys and JSON serialization
Implemented in storage.ts:
storage.ts
const KEYS = {
  BLOG: 'cafh_blog_v1',
  CONTACTS: 'cafh_contacts_v1',
  EVENTS: 'cafh_events_v1',
  // ... 30+ storage keys
};

const initStorage = <T>(key: string, initialData: T): T => {
  try {
    const stored = localStorage.getItem(key);
    if (!stored) {
      localStorage.setItem(key, JSON.stringify(initialData));
      return initialData;
    }
    return JSON.parse(stored);
  } catch (e) {
    console.error(`Error accessing storage for ${key}`, e);
    return initialData;
  }
};

Type System

All data structures are defined in types.ts with 50+ TypeScript interfaces:
types.ts
export interface User {
  id: string;
  name: string;
  email: string;
  role: UserRole;
  avatarUrl: string;
  tenantId: string;
  interests: string[];
  joinedDate: string;
}

export enum UserRole {
  SUPER_ADMIN = 'SUPER_ADMIN',
  ADMIN = 'ADMIN',
  EDITOR = 'EDITOR',
  MEMBER = 'MEMBER',
  GUEST = 'GUEST'
}

export interface Contact {
  id: string;
  name: string;
  email: string;
  phone: string;
  status: 'Subscribed' | 'Unsubscribed' | 'Bounced';
  tags: string[];
  engagementScore?: number;
}

Dependencies Overview

From package.json:

Core Dependencies

PackageVersionPurpose
react19.2.3UI framework
react-dom19.2.3React renderer
typescript5.8.2Type system
express5.2.1Backend server
vite6.2.0Build tool

UI & Components

PackageVersionPurpose
lucide-react0.561.0Icons
recharts3.6.0Charts
@xyflow/react12.10.1Flow diagrams
react-markdown10.1.0Markdown rendering
react-router-dom7.10.1Routing

Backend & Email

PackageVersionPurpose
nodemailer8.0.1Email sending
cors2.8.6CORS middleware
dotenv17.3.1Environment config
tsx4.21.0TS execution

Why These Choices?

Latest stable version with automatic batching, concurrent rendering, and improved hooks. Excellent TypeScript support.
Catches bugs at compile time, provides IntelliSense, and improves maintainability. Essential for large codebases.
Instant HMR, faster builds than Webpack, native ES modules, and excellent DX. Perfect for React development.
Simple, requires no backend database, works offline, and perfect for MVP. Can be replaced with PostgreSQL/MongoDB later.
Minimal, flexible, well-documented. Handles API routes and email queue efficiently.
Works on any static host without server-side routing configuration. Easy deployment to GitHub Pages, Netlify, etc.

Browser Support

Targeting modern browsers:
  • Chrome 90+
  • Firefox 88+
  • Safari 14+
  • Edge 90+
IE11 is not supported due to ES2022 features and modern React.

Next Steps

Folder Structure

Explore the project organization

Storage System

Understand data persistence

Build Process

Learn about production builds

Architecture

Platform architecture overview

Build docs developers (and LLMs) love