Modern web development is a bloated, over-engineered mess.
You start with a simple app idea, and before you know it, you’re knee-deep in Kubernetes, microservices, and 17 different JavaScript frameworks arguing about state management.
Every SaaS tool wants a piece of your wallet, and your once-fast web app now takes longer to load than a 1998 dial-up connection.
But what if I told you that PostgreSQL—yes, your friendly neighborhood database—can replace half your tech stack? Let's dive into the madness.
8. Authentication Without Auth0
Still paying for Auth0? Why? PostgreSQL has pgcrypto and pgjwt. You can roll your own authentication with a few lines of SQL.
CREATE EXTENSION IF NOT EXISTS pgcrypto;
CREATE EXTENSION IF NOT EXISTS pgjwt;
CREATE TABLE users (
id SERIAL PRIMARY KEY,
email VARCHAR(255) UNIQUE NOT NULL,
password TEXT NOT NULL,
name VARCHAR(255),
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
INSERT INTO users (email, password, name)
VALUES (
'user@example.com',
crypt('supersecurepassword', gen_salt('bf', 10)),
'Jeff'
);
SELECT id, email, name
FROM users
WHERE email = 'user@example.com'
AND password = crypt('supersecurepassword', password);
Now, add JWT support and enforce row-level security:
CREATE TABLE jwt_keys (
id SERIAL PRIMARY KEY,
kid VARCHAR(255) NOT NULL UNIQUE,
key TEXT NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);
ALTER TABLE documents ENABLE ROW LEVEL SECURITY;
CREATE POLICY user_documents_policy
ON documents
FOR SELECT USING (user_id = current_setting('jwt.claims.sub', true));
SELECT set_config('jwt.claims.sub', '1234567890', true);
Boom. You just built an auth system—no external services required.

Integrating Google Sign-In with React: A Dev-Friendly Guide
Athreya aka Maneshwar ・ Dec 31 '24
9. Ditch Google Analytics, Track Users with PostgreSQL
Google Analytics sells your soul. Let’s take back control with pg_mooncake, a time-series extension.
CREATE EXTENSION pg_mooncake;
CREATE TABLE user_activity(
user_id BIGINT,
activity_type TEXT,
activity_timestamp TIMESTAMP,
duration INT
) USING columnstore;
INSERT INTO user_activity VALUES
(1, 'login', '2024-01-01 08:00:00', 120),
(2, 'page_view', '2024-01-01 08:05:00', 30),
(3, 'logout', '2024-01-01 08:30:00', 60);
SELECT * FROM user_activity;
Now you own your analytics—no third parties snooping on your users.
10. Auto-Generated REST APIs with PostgREST
Writing REST APIs is for suckers. Just install PostgREST and let PostgreSQL do the work.
docker run --rm -p 3000:3000 \
-e PGRST_DB_URI="postgres://app_user:password@10.0.0.10/postgres" \
postgrest/postgrest
Just like that, you have a full-blown REST API without writing a single line of backend code.
11. Serve Static Files from PostgreSQL
Want to go full lunatic mode? Store and serve static files directly from PostgreSQL.
CREATE TABLE static_files (
id SERIAL PRIMARY KEY,
filename TEXT NOT NULL,
content BYTEA NOT NULL,
mime_type TEXT NOT NULL
);
INSERT INTO static_files (filename, content, mime_type)
VALUES ('index.html', decode('3c68746d6c3e3c2f68746d6c3e', 'hex'), 'text/html');
SELECT encode(content, 'escape') FROM static_files WHERE filename = 'index.html';
Congratulations, you now serve your frontend from your database like an absolute madman.
The Trade-Offs: Is This Madness Worth It?
Look, I’m not saying you should burn every other tool in your stack. PostgreSQL won’t replace everything, and sometimes specialized tools make sense.
But if you’re drowning in unnecessary dependencies, think twice before spinning up another microservice.
PostgreSQL can do more than you think—it’s time try treating it like the powerhouse it is.
So go ahead, de-bloat your stack, and embrace the chaos.
I’ve been working on a super-convenient tool called LiveAPI.
LiveAPI helps you get all your backend APIs documented in a few minutes
With LiveAPI, you can quickly generate interactive API documentation that allows users to execute APIs directly from the browser.
If you’re tired of manually creating docs for your APIs, this tool might just make your life easier.
Top comments (1)
Wasn’t this a fire ship video from a few days back?