# vikasingh0897/auditai architecture

> Architecture diagram of the GitHub repository vikasingh0897/auditai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-05-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vikasingh0897/auditai
- Repository: https://github.com/vikasingh0897/auditai

## Overview

1. **This is a split frontend/backend SaaS product.**  
   The repo contains a Vite + React TypeScript client in `frontend/` and a Node.js + Express TypeScript API in `backend/`. The architecture is centered on a user-submitted SaaS audit flow that turns a tool list and spend estimate into an AI-generated summary and then into lead capture.

2. **Primary user journey is linear and conversion-focused.**  
   Users enter through `LandingPage`, submit data in `AuditForm`, pass CAPTCHA, receive results in `AuditSummary` / `ResultsDashboard`, and may be shown `LeadModal` for follow-up. The front end is organized as a small set of page-level components with shared `Header` and `Footer`, not a large routed application.

3. **Frontend boundary: presentation and API consumption only.**  
   `frontend/src/App.tsx` and `main.tsx` bootstrap the app, while pages under `src/pages/` hold the main interaction states. The UI layer does not appear to own business logic; it likely posts form data to the backend and renders whatever summary/metrics the API returns.

4. **Backend boundary: request orchestration and security.**  
   `backend/src/app.ts` wires middleware and routes, while `index.ts` starts the server. The backend is the system of record for validation, anti-abuse controls, AI summarization, lead handling, and persistence, making it the main integration layer between browser, database, and external services.

5. **Core API surface is split by domain.**  
   Routes are organized into `audit.route.ts`, `lead.route.ts`, and `tools.route.ts`, with controllers in `controllers/` handling the domain logic. There is also a `pricing.controller.ts`, suggesting a dedicated path for pricing/reference data used by the audit engine or UI comparisons.

6. **Audit processing is the central business subsystem.**  
   `audit.controller.ts` likely coordinates the audit workflow: ingest user tool/spend data, enrich it with curated pricing/tool data, pass it through `summaryEngine.ts`, and persist the result using `audit.model.ts`. The test file `auditEngine.test.ts` indicates the audit/scoring logic is important enough to be unit-tested separately.

7. **External service integration is abstracted into utilities.**  
   `summaryEngine.ts` wraps the AI generation layer described in the README as Google Generative AI/Gemini. `captcha.ts` handles hCaptcha verification, and `emailService.ts` handles transactional email through a provider such as Brevo/Resend. These utilities create clear boundaries around third-party dependencies so controllers can stay thin.

8. **Security and abuse prevention sit in middleware.**  
   `honeypot.middleware.ts`, `rateLimiter.ts`, and `validator.middleware.ts` form the defensive perimeter. This means input is screened before reaching controllers, with schema validation and bot/traffic filtering happening at the edge of the API rather than inside business logic.

9. **Persistence is MongoDB-backed and modeled explicitly.**  
   `db.ts` manages the MongoDB connection, while Mongoose models in `models/` define stored entities such as audit records and pricing data. The presence of `seedTools.ts` and `pricing.model.ts` suggests the app keeps a curated internal dataset for tool/pricing intelligence, not just raw user submissions.

10. **Deployment is split and likely serverless-friendly.**  
   Both `frontend/vercel.json` and `backend/vercel.json` indicate separate deploy targets, with environment-driven configuration via `.env.example`. The frontend likely talks to the backend over `VITE_API_URL`, while the backend relies on MongoDB, CAPTCHA, AI, and email service credentials.

11. **Operationally, the app is opinionated around lead capture and metrics.**  
   The repo includes standalone docs like `ECONOMICS.md`, `GTM.md`, `METRICS.md`, `PRICING_DATA.md`, and `USER_INTERVIEWS.md`, which suggests this is not just a codebase but a productized funnel with pricing intelligence, conversion tracking, and go-to-market artifacts aligned to the same audit workflow.

