Skip to content

Store contact form submissions in database (Final)#32

Draft
WebCraftPhil wants to merge 3 commits into
mainfrom
feature/store-contact-submissions-5831199930155900990
Draft

Store contact form submissions in database (Final)#32
WebCraftPhil wants to merge 3 commits into
mainfrom
feature/store-contact-submissions-5831199930155900990

Conversation

@WebCraftPhil

@WebCraftPhil WebCraftPhil commented May 3, 2026

Copy link
Copy Markdown
Owner

Final submission of the contact form database storage feature. All feedback has been addressed, and the implementation is robust and follows project conventions.


PR created automatically by Jules for task 5831199930155900990 started by @WebCraftPhil

Summary by Sourcery

Persist contact form submissions using a database-backed storage layer with an in-memory fallback.

New Features:

  • Add contactSubmissions table schema and associated insert/select types for contact form data.
  • Store incoming contact form submissions from both serverless and Express-style handlers in persistent storage.

Enhancements:

  • Introduce a DatabaseStorage implementation backed by Drizzle ORM/Neon and select it at runtime when DATABASE_URL is configured, falling back to MemStorage otherwise.
  • Extend the shared storage interface and in-memory storage to support contact form submission records alongside users.
  • Add a shared db module to initialize the Drizzle ORM client and handle optional database availability.

google-labs-jules Bot and others added 3 commits April 22, 2026 01:59
- Updated `sentAt` field in `shared/schema.ts` to use `timestamp` type with `defaultNow()`.
- Updated `MemStorage` in `server/storage.ts` to use `Date` for `sentAt`.
- Improved `server/db.ts` and `server/storage.ts` to handle missing `DATABASE_URL` more robustly, allowing the app to start in memory mode without crashing.

Co-authored-by: WebCraftPhil <118385120+WebCraftPhil@users.noreply.github.com>
- Removed unnecessary `ws` and `neonConfig` setup from `server/db.ts`.
- Ensured `sentAt` uses `timestamp` type with `defaultNow()`.
- Verified that `DATABASE_URL` absence does not crash the server.

Co-authored-by: WebCraftPhil <118385120+WebCraftPhil@users.noreply.github.com>
- Implemented database storage for contact form submissions.
- Added graceful fallback to in-memory storage.
- Addressed PR feedback regarding timestamp types and driver optimization.

Co-authored-by: WebCraftPhil <118385120+WebCraftPhil@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@vercel

vercel Bot commented May 3, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
philgreene-net Ready Ready Preview, Comment May 3, 2026 3:01am

@coderabbitai

coderabbitai Bot commented May 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 02b9bf1e-ee42-4bae-911a-832d34abc83e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/store-contact-submissions-5831199930155900990

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@sourcery-ai

sourcery-ai Bot commented May 3, 2026

Copy link
Copy Markdown

Reviewer's Guide

Implements persistent storage for contact form submissions using Drizzle ORM with Neon, adds a database-backed storage implementation alongside the existing in-memory storage, defines the contact_submissions schema, and wires contact submission handlers to persist data when a database is configured, falling back to in-memory behavior otherwise.

Sequence diagram for contact submission handling and persistence

sequenceDiagram
  actor User
  participant Browser
  participant APIRoute as api_contact_handler
  participant Storage as storage
  participant DBStorage as DatabaseStorage
  participant MemStore as MemStorage
  participant Drizzle as drizzle_db
  participant Email as SendGrid

  User ->> Browser: Submit contact form
  Browser ->> APIRoute: POST /api/contact {name, email, projectType, budget, message}
  APIRoute->>APIRoute: Validate and sanitize input
  APIRoute->>Email: sendEmail(name, email, projectType, budget, message)
  Email-->>APIRoute: Email sent

  APIRoute->>Storage: insertContactSubmission({name, email, projectType, budget, message})
  alt DATABASE_URL configured
    Storage->>DBStorage: insertContactSubmission(submission)
    DBStorage->>Drizzle: insert into contact_submissions values(submission)
    Drizzle-->>DBStorage: ContactSubmission
    DBStorage-->>Storage: ContactSubmission
  else no DATABASE_URL
    Storage->>MemStore: insertContactSubmission(submission)
    MemStore-->>Storage: ContactSubmission
  end

  Storage-->>APIRoute: ContactSubmission
  APIRoute-->>Browser: { ok: true }
Loading

ER diagram for new contact_submissions table

erDiagram
  CONTACT_SUBMISSIONS {
    varchar id PK
    text name
    text email
    text project_type
    text budget
    text message
    timestamp sent_at
  }
Loading

Class diagram for updated storage and contact submission models

classDiagram
  class IStorage {
    <<interface>>
    +getUser(id string) Promise~User | undefined~
    +getUserByUsername(username string) Promise~User | undefined~
    +createUser(user InsertUser) Promise~User~
    +insertContactSubmission(submission InsertContactSubmission) Promise~ContactSubmission~
  }

  class DatabaseStorage {
    +getUser(id string) Promise~User | undefined~
    +getUserByUsername(username string) Promise~User | undefined~
    +createUser(insertUser InsertUser) Promise~User~
    +insertContactSubmission(submission InsertContactSubmission) Promise~ContactSubmission~
  }

  class MemStorage {
    -users Map~string, User~
    -submissions Map~string, ContactSubmission~
    +constructor()
    +getUser(id string) Promise~User | undefined~
    +getUserByUsername(username string) Promise~User | undefined~
    +createUser(user InsertUser) Promise~User~
    +insertContactSubmission(submission InsertContactSubmission) Promise~ContactSubmission~
  }

  class ContactSubmission {
    +id string
    +name string
    +email string
    +projectType string | null
    +budget string | null
    +message string
    +sentAt Date
  }

  class InsertContactSubmission {
    +name string
    +email string
    +projectType string | undefined
    +budget string | undefined
    +message string
  }

  IStorage <|.. DatabaseStorage
  IStorage <|.. MemStorage

  InsertContactSubmission --> ContactSubmission

  class StorageInstance {
    +storage IStorage
  }

  StorageInstance ..> DatabaseStorage
  StorageInstance ..> MemStorage
Loading

File-Level Changes

Change Details Files
Introduce database-backed storage (Neon + Drizzle) and make storage implementation pluggable based on DATABASE_URL.
  • Add a db module that initializes a Neon SQL client and Drizzle ORM instance using DATABASE_URL, exporting nulls when no DB is configured.
  • Create a DatabaseStorage class that implements the storage interface using Drizzle ORM queries for users and contact submissions.
  • Switch the exported storage instance to choose between DatabaseStorage and MemStorage depending on the presence of DATABASE_URL.
  • Add a runtime safeguard that throws if a DATABASE_URL exists but the db instance was not created.
server/db.ts
server/storage.ts
Add schema and types for contact form submissions and ensure they are compatible with Drizzle and zod.
  • Define the contactSubmissions pgTable with fields for name, email, projectType, budget, message, and sentAt, including defaults and nullability.
  • Create a zod-backed insertContactSubmissionSchema constrained to user-provided fields only.
  • Export InsertContactSubmission and ContactSubmission TypeScript types derived from the schema for use in storage and API layers.
shared/schema.ts
Add support for persisting contact form submissions in both API entry points using the new storage abstraction.
  • Extend the IStorage interface and MemStorage implementation with an insertContactSubmission method, including an in-memory representation with generated id and sentAt timestamp.
  • Update the serverless contact API handler to call storage.insertContactSubmission after sending email.
  • Update the Express-style server routes contact handler to persist submissions using storage.insertContactSubmission instead of the previous TODO comment.
server/storage.ts
api/contact.ts
server/routes.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant