How m1amineratit/acot works
Project Type and Purpose
• ColdSendr is a full-stack, single-page web application (SPA) whose goal is to let users generate and manage AI-powered cold emails.
• The frontend is a React (TS) + Tailwind CSS app, and the “backend” is fully managed via Supabase (Auth, Database, Edge Functions/migrations). External AI calls go to OpenRouter’s Claude 3.5 Sonnet API.
File Structure
• Top-level: config files (.env, tsconfig, tailwind, vite, eslint), README, index.html.
• supabase/: database migrations defining tables (email_history, user_usage) and RLS policies.
• src/: contains the SPA code:
• components/ – UI building blocks, split into auth, features, layout, ui.
• pages/ – route targets (LandingPage, LoginPage, SignupPage, DashboardPage).
• contexts/ – AuthContext for session management.
• lib/ – Supabase client initialization.
• services/ – business logic wrappers (e.g., emailHistory CRUD).
• utils/ – generic helpers (API wrappers to OpenRouter, clipboard utilities).
README for Architectural Clues
• Tech stack confirms BaaS (Supabase) + client-heavy React SPA.
• Authentication flows (email/password & Google OAuth) go through Supabase Auth.
• AI generation uses an external OpenRouter endpoint.
• Database schema is managed via Supabase migrations.
Relationships & Data Flows
1. Browser → Hosting/CDN: fetch static assets (index.html, JS/CSS).
2. React SPA → Supabase Auth (via lib/supabase.ts): sign-up, sign-in, session token exchange.
3. React (AuthContext) holds user session; ProtectedRoute gates dashboard.
4. On “Generate Email”: React calls utils/api → OpenRouter API → returns AI content.
5. On “Save Email” or “Fetch History”: React calls services/emailHistory → Supabase Postgres.
6. Google OAuth flow: Browser → Google → callback to Supabase Auth → session back to SPA.
Architectural Patterns & Principles
• BaaS (Backend-as-a-Service) with Supabase handling auth, database, migrations, RLS.
• SPA component hierarchy with clear separation: UI (components), state (contexts), data layer (services), and external API wrappers (utils).
• Context API for global state; services for data access; migrations for schema evolution.