Skip to content

jeffery-recopuerto/Ecommerce-full-stack-and-integration-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

38 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ MyStore - Full Stack E-Commerce Platform

Python React Flask TypeScript PostgreSQL License AI

A modern e-commerce platform with AI-powered chatbot, seller management system, and comprehensive order tracking.

Built with React, TypeScript, Flask, PostgreSQL (Render), and Hugging Face AI (Mistral-7B) for intelligent customer support.


πŸ“š Table of Contents


✨ Features

πŸ›’ Customer Features

  • πŸ” User Authentication - Signup/Login with OTP verification via Resend API
  • πŸ›οΈ Shopping Cart - Add, remove, and manage cart items
  • πŸ’³ Secure Checkout - Complete order with address details
  • πŸ“¦ Order Tracking - View order history and status
  • πŸ€– AI Chatbot - Product search and customer support (Hugging Face Mistral-7B)
  • πŸ“§ Email Notifications - Order confirmations via Resend API
  • πŸ” Product Filtering - Browse by categories

πŸ‘¨β€πŸ’Ό Seller Features

  • πŸ“ Seller Registration - Apply to become a seller with approval workflow
  • βž• Product Management - Add, edit, delete products
  • βœ… Draft/Publish System - Control product visibility
  • πŸ“Š Activity Logging - Track all product changes with audit trail
  • πŸ“§ Email Notifications - Get notified on approval/rejection
  • πŸ“ˆ Seller Dashboard - Manage inventory and view analytics

πŸ”§ Admin Features

  • βœ”οΈ Seller Approval System - Approve/reject seller applications via admin script
  • πŸ“© Contact Management - Handle customer inquiries
  • πŸ“Š System Monitoring - Overview of platform activity
  • πŸ› οΈ Database Management - Auto-create tables with setup script
  • πŸ“§ Email Queue - Automated email notifications

πŸ“Έ Screenshots

Signup Page

Signup Page

Login Page

Login Page

Home Page

Home Page

Seller Dashboard

Seller Dashboard

Seller Login

Seller Login

Add New Product

Add New Product

Cart Page

Cart Page

My Orders

My Orders

AI Chatbot

Chatbot

Chatbot Conversation

Chatbot Responses


πŸ› οΈ Tech Stack

Backend

Technology Purpose
Flask Python web framework
PostgreSQL Cloud database (Render)
psycopg2 PostgreSQL adapter for Python
bcrypt Password hashing
Resend API Email service for OTP & notifications
Hugging Face AI chatbot (Mistral-7B-Instruct-v0.2)
Flask-CORS Cross-origin requests
python-dotenv Environment variables

Frontend

Technology Purpose
React UI library
TypeScript Type safety
Vite Build tool
Axios HTTP client
CSS3 Styling

Cloud Services

  • Hugging Face API - Mistral-7B-Instruct-v0.2 for chatbot
  • Resend - Transactional email API
  • Render - PostgreSQL database hosting

πŸ“ Project Structure

ecommerce-project/
β”œβ”€β”€ Backend/ # Flask REST API (Python)
β”‚ β”œβ”€β”€ app.py # Main Flask application
β”‚ β”œβ”€β”€ create_tables.py # Database setup script
β”‚ β”œβ”€β”€ approve_seller.py # Admin seller management tool
β”‚ β”œβ”€β”€ .env.example # Environment variables template
β”‚ └── requirements.txt # Python dependencies
β”œβ”€β”€ frontend/ # React + TypeScript Frontend
β”‚ β”œβ”€β”€ src/ # Source code
β”‚ β”œβ”€β”€ public/ # Static assets
β”‚ β”œβ”€β”€ .env.production # Production config
β”‚ β”œβ”€β”€ vercel.json # Vercel deployment config
β”‚ └── package.json # Node dependencies
β”œβ”€β”€ Images/ # Project screenshots
β”œβ”€β”€ sql/ # SQL schema files (reference)
β”‚ β”œβ”€β”€ SingupDB.sql # User database schema
β”‚ └── seller_DB.sql # Seller database schema
└── README.md # This file

