Skip to content

sudovishal/go-url-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Shortener

Tech Stack- Go, Air, Postgres(For Live Deploy, probably will use NeonDB), htmx, templ This is my Postman Collection

Tentative Database Schema designed

CREATE TABLE guest_users (
    id SERIAL PRIMARY KEY,
    guest_id VARCHAR(36) UNIQUE NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE urls (
    id SERIAL PRIMARY KEY,
    original_url TEXT NOT NULL,
    short_code VARCHAR(10) UNIQUE NOT NULL,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP,
    expires_at TIMESTAMP WITH TIME ZONE,
    click_count INTEGER DEFAULT 0,
    guest_user_id INTEGER REFERENCES guest_users(id) ON DELETE SET NULL
);

CREATE INDEX idx_urls_short_code ON urls(short_code);
CREATE INDEX idx_urls_guest_user_id ON urls(guest_user_id);

Reference Links

Why _ is used while importing SQL Drivers HTMX Docs Templ Official Guide