System Patterns

System Architecture

The pickMail application follows a serverless architecture within the Val Town platform, leveraging its HTTP and email trigger capabilities:

  • Frontend: A simple HTML interface rendered by webmail.ts for displaying emails in an inbox format.
  • Backend: Two main scripts, webmail.ts for serving the web interface and fetching emails, and reciever.ts for processing incoming emails via an email trigger.
  • Database: Utilizes Val Town's provided SQLite database for storing email data, accessed through Drizzle ORM for type-safe operations.

The Webmail for Val Town application follows a serverless architecture within the Val Town platform, leveraging its HTTP and email trigger capabilities:

  • Frontend: A simple HTML interface rendered by webmail.ts for displaying emails in an inbox format.
  • Backend: Two main scripts, webmail.ts for serving the web interface and fetching emails, and reciever.ts for processing incoming emails via an email trigger.
  • Database: Utilizes Val Town's provided SQLite database for storing email data, accessed through Drizzle ORM for type-safe operations.

Key Technical Decisions

  • Drizzle ORM Adoption: Chosen for database interactions to ensure type safety and maintainability over raw SQL queries.

  • SQLite with LibSQL: Using @libsql/client with Drizzle ORM to interact with SQLite in a way compatible with Val Town's environment.

  • Migration Approach: Opting for Drizzle's migration system to manage schema changes, pending user input on migration file setup.

  • Forwarder Inbox Feature: Implementing AI-driven filtering to determine the importance of emails and forward them accordingly.

  • Drizzle ORM Adoption: Chosen for database interactions to ensure type safety and maintainability over raw SQL queries.

  • SQLite with LibSQL: Using @libsql/client with Drizzle ORM to interact with SQLite in a way compatible with Val Town's environment.

  • Migration Approach: Opting for Drizzle's migration system to manage schema changes, pending user input on migration file setup.

Design Patterns in Use

  • Separation of Concerns: Database schema is defined in shared/db/schema.ts for reuse across webmail.ts and reciever.ts.
  • Type-Safe Queries: Leveraging Drizzle ORM's query builder to construct type-safe database operations, reducing runtime errors.

Component Relationships

  • Webmail Interface (webmail.ts): Fetches email data from the SQLite database using Drizzle ORM and renders it as HTML.
  • Email Receiver (reciever.ts): Captures incoming emails via Val Town's email trigger and inserts them into the database using Drizzle ORM.
  • Shared Schema (shared/db/schema.ts): Defines the structure of the email table, ensuring consistency across different parts of the application.

Critical Implementation Paths

  • Email Fetching Flow: HTTP request -> webmail.ts -> Drizzle ORM query -> SQLite database -> Render HTML with email data.
  • Email Reception Flow: Incoming email -> reciever.ts (email trigger) -> Drizzle ORM insert -> SQLite database storage.