Skip to content

Developed a TypeScript and PostgreSQL-based platform for easy online retail store setup. • Designed and implemented various endpoints for both seller and buyer sides, enabling efficient store and product management, cart handling, and order placement.

Notifications You must be signed in to change notification settings

shubham-yadavv/StoreLink

Repository files navigation

StoreLink

Basic commands

git clone https://github.com//shubham-yadavv/StoreLink

 

Environment Variables

 

DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgres
DB_DATABASE=dukaan
PORT=3000

 

Docker build

docker-compose up -d

Setup Postgres

 

docker exec -it postgresdb psql -U username -W dukaan 

Copy and Paste DB Model

CREATE TABLE IF NOT EXISTS account (
    id SERIAL PRIMARY KEY,
    mobile_number VARCHAR(15) NOT NULL UNIQUE,
    otp VARCHAR(6),
    created_at TIMESTAMP DEFAULT NOW()
);

CREATE INDEX idx_account_id ON account (id);

CREATE TABLE IF NOT EXISTS store (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    address VARCHAR(255) NOT NULL,
    seller_id INT REFERENCES account(id) ON DELETE CASCADE,
    store_link VARCHAR(255) UNIQUE
);

CREATE INDEX idx_store_seller_id ON store (seller_id);

CREATE TABLE IF NOT EXISTS category (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255) UNIQUE
);

CREATE TABLE IF NOT EXISTS product (
    id SERIAL PRIMARY KEY,
    name VARCHAR(255),
    description TEXT,
    mrp NUMERIC(10, 2),
    sale_price NUMERIC(10, 2),
    image_url VARCHAR(255),
    category_id INT REFERENCES category(id) ON DELETE CASCADE,
    store_id INT REFERENCES store(id) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS customer (
    id SERIAL PRIMARY KEY,
    mobile_number VARCHAR(15),
    address VARCHAR(255)
);

CREATE TYPE order_status AS ENUM ('pending', 'accepted', 'rejected');
CREATE TABLE IF NOT EXISTS orders (  
    id SERIAL PRIMARY KEY,
    store_id INT REFERENCES store(id) ON DELETE CASCADE,
    customer_id INT REFERENCES customer(id) ON DELETE CASCADE,
    order_date TIMESTAMP,
    status order_status DEFAULT 'pending'
);

CREATE TABLE IF NOT EXISTS order_item (
    id SERIAL PRIMARY KEY,
    order_id INT REFERENCES orders(id) ON DELETE CASCADE,
    product_id INT REFERENCES product(id) ON DELETE CASCADE,
    quantity INT
);



exit PG CLI

 

You can access the server at: http://localhost:3000

API Docs available at : http://localhost:3000/docs

Screenshot 2023-10-24 at 8 52 00 PM

 

Routes Method Description
/api/seller/signup POST Seller Sign-up
/api/seller/store/create POST Create Store
/api/seller/products/upload POST Upload Products and Categories
/api/seller/orders/accept POST Accept Orders
/api/buyer/store/details POST Get Store Details
/api/buyer/products/catalog POST Get Product Catalog and Categories
/api/buyer/cart/add GET Add Items to Cart
/api/buyer/order/place POST Place an Order

About

Developed a TypeScript and PostgreSQL-based platform for easy online retail store setup. • Designed and implemented various endpoints for both seller and buyer sides, enabling efficient store and product management, cart handling, and order placement.

Topics

Resources

Stars

Watchers

Forks