{
  "meta": {
    "project": "Email Campaigner",
    "date": "2026-03-29",
    "prepared_by": "Generated by TestSprite"
  },
  "product_overview": "Email Campaigner is a web-based dashboard for creating, sending, and analyzing email campaigns, plus managing contacts, lists, and reusable templates. It supports authenticated users to build campaign content, import recipients, perform transactional sends, and view analytics.",
  "core_goals": [
    "Allow teams to create and send campaigns quickly from reusable templates",
    "Centralize contact and list management with CSV import and duplicate handling",
    "Provide basic send controls (test sends, batch sends) and visibility into delivery status",
    "Expose campaign-level analytics (sends, opens, clicks) for measurement and comparison",
    "Enforce basic unsubscribe/suppression compliance and authenticated access"
  ],
  "features": [
    {
      "name": "Authentication",
      "description": "Sign in, sign up, session handling, and route protection so only authenticated users access app areas.",
      "user_flows": [
        "Navigate to /login -> Enter email and password to sign in -> Submit credentials -> See dashboard at /",
        "Navigate to /login -> Switch to sign up mode and create an account -> Confirm account creation -> Redirect to /",
        "Start on / -> Sign out from session -> Redirect to /login",
        "Navigate to /login -> Enter invalid credentials to sign in -> Submit credentials -> See authentication error and remain on /login"
      ]
    },
    {
      "name": "Campaign Management",
      "description": "List, create, edit, open, build, and send campaigns with status tracking.",
      "user_flows": [
        "Navigate to /campaigns -> View campaign list -> Search campaigns by text -> Create a new campaign from modal form -> Open created campaign at /campaigns/:id -> Open campaign builder at /campaigns/:id/builder -> Save campaign changes -> Trigger campaign send -> See campaign status transition to sending and then sent on /campaigns/:id",
        "Navigate to /campaigns -> View campaign list -> Open campaign at /campaigns/:id -> Open campaign builder at /campaigns/:id/builder -> Edit campaign metadata and save -> See updated metadata on /campaigns/:id",
        "Navigate to /campaigns -> Create a new campaign with missing required metadata -> Submit create -> See validation error and remain on /campaigns",
        "Navigate to /campaigns -> Open campaign at /campaigns/:id -> Trigger campaign send -> Receive send failure -> See campaign status failed and error details on /campaigns/:id"
      ]
    },
    {
      "name": "Contact Management",
      "description": "Search, add, import, update, and remove contacts; view contact detail and maintain subscription status.",
      "user_flows": [
        "Navigate to /contacts -> View contact list -> Search contacts by name/email -> Add a contact through modal form -> See new contact appear in /contacts -> Open contact at /contacts/:id -> See contact detail and history",
        "Navigate to /contacts -> Import contacts from CSV -> Confirm import -> See imported contacts added to /contacts and import summary",
        "Navigate to /contacts -> Import contacts from CSV with malformed rows -> Submit import -> See import error report with failed rows and remain on /contacts until resolved",
        "Navigate to /contacts -> Add a contact through modal form with an email that already exists -> Submit create -> See duplicate/contact conflict error and remain on /contacts"
      ]
    },
    {
      "name": "Lists and Templates",
      "description": "Create and manage recipient lists and reusable email templates; launch full-screen template editor and reuse templates in campaigns.",
      "user_flows": [
        "Navigate to /lists -> View lists -> Create and update a recipient list -> See new list appear in /lists",
        "Navigate to /templates -> View template list -> Open template editor at /templates/:id/edit -> Edit template content and save -> See template updated in /templates",
        "Navigate to /campaigns -> Create a campaign -> Select existing template from template selection -> See template content applied in campaign builder at /campaigns/:id/builder",
        "Navigate to /templates -> Open template editor at /templates/:id/edit -> Introduce invalid merge fields and save -> See validation or warning message and remain in editor until fixed"
      ]
    },
    {
      "name": "Analytics and Transactional Emails",
      "description": "Filter and view campaign analytics and send one-off transactional emails with immediate history tracking.",
      "user_flows": [
        "Navigate to /analytics -> Filter/select campaign analytics -> See updated analytics charts and metrics for selection",
        "Navigate to /analytics -> Filter by criteria that matches no campaigns -> See empty state message indicating no results",
        "Navigate to /transactional -> Open send transactional email dialog -> Submit recipient, subject, and body -> See confirmation of send and record in transactional send history",
        "Navigate to /transactional -> Open send transactional email dialog -> Submit invalid recipient address -> See validation error and remain on /transactional"
      ]
    }
  ],
  "code_summary": {
    "version": "2",
    "type": "frontend",
    "tech_stack": [
      "TypeScript",
      "React",
      "React Router",
      "TanStack Query",
      "Supabase Auth",
      "Tailwind CSS"
    ],
    "routes": [
      {
        "path": "/login",
        "file": "frontend/src/pages/Login.tsx",
        "auth_required": false,
        "description": "Sign in/sign up page for user authentication."
      },
      {
        "path": "/",
        "file": "frontend/src/pages/Dashboard.tsx",
        "auth_required": true,
        "description": "Main dashboard with KPIs and recent campaigns."
      },
      {
        "path": "/campaigns",
        "file": "frontend/src/pages/Campaigns.tsx",
        "auth_required": true,
        "description": "Campaign listing, filtering, and creation entry."
      },
      {
        "path": "/campaigns/:id",
        "file": "frontend/src/pages/CampaignDetail.tsx",
        "auth_required": true,
        "description": "Campaign detail and status view."
      },
      {
        "path": "/campaigns/:id/builder",
        "file": "frontend/src/pages/CampaignBuilder.tsx",
        "auth_required": true,
        "description": "Full-screen campaign editor/builder."
      },
      {
        "path": "/contacts",
        "file": "frontend/src/pages/Contacts.tsx",
        "auth_required": true,
        "description": "Contact listing, search, import, and add actions."
      },
      {
        "path": "/contacts/:id",
        "file": "frontend/src/pages/ContactDetail.tsx",
        "auth_required": true,
        "description": "Contact profile/detail screen."
      },
      {
        "path": "/lists",
        "file": "frontend/src/pages/Lists.tsx",
        "auth_required": true,
        "description": "Audience list management page."
      },
      {
        "path": "/templates",
        "file": "frontend/src/pages/Templates.tsx",
        "auth_required": true,
        "description": "Email template listing and edit entry."
      },
      {
        "path": "/templates/:id/edit",
        "file": "frontend/src/pages/TemplateBuilder.tsx",
        "auth_required": true,
        "description": "Full-screen template editor."
      },
      {
        "path": "/analytics",
        "file": "frontend/src/pages/Analytics.tsx",
        "auth_required": true,
        "description": "Campaign analytics and reporting views."
      },
      {
        "path": "/transactional",
        "file": "frontend/src/pages/Transactional.tsx",
        "auth_required": true,
        "description": "Transactional email send/history page."
      },
      {
        "path": "/settings",
        "file": "frontend/src/pages/Settings.tsx",
        "auth_required": true,
        "description": "Application and account settings."
      }
    ],
    "features": [
      {
        "name": "Authentication",
        "description": "User sign in/sign up and route protection.",
        "files": [
          "frontend/src/pages/Login.tsx",
          "frontend/src/contexts/AuthContext.tsx",
          "frontend/src/App.tsx"
        ],
        "entry_route": "/login",
        "user_interactions": [
          "Enter email and password to sign in.",
          "Switch to sign up mode and create an account.",
          "Sign out from sidebar header."
        ],
        "api_calls": [
          {
            "method": "SUPABASE_AUTH",
            "endpoint": "supabase.auth.signInWithPassword"
          },
          {
            "method": "SUPABASE_AUTH",
            "endpoint": "supabase.auth.signUp"
          },
          {
            "method": "SUPABASE_AUTH",
            "endpoint": "supabase.auth.signOut"
          }
        ],
        "auth_required": false
      },
      {
        "name": "Campaign Management",
        "description": "Create, browse, open, and edit campaigns.",
        "files": [
          "frontend/src/pages/Campaigns.tsx",
          "frontend/src/pages/CampaignDetail.tsx",
          "frontend/src/pages/CampaignBuilder.tsx",
          "frontend/src/lib/api.ts"
        ],
        "entry_route": "/campaigns",
        "user_interactions": [
          "Open campaign list and search by text.",
          "Create a new campaign from modal form.",
          "Open campaign detail and builder pages."
        ],
        "api_calls": [
          {
            "method": "GET",
            "endpoint": "/api/campaigns"
          },
          {
            "method": "POST",
            "endpoint": "/api/campaigns"
          },
          {
            "method": "PATCH",
            "endpoint": "/api/campaigns/:id"
          },
          {
            "method": "POST",
            "endpoint": "/api/campaigns/:id/send"
          }
        ],
        "auth_required": true
      },
      {
        "name": "Contact Management",
        "description": "Manage recipients and import contacts.",
        "files": [
          "frontend/src/pages/Contacts.tsx",
          "frontend/src/pages/ContactDetail.tsx",
          "frontend/src/lib/api.ts"
        ],
        "entry_route": "/contacts",
        "user_interactions": [
          "Search contacts by name/email.",
          "Add a contact through modal form.",
          "Import contacts from CSV."
        ],
        "api_calls": [
          {
            "method": "GET",
            "endpoint": "/api/contacts"
          },
          {
            "method": "POST",
            "endpoint": "/api/contacts"
          },
          {
            "method": "POST",
            "endpoint": "/api/contacts/import"
          },
          {
            "method": "PATCH",
            "endpoint": "/api/contacts/:id"
          },
          {
            "method": "DELETE",
            "endpoint": "/api/contacts/:id"
          }
        ],
        "auth_required": true
      },
      {
        "name": "Lists and Templates",
        "description": "Organize recipients into lists and manage template assets.",
        "files": [
          "frontend/src/pages/Lists.tsx",
          "frontend/src/pages/Templates.tsx",
          "frontend/src/pages/TemplateBuilder.tsx",
          "frontend/src/lib/api.ts"
        ],
        "entry_route": "/lists",
        "user_interactions": [
          "Create and update recipient lists.",
          "Open templates and launch editor.",
          "Select templates when creating campaigns."
        ],
        "api_calls": [
          {
            "method": "GET",
            "endpoint": "/api/lists"
          },
          {
            "method": "POST",
            "endpoint": "/api/lists"
          },
          {
            "method": "GET",
            "endpoint": "/api/templates"
          },
          {
            "method": "POST",
            "endpoint": "/api/templates"
          },
          {
            "method": "PATCH",
            "endpoint": "/api/templates/:id"
          }
        ],
        "auth_required": true
      },
      {
        "name": "Analytics and Transactional Emails",
        "description": "Analyze campaign outcomes and send one-off transactional messages.",
        "files": [
          "frontend/src/pages/Analytics.tsx",
          "frontend/src/pages/Transactional.tsx",
          "frontend/src/lib/api.ts"
        ],
        "entry_route": "/analytics",
        "user_interactions": [
          "Filter/select campaign analytics.",
          "Open send transactional email dialog.",
          "Submit recipient, subject, and body."
        ],
        "api_calls": [
          {
            "method": "GET",
            "endpoint": "/api/analytics/*"
          },
          {
            "method": "GET",
            "endpoint": "/api/transactional"
          },
          {
            "method": "POST",
            "endpoint": "/api/transactional/send"
          }
        ],
        "auth_required": true
      }
    ],
    "known_limitations": []
  }
}
