Skip to content

sandeep7348/snitch-fullstack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

15 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›οΈ Snitch Fullstack

A full-stack MERN E-Commerce Application inspired by the Snitch clothing brand. The project provides secure authentication, product management, cloud image uploads, shopping cart functionality, and AI-powered semantic product search using Mistral AI Embeddings and Pinecone Vector Database.


πŸš€ Features

πŸ” Authentication

  • User Registration
  • User Login (JWT Authentication)
  • Secure HTTP-only Cookies
  • Logout
  • Get Current User
  • Protected Routes
  • Google OAuth (In Progress)

πŸ“¦ Product Management

  • Create Product
  • Update Product
  • Delete Product
  • Get All Products
  • Get Product by ID
  • Get Products by Category
  • Get Distinct Categories
  • Cloud Image Upload using ImageKit
  • Product Stock Management

πŸ›’ Shopping Cart

  • Add Product to Cart
  • Get Logged-in User Cart
  • Remove Product from Cart
  • Clear Cart
  • Quantity Management
  • Stock Validation before Adding Products
  • Protected Cart APIs

πŸ€– AI Features

  • AI-powered Semantic Product Search
  • Product Embedding using Mistral AI Embeddings
  • Vector Storage using Pinecone
  • Automatic Embedding Generation when Product is Created
  • Automatic Embedding Update when Product is Updated
  • Automatic Vector Deletion when Product is Deleted
  • Semantic Similarity Search using Vector Embeddings

πŸ”’ Security

  • JWT Authentication
  • HTTP-only Cookies
  • Password Hashing using bcrypt
  • Protected REST APIs
  • CORS Configuration

πŸ›  Tech Stack

Frontend

  • React
  • Vite
  • React Router
  • Axios
  • Tailwind CSS

Backend

  • Node.js
  • Express.js
  • MongoDB
  • Mongoose
  • Multer
  • ImageKit
  • JWT
  • Cookie Parser

AI Stack

  • LangChain
  • Mistral AI Embeddings
  • Pinecone Vector Database

πŸ“‚ Project Structure

snitch-fullstack/
β”‚
β”œβ”€β”€ Backend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   β”œβ”€β”€ auth.controller.js
β”‚   β”‚   β”œβ”€β”€ post.controller.js
β”‚   β”‚   └── cart.controller.js
β”‚   β”‚
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ user.models.js
β”‚   β”‚   β”œβ”€β”€ post.models.js
β”‚   β”‚   └── cart.models.js
β”‚   β”‚
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ auth.routes.js
β”‚   β”‚   β”œβ”€β”€ post.routes.js
β”‚   β”‚   └── cart.routes.js
β”‚   β”‚
β”‚   β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ app.js
β”‚   β”œβ”€β”€ package.json
β”‚   └── .env
β”‚
β”œβ”€β”€ Frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ public/
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”‚
└── README.md

πŸ“¦ Installation

Clone Repository

git clone https://github.com/sandeep7348/snitch-fullstack.git

cd snitch-fullstack

Backend Setup

cd Backend

npm install

Create a .env file.

PORT=3000

MONGODB_URL=your_mongodb_connection_string

JWT_SECRET=your_jwt_secret

IMAGE_KIT_PUBLIC_KEY=your_public_key
IMAGE_KIT_PRIVATE_KEY=your_private_key
IMAGE_KIT_URL_ENDPOINT=your_url_endpoint

GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret

MISTRAL_API_KEY=your_mistral_api_key

PINECONE_API_KEY=your_pinecone_api_key
PINECONE_INDEX_NAME=your_pinecone_index_name

Run Backend

npm run dev

Frontend Setup

cd Frontend

npm install

npm run dev

REST API

Authentication

Method Endpoint
POST /api/auth/register
POST /api/auth/login
GET /api/auth/getMe
POST /api/auth/logout

Products

Method Endpoint
POST /api/post
GET /api/allpost
GET /api/post/:id
PUT /api/post/:postId
DELETE /api/post/:postId
GET /api/category/:category
GET /api/categories
POST /api/search

Shopping Cart

Method Endpoint
POST /api/cart/add
GET /api/cart
DELETE /api/cart/remove/:postId
DELETE /api/cart/clear

AI Semantic Search

Every product is converted into a vector embedding using Mistral AI Embeddings.

The embedding is stored in Pinecone along with product metadata.

When a user searches for a product:

  • The search query is converted into an embedding.
  • Pinecone performs semantic similarity search.
  • Matching product IDs are returned.
  • Complete product details are fetched from MongoDB.
  • Relevant products are returned to the user.

Product Creation Flow

Admin Creates Product
        β”‚
        β–Ό
 Upload Image (ImageKit)
        β”‚
        β–Ό
 Save Product (MongoDB)
        β”‚
        β–Ό
 Generate Embedding (Mistral AI)
        β”‚
        β–Ό
 Store Vector (Pinecone)

Shopping Cart Flow

User Login
      β”‚
      β–Ό
Browse Products
      β”‚
      β–Ό
Click Add to Cart
      β”‚
      β–Ό
Authenticate User
      β”‚
      β–Ό
Check Product Availability
      β”‚
      β–Ό
Validate Stock
      β”‚
      β–Ό
Create Cart / Update Existing Cart
      β”‚
      β–Ό
Save Cart in MongoDB
      β”‚
      β–Ό
Return Updated Cart

Semantic Search Flow

User Search Query
        β”‚
        β–Ό
Generate Query Embedding
        β”‚
        β–Ό
Pinecone Similarity Search
        β”‚
        β–Ό
Retrieve Matching Product IDs
        β”‚
        β–Ό
Fetch Products from MongoDB
        β”‚
        β–Ό
Return Relevant Products

Example Search Request

{
  "query": "black oversized cotton t-shirt"
}

Example Search Queries

  • oversized black t-shirt
  • formal white shirt
  • winter hoodie
  • casual streetwear
  • denim jeans
  • cotton summer shirt
  • cargo pants
  • office wear
  • premium men's clothing
  • comfortable everyday clothes

Image Upload

Product images are uploaded to ImageKit.

Only the secure image URL is stored in MongoDB.


Authentication Flow

Register/Login
      β”‚
      β–Ό
Generate JWT
      β”‚
      β–Ό
Store HTTP-only Cookie
      β”‚
      β–Ό
Access Protected APIs

Upcoming Features

  • Order Management
  • Stripe / Razorpay Integration
  • Wishlist
  • AI Shopping Assistant
  • Personalized Product Recommendations
  • Product Filtering & Sorting
  • Pagination
  • Product Reviews & Ratings
  • Admin Dashboard
  • User Profile Management
  • Google OAuth Authentication

Author

Sandeep Choudhary

GitHub: https://github.com/sandeep7348


⭐ If you found this project useful, consider giving it a star on GitHub!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages