2026Marketplace architecture

Edge C2C Marketplace with Encrypted Messaging

Technologies

Next.jsHonoPostgreSQLDrizzle ORMCloudflare HyperdriveCloudflare Realtime KitSignal Protocol

Features

End-to-end encrypted messaging integrated directly into the marketplace

Overview

Architecture design for a user-to-user C2C marketplace with integrated encrypted messaging. The system was defined with an edge-first approach, using Cloudflare Workers to support low latency, scalability, and clean integration with realtime services. The platform combines core marketplace concerns such as users, listings, and transactions with an end-to-end chat designed for secure user communication. The architecture was shaped before development started so stack choices could follow real constraints and reduce later complexity and technical debt.

Role

Led the application architecture and stack definition, with responsibility for technology selection, trade-off evaluation, edge-native backend design, database modelling, C2C commerce flows, and the integration of a secure messaging system.

What I did

Defined an edge-first architecture compatible with Cloudflare Workers, designed around distributed traffic, low latency, realtime support, and real edge-runtime constraints. Set up the backend structure with Hono, separating the main application domains: users, C2C listings, platform logic, and messaging integration. Designed the PostgreSQL data model with Drizzle ORM, covering users, authentication, listings, conversations, messages, and interaction state between users. Designed and integrated a secure chat system based on the Signal Protocol, including session handling, key exchange, end-to-end encryption, and realtime updates. Defined database connectivity through Hyperdrive and used Cloudflare tooling for realtime synchronization in a way that stayed consistent with the edge architecture.

Problems solved

Technology choices in an edge environment

Deploying on Cloudflare Workers introduces hard constraints around runtime compatibility, libraries, and database connectivity. The architecture was designed around technologies that fit the edge environment from the start, avoiding unsupported or expensive integrations later on.

Database integration in a serverless edge setup

Connecting a traditional database from an edge environment can introduce latency and operational complexity. Using Hyperdrive made it possible to keep PostgreSQL connectivity compatible with Workers while preserving performance and stability.

Secure messaging integrated into the product

Integrating encrypted chat inside a marketplace requires key management, session handling, and realtime synchronization. Choosing the Signal Protocol made it possible to design a secure communication layer without compromising the product experience or bolting on a disconnected external solution.