πŸš€ Getting Started

Prerequisites

Installation

1. Clone the Repository

git clone https://github.com/ShashankGowni/ecommerce-fullstack.git
cd ecommerce-project

Backend Setup

Navigate to Backend: ``bash cd Backend

**Create virtual environment:**
```bash

python -m venv venv

Activate virtual environment:

# Windows:
venv\Scripts\activate
pip install -r requirements.txt

Create .env file:

env

Email Configuration (Resend API)

[email protected]
EMAIL_PASSWORD=not-used-with-resend
RESEND_API_KEY=re_your_resend_api_key_here

Database Configuration (PostgreSQL on Render)

DATABASE_URL=postgresql://username:password@host/database_name

Hugging Face API

HF_API_KEY=hf_your_hugging_face_token_here
HF_API_URL=https://api-inference.huggingface.co/models/mistralai/Mistral-7B-Instruct-v0.2

Setup Database (Auto-create tables):

python create_tables.py

This script will:

  • Connect to your PostgreSQL database
  • Drop existing tables (if any)
  • Create all required tables
  • Set up indexes and triggers
  • Verify setup

Run Backend:

python app.py

🌐 Backend runs on http://localhost:5000

Frontend Setup

Navigate to frontend:

cd frontend

Install dependencies:

npm install

Create .env.local for development:

env

VITE_API_URL=http://localhost:5000

Run development server:

npm run dev
🌐 Frontend runs on http://localhost:5173

Get API Keys

Render PostgreSQL Database

  • Go to https://render.com/
  • Sign up for free account
  • Click "New" β†’ "PostgreSQL"
  • Choose free plan
  • Copy the "External Database URL"
  • Add to .env as DATABASE_URL

Hugging Face API

  • Go to https://huggingface.co/join
  • Sign up for free
  • Go to Settings β†’ Access Tokens
  • Click "New token"
  • Select "Read" permission
  • Copy token

Add to .env:

env

HF_API_KEY=hf_your_token_here

Resend API (Email/OTP)

Add to .env:

env

RESEND_API_KEY=re_your_key_here

πŸ”Œ API Endpoints

Authentication

POST /signup - User registration
POST /login - User login
POST /send-otp - Send OTP verification via Resend
POST /verify-otp - Verify OTP code

Seller Management

POST /seller-signup - Seller registration (creates pending seller)
POST /seller-login - Seller login (only approved sellers)
GET /seller-products - Get seller's products
POST /check-seller-status - Check approval status
GET /seller-activity - Get activity logs
POST /update-seller-status - Approve/reject seller (admin only)

Products

GET /products - Get all published products
GET /products/<id> - Get single product details
POST /add-product - Add new product (seller only)
PUT /products/<id> - Update product
DELETE /products/<id> - Delete product
PATCH /products/<id>/publish - Publish product
PATCH /products/<id>/unpublish - Unpublish (draft) product

Orders

POST /save-order - Save order to database
POST /send-order-email - Send order confirmation via Resend
GET /get-orders/<email> - Get user's order history
Chatbot (AI - Hugging Face)
POST /chat - Basic AI chat with Mistral-7B
POST /chat-with-history - Chat with conversation context
POST /chat-product-search - AI-powered product search

Contact

POST /contact-us - Submit contact form
GET /admin/contact-messages - Get all messages (admin)

πŸ’Ύ Database Schema

Tables Created by create_tables.py:

  • Users - Customer accounts with authentication
  • Sellers - Seller accounts with approval status
  • Products - Product catalog (draft/published states)
  • Orders - Customer order information
  • OrderItems - Individual items in orders
  • ProductActivityLog - Audit trail for product changes
  • SellerStatusChanges - Track seller approval/rejection with email queue
  • ContactMessages - Customer support inquiries

Triggers:

trg_seller_status_change - Auto-log status changes and queue emails

Indexes:

Optimized for seller email, product ID, and timestamp queries

πŸ› οΈ Admin Tools

Database Setup Script

  • File: create_tables.py

  • Purpose: Automatically creates all database tables, indexes, and triggers

Usage:

cd Backend
python create_tables.py

Features:

  • βœ… Drops old tables safely
  • βœ… Creates all tables in correct order
  • βœ… Sets up foreign keys
  • βœ… Creates indexes for performance
  • βœ… Sets up email notification triggers
  • βœ… Verifies setup

Seller Management Tool (CRUD)

  • File: approve_seller.py

  • Purpose: Admin interface for managing sellers

Usage:

cd Backend
python approve_seller.py

Features:

READ/VIEW:

  • View all sellers
  • View pending sellers
  • View seller details by ID

UPDATE:

  • Approve seller (sends email, allows login)
  • Reject seller (sends email, blocks login)

Update seller information

CREATE:

Manually create seller with chosen status

DELETE:

Delete seller and all products

EMAIL: Send pending approval emails

  • πŸ”’ Security Features
  • βœ… Password hashing with bcrypt
  • βœ… OTP verification for signup via Resend API
  • βœ… Environment variables for sensitive data
  • βœ… SQL injection protection (parameterized queries)
  • βœ… Session management
  • βœ… Secure authentication flow
  • βœ… API keys never exposed to frontend
  • βœ… CORS protection with Flask-CORS
  • βœ… PostgreSQL SSL mode enabled

πŸ› Troubleshooting

Backend Issues

PostgreSQL connection error:

DATABASE_URL=postgresql://user:password@host/dbname

python create_tables.py

psycopg2 installation fails:

pip install psycopg2-binary

Hugging Face API errors:

βœ… Check if HF_API_KEY is valid βœ… First request takes 20-30 seconds (model loading) βœ… Free tier has rate limits βœ… Check https://status.huggingface.co/

**Resend email not sending:**

- βœ… Verify RESEND_API_KEY is correct
- βœ… Free tier: 3,000 emails/month, 100/day
- βœ… Check dashboard: https://resend.com/emails
- βœ… Verify sender email

**Import errors:**
```bash
pip install -r requirements.txt

