# ymadhumohanreddy/the-preppal architecture

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

- Interactive diagram: https://gitdiagram.com/ymadhumohanreddy/the-preppal
- Repository: https://github.com/ymadhumohanreddy/the-preppal

## Overview

##### Project type and purpose
- PrepPal is a full-stack AI-driven web application built with Next.js (App Router), React and Tailwind CSS on the frontend, Node.js + Drizzle ORM on the backend, and PostgreSQL as the primary data store.
- Its goal is to serve interactive interview sessions: generate questions, collect user responses, send them to an AI service for feedback, and persist sessions for later review.

##### File structure
- Top-level “app” directory: Next.js App Router pages and nested routes for auth (sign-in, sign-up), static pages (aboutme, giveup), and the core “dashboard” section.
- “components”: shared UI elements (buttons, cards, modals, etc.).
- “utils” and “lib”: database connector (utils/db.js), ORM schema (utils/schema.js), AI-modal wrapper (utils/GeminiAIModal.js), general helpers (lib/utils.js).
- Configuration and build scripts: drizzle.config.js, next.config.mjs, postcss.config.mjs, tailwind.config.js.
- “public”: static assets (videos, fonts).
- Middleware (middleware.js) manages auth or route protections.

##### Readme insights
- Features: question generation, real-time feedback, session storage.
- Tech stack: React/Next.js, Tailwind, Node.js, Drizzle ORM, PostgreSQL, external AI APIs.
- Project structure hints at clear separation: frontend components vs. data/DB utilities.

a. Main components to show
- Client (Browser/Mobile) running Next.js React App (Client Components)
- Next.js Server (Server Components + API Routes)
- Drizzle ORM Layer (drizzle.config.js + utils/db.js + utils/schema.js)
- PostgreSQL Database
- External AI Service (OpenAI or Gemini via GeminiAIModal)
- Static Asset Server (Next.js “public”)
- Authentication/Middleware

b. Relationships and interactions
- Browser ↔ Next.js Server: page requests, API calls, client-server component hydration
- Next.js Server ↔ Database: ORM queries for session data, user profiles, interview logs
- Next.js Server ↔ AI Service: HTTP/gRPC calls for question generation or feedback
- Next.js Server ↔ Static Assets: CSS, fonts, videos served from “public”
- Middleware enforces auth on protected routes (dashboard, interview)

c. Architectural patterns / design principles
- Layered architecture: Presentation (React UI) → Application (Next.js SSR/Server Components) → Data (Drizzle ORM → PostgreSQL)
- Component-based UI (isolated, reusable UI bits under “components” and “app/dashboard/_components”)
- Route grouping and nested layout using Next.js App Router conventions
- Separation of concerns: AI integration encapsulated in utils/GeminiAIModal.js

d. Key technologies / frameworks
- Next.js App Router & Server Components
- React + Tailwind CSS for UI
- Drizzle ORM + PostgreSQL for persistence
- External AI API (via GeminiAIModal or OpenAI wrapper)
- Middleware.js for request guards

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        Browser["Client (Browser/Mobile)"]:::client
        AppUI["React/Tailwind UI\n(Next.js App Router & Components)"]:::frontend
        Browser -->|renders| AppUI
    end

    %% Authentication & Static Pages (Client)
    subgraph "Routes & Pages" 
        direction TB
        AuthRoutes["Auth Routes\n(Sign-In, Sign-Up)"]:::frontend
        StaticPages["Static Pages\n(About Me, Give Up)"]:::frontend
        DashboardUI["Dashboard UI\n(Dashboard, Interview Workflow)"]:::frontend
        AppUI --> AuthRoutes
        AppUI --> StaticPages
        AppUI --> DashboardUI
    end

    %% Server Layer
    subgraph "Server Layer"
        direction TB
        AuthMiddleware["Auth Middleware\n(middleware.js)"]:::backend
        NextServer["Next.js Server\n(Server Components & API Routes)"]:::backend
        Helpers["Utility Helpers\n(lib/utils.js, utils/planData.jsx)"]:::backend
        AuthRoutes -->|protected by| AuthMiddleware
        StaticPages -->|static SSR| NextServer
        DashboardUI -->|data/API calls| NextServer
        NextServer --> Helpers
    end

    %% ORM & Data Layer
    subgraph "Data Layer"
        direction TB
        ORM["Drizzle ORM Layer\n(utils/db.js, utils/schema.js)"]:::backend
        DB["PostgreSQL Database"]:::database
        NextServer -->|ORM queries| ORM
        ORM -->|SQL queries| DB
    end

    %% AI Integration
    subgraph "AI Integration"
        direction TB
        AIWrapper["Gemini AI Modal\n(utils/GeminiAIModal.js)"]:::external
        NextServer -->|calls| AIWrapper
        AIService["External AI Service"]:::external
        AIWrapper -->|HTTP/gRPC| AIService
    end

    %% Static Assets
    StaticAssets["Static Assets\n(public/)"]:::static
    NextServer -->|serves| StaticAssets

    %% Click Events
    click AppUI "https://github.com/ymadhumohanreddy/the-preppal/tree/main/app/"
    click AuthMiddleware "https://github.com/ymadhumohanreddy/the-preppal/blob/main/middleware.js"
    click ORM "https://github.com/ymadhumohanreddy/the-preppal/blob/main/utils/db.js"
    click AIWrapper "https://github.com/ymadhumohanreddy/the-preppal/blob/main/utils/GeminiAIModal.js"
    click StaticAssets "https://github.com/ymadhumohanreddy/the-preppal/tree/main/public/"

    %% Styles
    classDef client fill:#e3f2fd,stroke:#42a5f5,color:#0d47a1
    classDef frontend fill:#bbdefb,stroke:#1e88e5,color:#0d47a1
    classDef backend fill:#c8e6c9,stroke:#43a047,color:#1b5e20
    classDef database fill:#eeeeee,stroke:#757575,color:#424242
    classDef external fill:#ffe0b2,stroke:#fb8c00,color:#e65100
    classDef externalService fill:#ffd54f,stroke:#f57f17,color:#e65100
    classDef static fill:#f5f5f5,stroke:#9e9e9e,color:#424242
```
