# sri-dinesh/resume-builder-ai architecture

> Architecture diagram of the GitHub repository sri-dinesh/resume-builder-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sri-dinesh/resume-builder-ai
- Repository: https://github.com/sri-dinesh/resume-builder-ai

## Overview

##### Project Type and Purpose
- The project is a full-stack web application built with Next.js and TypeScript. It leverages React for the frontend UI and uses Prisma ORM with PostgreSQL for the backend database.
- Its purpose is to provide an AI-powered platform for building and customizing professional resumes. Key features like AI-powered suggestions, real‑time previews, multiple resume templates, and subscription management with Stripe are core to its functionality.

##### File Structure
- The top-level directories (e.g., src, prisma, public) indicate a modern Next.js project following the app directory structure.
- In the src/app folder, note the separation between authentication (in the (auth) folder) and the main, logged-in area (in the (main) folder). The (main) directory further splits components by functional areas such as billing (for Stripe-related subscription management) and editor (which contains many specific forms and editor features).
- There is an API folder (src/app/api) that hosts endpoints for actions like contact submissions and handling stripe-webhook events.
- The prisma folder holds database schema and migration files, signifying a relational database (PostgreSQL) accessed through Prisma.
- Additional directories (components, lib, hooks) support UI elements, business logic (e.g., Google AI integration via google-ai-model.ts), and reusable custom hooks.

##### README for Additional Insights
- The README describes the tool’s core functionality and outlines major features like AI-generated content, customizable templates, real-time preview, and ATS optimization.
- It calls out the technology stack: Next.js, React, Prisma ORM, PostgreSQL, Tailwind CSS, Shadcn UI, and Stripe for payments.
- These details reinforce the structures seen in the file tree and offer important context for the system's integration points and external services.

a. Main Components:
- User Interface Client: This includes the Next.js–driven frontend with pages for authentication, resume editing, subscription management, and public landing pages.
- Frontend Application (Next.js): Covers routing, SSR/SSG where applicable, and integration of React components.
- API Layer: Next.js API routes (e.g., /api/contact, /api/stripe-webhook) performing server-side logic, validations, and handling data exchange.
- Business Logic and Libraries: Modules in the lib folder handling tasks like AI integrations, animations, stripe operations, and data validations.
- Database: Managed by Prisma ORM with PostgreSQL; shown as the persistent data store for resume data, user accounts, and transaction records.
- External Services:
- Stripe: For managing subscriptions and billing.
- AI/Google Model: For powering the resume content suggestion and generation.
- Middleware & Authentication: Paths and custom hooks indicating session management and route protection.

b. Relationships and Interactions:
- Users interact with the Frontend UI which communicates via the API layer.
- API endpoints orchestrate calls between the UI, the business logic components, and the database.
- Certain API endpoints (such as stripe-webhook) also directly receive callbacks from external services like Stripe.
- Business logic modules (found in lib) integrate with external AI models to provide content suggestions and generate resume sections.

c. Architectural Patterns and Design Principles:
- Separation of Concerns: The division between Authentication, Main Application, and API routes.
- Modular Design: Break down into UI components (both common and page-specific), business logic libraries, and backend services.
- Integration Patterns: Use of serverless functions (API routes in Next.js) for backend operations and external service webhooks.

d. Key Technologies and Frameworks:
- React & Next.js: For rendering the UI and handling page-based routing.
- TypeScript: Ensuring type safety across the project.
- Prisma ORM & PostgreSQL: For database interactions and schema management.
- Stripe: For payment and subscription management integration.
- Tailwind CSS: For styling the UI.
- Shadcn UI: For UI component styling/assembly.