Frontend Issues

Module not found:

rm -rf node_modules package-lock.json
npm install

Port already in use:

export default defineConfig({
  server: { port: 3000 }
})

CORS errors:

  • Verify backend URL in frontend config
  • Check Flask-CORS is installed
  • Verify backend is running

Build errors:

npm run build

Database Issues

Tables not created:

python create_tables.py
Seller can't login after approval:

Run approve_seller.py to check status Verify status is "Approved" (case-sensitive) Products not showing:

Check product status is "published" (not "draft") Verify seller is approved

πŸ“ License

Β© 2025 Gowni Shashank. All Rights Reserved.

This software is proprietary and confidential. See the LICENSE file for complete terms.

πŸ“‹ License Summary

  • βœ… Viewable for portfolio/demonstration purposes only
  • ❌ No permission to use, copy, modify, or distribute
  • ❌ Commercial use strictly prohibited without written permission
  • πŸ’Ό For licensing inquiries: [email protected] This project is shared publicly to showcase my development capabilities.

πŸ™ Acknowledgments

Flask - Python web framework

  • Hugging Face - AI model hosting and Mistral-7B model
  • Resend - Modern email API
  • React - Frontend library
  • Vite - Build tool
  • PostgreSQL - Database
  • Render - Cloud database hosting
  • Vercel - Frontend deployment

πŸ“¬ Contact

Gowni Shashank

πŸ“§ Email: [email protected] πŸ’Ό LinkedIn: linkedin.com/in/shashankgowni πŸ™ GitHub: @ShashankGowni

Open to collaboration on interesting projects.

Created with πŸ’» by Gowni Shashank β€’ January 2025 🌍

About

Full-stack e-commerce platform with Flask backend, React frontend, and AI chatbot

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published