The

PRAM Stack

in

Production

Episode #3

PRAM Stack on PostGIS Day:

Using it in Production

@rhysallister

Episodes?

Episodes?

Episodes?

So this presentation is episode #3

Agenda

What is the PRAM Stack?

What is "Production"?

What is lvwr.io?

What is the PRAM Stack?

PostGIS

ogr_fdw

http

gzip

What is Production?

Functionality

Reliability

Performance

Scalability

Security

Maintainability

Observability

lvwr.io

lvwr.io

Typical Web App Architecture

Presentation

Application

Data

Backend

Typical Web App Archtecture

Presentation

Application

Data

Backend

lvwr.io

PRAM Stack

lvwr.io

PRAM Stack

P

2

lvwr.io

P

3

lvwr.io

P

4

lvwr.io

P

4

What is this?

What is this?

CREATE TABLE api.livewires(
  livewire text NOT NULL,
  wireident uuid NOT NULL UNIQUE DEFAULT gen_random_uuid(),
  owner text NOT NULL REFERENCES authentic.users (email),
  company text NOT NULL GENERATED ALWAYS AS (split_part(owner, '@', 2)) STORED,
  description text,
  created_at timestamptz NOT NULL DEFAULT CURRENT_TIMESTAMP(0),
  isready boolean NOT NULL DEFAULT False,
  ispublic boolean NOT NULL DEFAULT False,
  g geometry(Polygon, 4326) NOT NULL DEFAULT st_buffer(st_makepoint(0, 0), 4),
  CONSTRAINT livewire_name CHECK (char_length(livewire) > 5),
  UNIQUE (wireident, owner),
  PRIMARY KEY (livewire, company)
);
COMMENT ON TABLE api.livewires IS 'This table shows the list of livewires';
ALTER TABLE api.livewires ENABLE ROW LEVEL SECURITY;

CREATE POLICY "Owner can see a livewire" ON api.livewires FOR SELECT USING
  (owner = current_setting('request.jwt.claims', true)::json ->> 'email' );

CREATE POLICY "Public livewire can be seen by all" ON api.livewires FOR SELECT USING
  (split_part(current_setting('request.jwt.claims', true)::json ->> 'email', '@', 2) = company
	AND ispublic AND isready);

CREATE POLICY "Only owners can update livewire stuff" ON api.livewires FOR UPDATE USING
  (owner = current_setting('request.jwt.claims', true)::json ->> 'email');

CREATE POLICY "Only owners can delete a livewire" ON api.livewires FOR DELETE USING
  (owner = current_setting('request.jwt.claims', true)::json ->> 'email');

CREATE POLICY "Only owners can insert a livewire" ON api.livewires FOR INSERT WITH CHECK
  (owner = current_setting('request.jwt.claims', true)::json ->> 'email');

What is this?

lvwr.io

pg_cron

pgTAP

pgtrgrm

pl/pgsql

pgsodium

pgjwt

livewire

ogr_fdw

http

gzip

lvwr.io

Presentation

Application & Data

Backend

HTTP Helper

Sensible database-native change management for framework-free development and dependable deployment.

pgTAP

If all you have is a hammer....

If you think PostgreSQL is just a hammer....

The PRAM Stack in Production

By rhysallister

The PRAM Stack in Production

  • 27