PERN stack architecture
The MERN layout with PostgreSQL: relational data, SQL and transactions.

PERN swaps MongoDB for PostgreSQL in the MERN stack: PostgreSQL, Express, React and Node.js. You keep JavaScript or TypeScript across the app but store data in a relational database, with tables, foreign keys, joins and transactions.
The Express API talks to PostgreSQL through an ORM or query builder such as Prisma, Drizzle or Knex. Redis is a common addition for sessions, caching and rate limits.
What the stack is made of
- React
- The single-page front end.
- Express on Node.js
- The API layer, with routes, validation and authentication.
- Prisma, Drizzle or Knex
- Typed access to the database, plus migrations.
- PostgreSQL
- The relational database: constraints, transactions, JSONB for flexible fields and full-text search.
- Redis
- Optional. Sessions, cache and rate-limit counters.
How a request flows through it
- React calls the API with JSON.
- Express checks the session in Redis and validates the input.
- The handler runs a transaction in PostgreSQL through the ORM, such as creating an order and its line items together.
- The API returns JSON and React updates the page.
When to use it, and when not to
Good fit
- Business data with relationships: users, orders, invoices, permissions.
- You need transactions and constraints the database enforces.
- A JavaScript team that wants SQL, migrations and reporting queries.
Think twice
- Data with no fixed shape that changes per record: a document store may be simpler.
- Search-engine-critical pages, unless you add server rendering.
Edit this diagram
Click Open the diagram in the editor to get your own copy, saved in your browser. Rename the boxes to match your system, swap any technology for the one you use from the icon palette, then export a PNG, SVG or PDF, or share a link. No sign-up.