##### Final Recommendations
- Be as detailed as possible, separating the project into the numerous components you’ve identified.

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% User Layer
  User["User"]:::user

  %% UI Layer
  subgraph "UI Layer"
    %% Authentication Subgroup
    subgraph "Authentication"
      SignIn["Sign-In Page"]:::ui
      SignUp["Sign-Up Page"]:::ui
    end
    Landing["Public Landing (Page)"]:::ui
    Layout["Global Layout"]:::ui
    %% Main Application Subgroup
    subgraph "Main Application"
      Editor["Resume Editor"]:::ui
      Billing["Billing/Stripe"]:::ui
    end
    ComponentsApp["UI Components (src/app)"]:::ui
    ComponentsSrc["UI Components (src)"]:::ui
  end

  %% API Layer
  subgraph "API Layer"
    Contact["Contact Endpoint"]:::api
    StripeWebhook["Stripe Webhook Endpoint"]:::api
  end

  %% Business Logic Layer
  subgraph "Business Logic"
    AIModule["AI Integration Module"]:::bl
    StripeIntegration["Stripe Integration"]:::bl
    SubscriptionMgmt["Subscription Management"]:::bl
    LibUtils["Lib Utilities/Animations/Validation"]:::bl
  end

  %% Middleware & Hooks Layer
  subgraph "Middleware & Hooks"
    Middleware["Middleware"]:::mw
    Hooks["Custom Hooks"]:::mw
  end

  %% Database Layer
  subgraph "Database"
    PrismaSchema["DB Schema (Prisma)"]:::db
    Migrations["Migrations"]:::db
  end

  %% External Services Layer
  subgraph "External Services"
    StripeService["Stripe Service"]:::ext
    GoogleAIService["Google AI Service"]:::ext
  end

  %% Connections from User to UI Layer
  User --> SignIn
  User --> SignUp
  User --> Landing
  User --> Layout

  %% UI Layer: Authentication pages are secured by hooks
  SignIn --> Hooks
  SignUp --> Hooks

  %% Hooks and Middleware secure Main Application
  Hooks --> Editor
  Hooks --> Billing
  Middleware --> Editor
  Middleware --> Billing

  %% Public Pages contribute to Main Application navigation
  Landing --> Editor
  Layout --> Billing

  %% UI Components support the UI Layer
  Layout --> ComponentsApp
  Layout --> ComponentsSrc

  %% Main Application interacts with API Layer
  Editor -->|"calls"| Contact
  Billing -->|"calls"| StripeWebhook

  %% API Layer calls Business Logic and updates Database  
  Contact -->|"processes"| LibUtils
  StripeWebhook -->|"processes"| StripeIntegration
  StripeWebhook -->|"processes"| SubscriptionMgmt
  Contact --> PrismaSchema
  StripeWebhook --> PrismaSchema

  %% Business Logic interacts with Database and External Services
  LibUtils --> PrismaSchema
  StripeIntegration --> PrismaSchema
  SubscriptionMgmt --> PrismaSchema

  AIModule -->|"integrates"| GoogleAIService
  LibUtils --> AIModule
  StripeIntegration -->|"integrates"| StripeService
  SubscriptionMgmt -->|"integrates"| StripeService

  %% Class definitions for styling
  classDef user fill:#FFE4B5,stroke:#000,stroke-width:2px;
  classDef ui fill:#ADD8E6,stroke:#000,stroke-width:2px;
  classDef api fill:#90EE90,stroke:#000,stroke-width:2px;
  classDef bl fill:#FFD700,stroke:#000,stroke-width:2px;
  classDef mw fill:#DDA0DD,stroke:#000,stroke-width:2px;
  classDef db fill:#87CEEB,stroke:#000,stroke-width:2px;
  classDef ext fill:#F08080,stroke:#000,stroke-width:2px;

  %% Click Events for UI Layer
  click SignIn "https://github.com/sri-dinesh/resume-builder-ai/tree/main/src/app/(auth)/sign-in"
  click SignUp "https://github.com/sri-dinesh/resume-builder-ai/tree/main/src/app/(auth)/sign-up"
  click Landing "https://github.com/sri-dinesh/resume-builder-ai/blob/main/src/app/page.tsx"
  click Layout "https://github.com/sri-dinesh/resume-builder-ai/blob/main/src/app/layout.tsx"
  click Editor "https://github.com/sri-dinesh/resume-builder-ai/tree/main/src/app/(main)/editor"
  click Billing "https://github.com/sri-dinesh/resume-builder-ai/tree/main/src/app/(main)/billing"
  click ComponentsApp "https://github.com/sri-dinesh/resume-builder-ai/tree/main/src/app/components"
  click ComponentsSrc "https://github.com/sri-dinesh/resume-builder-ai/tree/main/src/components"

  %% Click Events for API Layer
  click Contact "https://github.com/sri-dinesh/resume-builder-ai/blob/main/src/app/api/contact/route.ts"
  click StripeWebhook "https://github.com/sri-dinesh/resume-builder-ai/blob/main/src/app/api/stripe-webhook/route.ts"

  %% Click Events for Business Logic
  click AIModule "https://github.com/sri-dinesh/resume-builder-ai/blob/main/src/lib/google-ai-model.ts"
  click StripeIntegration "https://github.com/sri-dinesh/resume-builder-ai/blob/main/src/lib/stripe.ts"
  click SubscriptionMgmt "https://github.com/sri-dinesh/resume-builder-ai/blob/main/src/lib/subscription.ts"
  click LibUtils "https://github.com/sri-dinesh/resume-builder-ai/blob/main/src/lib/utils.ts"

  %% Click Events for Middleware & Hooks
  click Middleware "https://github.com/sri-dinesh/resume-builder-ai/blob/main/src/middleware.ts"
  click Hooks "https://github.com/sri-dinesh/resume-builder-ai/tree/main/src/hooks"

  %% Click Events for Database
  click PrismaSchema "https://github.com/sri-dinesh/resume-builder-ai/blob/main/prisma/schema.prisma"
  click Migrations "https://github.com/sri-dinesh/resume-builder-ai/tree/main/prisma/migrations"
```