Main entry points: [`backend/src/app.ts`](https://github.com/vikasingh0897/auditai/blob/main/backend/src/app.ts) (API app), [`frontend/src/App.tsx`](https://github.com/vikasingh0897/auditai/blob/main/frontend/src/App.tsx) (App shell), [`backend/src/controllers/audit.controller.ts`](https://github.com/vikasingh0897/auditai/blob/main/backend/src/controllers/audit.controller.ts) (Audit controller), [`backend/src/controllers/lead.controller.ts`](https://github.com/vikasingh0897/auditai/blob/main/backend/src/controllers/lead.controller.ts) (Lead controller)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_bootstrap["App shell<br/>React bootstrap<br/>[App.tsx]"]
  node_frontend_entry(("Main entry<br/>Vite entry<br/>[main.tsx]"))
  node_landing_page["Landing page<br/>[LandingPage.tsx]"]
  node_audit_form["Audit form<br/>page<br/>[AuditForm.tsx]"]
  node_audit_summary["Audit summary<br/>page<br/>[AuditSummary.tsx]"]
  node_results_dashboard["Results dashboard<br/>page"]
  node_lead_modal["Lead modal<br/>page<br/>[LeadModal.tsx]"]
  node_header["Header<br/>shared UI<br/>[Header.tsx]"]
  node_footer["Footer<br/>shared UI<br/>[Footer.tsx]"]
end

subgraph group_backend["Backend"]
  node_backend_entry(("Server entry<br/>Node entry<br/>[index.ts]"))
  node_backend_app["API app<br/>Express app<br/>[app.ts]"]
  node_audit_route["Audit route<br/>API route<br/>[audit.route.ts]"]
  node_lead_route["Lead route<br/>API route<br/>[lead.route.ts]"]
  node_tools_route["Tools route<br/>API route<br/>[tools.route.ts]"]
  node_audit_controller["Audit controller<br/>domain controller"]
  node_lead_controller["Lead controller<br/>domain controller<br/>[lead.controller.ts]"]
  node_pricing_controller["Pricing controller<br/>domain controller"]
  node_validation_layer{{"Guardrails<br/>middleware"}}
  node_captcha_service["Captcha<br/>service adapter<br/>[captcha.ts]"]
  node_summary_engine["Summary engine<br/>AI adapter<br/>[summaryEngine.ts]"]
  node_email_service["Email service<br/>service adapter<br/>[emailService.ts]"]
  node_mongo_db[("MongoDB<br/>database connection<br/>[db.ts]")]
  node_audit_model[("Audit model<br/>Mongoose model<br/>[audit.model.ts]")]
  node_pricing_model[("Pricing model<br/>Mongoose model<br/>[pricing.model.ts]")]
  node_seed_tools["Seed tools<br/>seed data<br/>[seedTools.ts]"]
end

subgraph group_ops["Ops & Docs"]
  node_ci_workflow["CI workflow<br/>automation<br/>[ci.yml]"]
  node_vercel_frontend["Frontend deploy<br/>deployment config<br/>[vercel.json]"]
  node_vercel_backend["Backend deploy<br/>deployment config<br/>[vercel.json]"]
  node_docs_bundle["Product docs<br/>[README.md]"]
end

node_frontend_entry -->|"boots"| node_frontend_bootstrap
node_frontend_bootstrap -->|"shows"| node_landing_page
node_landing_page -->|"starts"| node_audit_form
node_audit_form -->|"submits to"| node_audit_summary
node_audit_summary -->|"renders"| node_results_dashboard
node_results_dashboard -->|"prompts"| node_lead_modal
node_frontend_bootstrap -.->|"uses"| node_header
node_frontend_bootstrap -.->|"uses"| node_footer
node_frontend_bootstrap -->|"calls API"| node_backend_app
node_backend_entry -->|"starts"| node_backend_app
node_backend_app -->|"applies"| node_validation_layer
node_backend_app -->|"mounts"| node_audit_route
node_backend_app -->|"mounts"| node_lead_route
node_backend_app -->|"mounts"| node_tools_route
node_audit_route -->|"delegates"| node_audit_controller
node_lead_route -->|"delegates"| node_lead_controller
node_tools_route -->|"delegates"| node_pricing_controller
node_audit_controller -->|"verifies"| node_captcha_service
node_audit_controller -->|"generates"| node_summary_engine
node_audit_controller -->|"persists"| node_audit_model
node_lead_controller -->|"notifies"| node_email_service
node_lead_controller -->|"stores"| node_mongo_db
node_pricing_controller -->|"reads"| node_pricing_model
node_pricing_model -->|"backed by"| node_mongo_db
node_audit_model -->|"backed by"| node_mongo_db
node_seed_tools -.->|"seeds"| node_pricing_model
node_ci_workflow -.->|"checks"| node_frontend_bootstrap
node_ci_workflow -.->|"checks"| node_backend_app
node_vercel_frontend -.->|"deploys"| node_frontend_entry
node_vercel_backend -.->|"deploys"| node_backend_entry
node_docs_bundle -.->|"describes"| node_backend_app
node_docs_bundle -.->|"describes"| node_frontend_bootstrap

click node_frontend_bootstrap "https://github.com/vikasingh0897/auditai/blob/main/frontend/src/App.tsx"
click node_frontend_entry "https://github.com/vikasingh0897/auditai/blob/main/frontend/src/main.tsx"
click node_landing_page "https://github.com/vikasingh0897/auditai/blob/main/frontend/src/pages/LandingPage.tsx"
click node_audit_form "https://github.com/vikasingh0897/auditai/blob/main/frontend/src/pages/AuditForm.tsx"
click node_audit_summary "https://github.com/vikasingh0897/auditai/blob/main/frontend/src/pages/AuditSummary.tsx"
click node_results_dashboard "https://github.com/vikasingh0897/auditai/blob/main/frontend/src/pages/ResultsDashboard.tsx"
click node_lead_modal "https://github.com/vikasingh0897/auditai/blob/main/frontend/src/pages/LeadModal.tsx"
click node_header "https://github.com/vikasingh0897/auditai/blob/main/frontend/src/components/Header.tsx"
click node_footer "https://github.com/vikasingh0897/auditai/blob/main/frontend/src/components/Footer.tsx"
click node_backend_entry "https://github.com/vikasingh0897/auditai/blob/main/backend/src/index.ts"
click node_backend_app "https://github.com/vikasingh0897/auditai/blob/main/backend/src/app.ts"
click node_audit_route "https://github.com/vikasingh0897/auditai/blob/main/backend/src/routes/audit.route.ts"
click node_lead_route "https://github.com/vikasingh0897/auditai/blob/main/backend/src/routes/lead.route.ts"
click node_tools_route "https://github.com/vikasingh0897/auditai/blob/main/backend/src/routes/tools.route.ts"
click node_audit_controller "https://github.com/vikasingh0897/auditai/blob/main/backend/src/controllers/audit.controller.ts"
click node_lead_controller "https://github.com/vikasingh0897/auditai/blob/main/backend/src/controllers/lead.controller.ts"
click node_pricing_controller "https://github.com/vikasingh0897/auditai/blob/main/backend/src/controllers/pricing.controller.ts"
click node_validation_layer "https://github.com/vikasingh0897/auditai/blob/main/backend/src/middlewares/validator.middleware.ts"
click node_captcha_service "https://github.com/vikasingh0897/auditai/blob/main/backend/src/utils/captcha.ts"
click node_summary_engine "https://github.com/vikasingh0897/auditai/blob/main/backend/src/utils/summaryEngine.ts"
click node_email_service "https://github.com/vikasingh0897/auditai/blob/main/backend/src/utils/emailService.ts"
click node_mongo_db "https://github.com/vikasingh0897/auditai/blob/main/backend/src/db.ts"
click node_audit_model "https://github.com/vikasingh0897/auditai/blob/main/backend/src/models/audit.model.ts"
click node_pricing_model "https://github.com/vikasingh0897/auditai/blob/main/backend/src/models/pricing.model.ts"
click node_seed_tools "https://github.com/vikasingh0897/auditai/blob/main/backend/src/seedingData/seedTools.ts"
click node_ci_workflow "https://github.com/vikasingh0897/auditai/blob/main/.github/workflows/ci.yml"
click node_vercel_frontend "https://github.com/vikasingh0897/auditai/blob/main/frontend/vercel.json"
click node_vercel_backend "https://github.com/vikasingh0897/auditai/blob/main/backend/vercel.json"
click node_docs_bundle "https://github.com/vikasingh0897/auditai/blob/main/README.md"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_frontend_bootstrap,node_frontend_entry,node_landing_page,node_audit_form,node_audit_summary,node_results_dashboard,node_lead_modal,node_header,node_footer toneBlue
class node_backend_entry,node_backend_app,node_audit_route,node_lead_route,node_tools_route,node_audit_controller,node_lead_controller,node_pricing_controller,node_validation_layer,node_captcha_service,node_summary_engine,node_email_service,node_mongo_db,node_audit_model,node_pricing_model,node_seed_tools toneAmber
class node_ci_workflow,node_vercel_frontend,node_vercel_backend,node_docs_bundle toneMint
```

## Components

### Frontend

Vite + React client for the audit funnel

- [App shell](https://github.com/vikasingh0897/auditai/blob/main/frontend/src/App.tsx): React bootstrap · Starts the client and mounts the application · `frontend/src/App.tsx`
- [Main entry](https://github.com/vikasingh0897/auditai/blob/main/frontend/src/main.tsx): Vite entry · Client entrypoint and render setup · `frontend/src/main.tsx`
- [Landing page](https://github.com/vikasingh0897/auditai/blob/main/frontend/src/pages/LandingPage.tsx): page · Top-of-funnel entry and product framing · `frontend/src/pages/LandingPage.tsx`
- [Audit form](https://github.com/vikasingh0897/auditai/blob/main/frontend/src/pages/AuditForm.tsx): page · Collects tools, spend, and captcha-gated submission · `frontend/src/pages/AuditForm.tsx`
- [Audit summary](https://github.com/vikasingh0897/auditai/blob/main/frontend/src/pages/AuditSummary.tsx): page · Renders the AI-generated audit outcome · `frontend/src/pages/AuditSummary.tsx`
- [Results dashboard](https://github.com/vikasingh0897/auditai/blob/main/frontend/src/pages/ResultsDashboard.tsx): page · Displays conversion-focused results and metrics · `frontend/src/pages/ResultsDashboard.tsx`
- [Lead modal](https://github.com/vikasingh0897/auditai/blob/main/frontend/src/pages/LeadModal.tsx): page · Captures follow-up details after results · `frontend/src/pages/LeadModal.tsx`
- [Header](https://github.com/vikasingh0897/auditai/blob/main/frontend/src/components/Header.tsx): shared UI · Common top-level navigation and branding · `frontend/src/components/Header.tsx`
- [Footer](https://github.com/vikasingh0897/auditai/blob/main/frontend/src/components/Footer.tsx): shared UI · Common page footer and secondary links · `frontend/src/components/Footer.tsx`

### Backend

Express API for audit processing and lead capture

- [Server entry](https://github.com/vikasingh0897/auditai/blob/main/backend/src/index.ts): Node entry · Starts the API server · `backend/src/index.ts`
- [API app](https://github.com/vikasingh0897/auditai/blob/main/backend/src/app.ts): Express app · Configures middleware, routing, and app wiring · `backend/src/app.ts`
- [Audit route](https://github.com/vikasingh0897/auditai/blob/main/backend/src/routes/audit.route.ts): API route · Audit submission and retrieval endpoints · `backend/src/routes/audit.route.ts`
- [Lead route](https://github.com/vikasingh0897/auditai/blob/main/backend/src/routes/lead.route.ts): API route · Lead capture and follow-up endpoints · `backend/src/routes/lead.route.ts`
- [Tools route](https://github.com/vikasingh0897/auditai/blob/main/backend/src/routes/tools.route.ts): API route · Curated tools and reference data endpoints · `backend/src/routes/tools.route.ts`
- [Audit controller](https://github.com/vikasingh0897/auditai/blob/main/backend/src/controllers/audit.controller.ts): domain controller · Orchestrates audit validation, enrichment, and persistence · `backend/src/controllers/audit.controller.ts`
- [Lead controller](https://github.com/vikasingh0897/auditai/blob/main/backend/src/controllers/lead.controller.ts): domain controller · Handles lead intake and delivery · `backend/src/controllers/lead.controller.ts`
- [Pricing controller](https://github.com/vikasingh0897/auditai/blob/main/backend/src/controllers/pricing.controller.ts): domain controller · Serves pricing and comparison data · `backend/src/controllers/pricing.controller.ts`
- [Guardrails](https://github.com/vikasingh0897/auditai/blob/main/backend/src/middlewares/validator.middleware.ts): middleware · Honeypot, rate limiting, and request validation · `backend/src/middlewares/validator.middleware.ts`
- [Captcha](https://github.com/vikasingh0897/auditai/blob/main/backend/src/utils/captcha.ts): service adapter · Verifies hCaptcha challenges · `backend/src/utils/captcha.ts`
- [Summary engine](https://github.com/vikasingh0897/auditai/blob/main/backend/src/utils/summaryEngine.ts): AI adapter · Generates audit summaries using Gemini-style AI · `backend/src/utils/summaryEngine.ts`
- [Email service](https://github.com/vikasingh0897/auditai/blob/main/backend/src/utils/emailService.ts): service adapter · Sends transactional or lead follow-up email · `backend/src/utils/emailService.ts`
- [MongoDB](https://github.com/vikasingh0897/auditai/blob/main/backend/src/db.ts): database connection · Shared database connection management · `backend/src/db.ts`
- [Audit model](https://github.com/vikasingh0897/auditai/blob/main/backend/src/models/audit.model.ts): Mongoose model · Stores audit records and outcomes · `backend/src/models/audit.model.ts`
- [Pricing model](https://github.com/vikasingh0897/auditai/blob/main/backend/src/models/pricing.model.ts): Mongoose model · Stores curated pricing and tool reference data · `backend/src/models/pricing.model.ts`
- [Seed tools](https://github.com/vikasingh0897/auditai/blob/main/backend/src/seedingData/seedTools.ts): seed data · Populates the curated tool dataset · `backend/src/seedingData/seedTools.ts`

### Ops & Docs

Deployment, CI, and product docs

- [CI workflow](https://github.com/vikasingh0897/auditai/blob/main/.github/workflows/ci.yml): automation · Runs repository checks in GitHub Actions · `.github/workflows/ci.yml`
- [Frontend deploy](https://github.com/vikasingh0897/auditai/blob/main/frontend/vercel.json): deployment config · Frontend hosting configuration · `frontend/vercel.json`
- [Backend deploy](https://github.com/vikasingh0897/auditai/blob/main/backend/vercel.json): deployment config · Backend hosting configuration · `backend/vercel.json`
- [Product docs](https://github.com/vikasingh0897/auditai/blob/main/README.md): docs · Architecture, economics, metrics, prompts, and GTM materials · `README.md`

## Connections

- Main entry → App shell: boots · Mounts the React application
- App shell → Landing page: shows · Primary landing experience
- Landing page → Audit form: starts · Moves users into the audit flow
- Audit form → Audit summary: submits to · Requests the AI-generated audit result
- Audit summary → Results dashboard: renders · Presents the post-audit outcome
- Results dashboard → Lead modal: prompts · Converts results into lead capture
- App shell → Header: uses · Shared top-level UI chrome
- App shell → Footer: uses · Shared page footer
- App shell → API app: calls API · Client consumes backend endpoints
- Server entry → API app: starts · Server initializes Express app
- API app → Guardrails: applies · Screens requests before controllers
- API app → Audit route: mounts · Registers audit endpoints
- API app → Lead route: mounts · Registers lead endpoints
- API app → Tools route: mounts · Registers tools/reference endpoints
- Audit route → Audit controller: delegates · Hands off audit requests
- Lead route → Lead controller: delegates · Hands off lead requests
- Tools route → Pricing controller: delegates · Serves pricing and tool data
- Audit controller → Captcha: verifies · Checks bot challenges before processing
- Audit controller → Summary engine: generates · Creates the AI summary payload
- Audit controller → Audit model: persists · Stores audit results
- Lead controller → Email service: notifies · Sends follow-up or confirmation email
- Lead controller → MongoDB: stores · Persists lead-related data
- Pricing controller → Pricing model: reads · Loads reference pricing data
- Pricing model → MongoDB: backed by · Mongoose persistence layer
- Audit model → MongoDB: backed by · Mongoose persistence layer
- Seed tools → Pricing model: seeds · Populates curated tool records
- CI workflow → App shell: checks · Builds and validates client code
- CI workflow → API app: checks · Builds and validates server code
- Frontend deploy → Main entry: deploys · Frontend hosting target
- Backend deploy → Server entry: deploys · Backend hosting target
- Product docs → API app: describes · Documents system design and product behavior
- Product docs → App shell: describes · Documents client structure and funnel
