AI Startup Analyzer is built as a TypeScript monorepo that separates concerns across four workspaces: two deployable applications and two shared packages. The backend receives HTTP requests, enqueues analysis jobs, and runs 14 AI agents in two coordinated parallel phases. The frontend streams live progress from the queue and renders the completed report. Redis serves both the job queue and the AI response cache, while Prisma and Neon PostgreSQL form the durable data layer.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Abbaddii-99/AI-Startup-Analyzer/llms.txt
Use this file to discover all available pages before exploring further.
Repository Structure
packages/db and packages/shared are compiled before either application starts. The shared packages are referenced by their package names (@ai-analyzer/db, @ai-analyzer/shared) and resolved locally via workspace symlinks — no publishing step is required.
Request Lifecycle
Every analysis follows the same end-to-end path from the HTTP layer through the queue and into the database.AnalysisController is protected by JWT authentication (httpOnly cookie), a CSRF middleware applied to all /analysis routes, and a global ThrottlerGuard capped at 10 requests per second and 100 requests per minute.
The Two-Phase Agent Execution Model
The 14 agents are split into two phases based on their data dependencies. This design minimises total wall-clock time: agents within the same phase have no dependency on each other and can run fully concurrently.Phase 1 — Six Core Agents (parallel)
These agents receive only the raw idea string. They run withPromise.all, meaning all six must succeed before Phase 2 begins.
| Agent | Primary Output Type |
|---|---|
IdeaAnalyzerAgent | IdeaAnalysis |
MarketResearchAgent | MarketResearch |
CompetitorAnalysisAgent | CompetitorAnalysis |
MVPGeneratorAgent | MVPPlan |
MonetizationAgent | MonetizationStrategy |
GoToMarketAgent | GoToMarketStrategy |
90. The combined agentResults object is passed as context to every Phase 2 agent.
Phase 2 — Seven Advanced Agents (parallel, fault-tolerant)
These agents synthesize their output from both the original idea and the Phase 1 results. They run withPromise.allSettled so that a single agent failure does not abort the entire analysis.
ComprehensiveIdeaAnalyzerAgent runs as a final single-agent step with full context from both phases.
Phase 2 uses
Promise.allSettled — a rejected agent logs a warning and stores null for its section rather than failing the whole job. The only exception is FinalReportAgent: if it rejects, the processor throws and the job is marked FAILED, because the IdeaScore fields it produces are required for the top-level analysis record.Grounding Pipeline
After Phase 2, theFinalReport output passes through a quality evaluation and grounding pipeline before being written to the database.
| Flag | Effect when "true" |
|---|---|
ENABLE_RULE_GROUNDING | Applies deterministic structural corrections (field presence, score clamping, length checks) |
ENABLE_AI_GROUNDING | Passes the report back to the AI with grounding instructions to improve coherence and completeness |
"true". Set either to "false" to skip that grounding pass. When both are disabled, the raw FinalReport output is written to the database without modification.
Data Layer
Prisma + Neon PostgreSQL
All persistent data is stored in a Neon PostgreSQL database managed through Prisma 6. Thepackages/db workspace contains the Prisma schema and all committed migrations. Two connection strings are required:
DATABASE_URL— the pooled Neon connection string used by the running application.DIRECT_DATABASE_URL— the direct (non-pooled) connection string used exclusively by Prisma migrations.
prisma migrate deploy as an entrypoint command before the API starts. If migrations fail, the container exits and serves no traffic.
Redis Cache
Redis is used for two distinct purposes:- BullMQ job queue — the
"analysis"queue persists jobs, tracks progress, and handles retries. BullMQ uses ioredis under the hood and connects using theREDIS_HOST,REDIS_PORT, andREDIS_PASSWORDenvironment variables. - AI response cache — individual AI agent responses are cached with a 24-hour TTL. Cache keys are derived from a sha256 hash of the agent name and the input payload, so identical idea strings served within the TTL window do not incur additional AI API calls.
Security and Middleware
The NestJS application bootstraps with the following security layers, all configured inmain.ts:
- Helmet — sets CSP,
X-Frame-Options, HSTS, and other security headers on every response. - Cookie Parser — enables httpOnly cookie-based JWT authentication. Access tokens and refresh tokens are never exposed to JavaScript.
- CORS — in production, only origins listed in
FRONTEND_URL(comma-separated) are allowed. In development, all origins are permitted. - CSRF Middleware — applied to all
/analysisroutes viaCsrfMiddleware. - ValidationPipe — strips undeclared properties (
whitelist: true) and transforms payloads to their DTO types (transform: true). - ThrottlerGuard — global rate limiting at 10 req/s and 100 req/min via
@nestjs/throttler.
Shared Packages
@ai-analyzer/shared
The packages/shared workspace exports TypeScript types, validation helpers, and normalization utilities consumed by both the backend worker and (where applicable) the frontend. All exports are re-exported from a single entry point:
validateFinalReportDetailed and normalizeFinalReport functions from this package are used directly inside AnalysisProcessor to compute normalization confidence before and after the grounding pipeline runs.
@ai-analyzer/db
The packages/db workspace contains the Prisma schema and migrations. It does not export application code — it is consumed at the infrastructure level via pnpm db:generate, pnpm db:migrate:dev, and pnpm db:migrate:deploy.
Module Structure (Backend)
The NestJS application is composed of three feature modules registered inAppModule, plus a global health controller:
| Module | Responsibilities |
|---|---|
AuthModule | JWT strategy, refresh token rotation, Google OAuth, /auth/* routes |
AnalysisModule | Analysis CRUD, plan quota enforcement, BullMQ producer, /analysis/* routes |
AgentsModule | Provides all 14 agent services and AIService to the DI container |