git clone https://github.com//shubham-yadavv/StoreLink
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgres
DB_DATABASE=dukaan
PORT=3000
docker-compose up -d
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](https://private-user-images.githubusercontent.com/68185027/278037166-f89d77bc-abe0-4ad2-a821-573a30b6fe86.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjI4MzEwODEsIm5iZiI6MTcyMjgzMDc4MSwicGF0aCI6Ii82ODE4NTAyNy8yNzgwMzcxNjYtZjg5ZDc3YmMtYWJlMC00YWQyLWE4MjEtNTczYTMwYjZmZTg2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MDUlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODA1VDA0MDYyMVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWYwYzU5MmQ3NjQ0OTFiOWIxMTAwYWE5NzBkNjRhN2EzNjY5N2MzNTFkNzBmNjI1MWQzYjIxNDYxMDgyNzVmMzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.s4QXJPPUBkCv0qNaHzBBKBGQg8ut9_NkdqSA3ynMqik)
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 |