Skip to content

Repository files navigation

ClearStock

An AI-powered marketplace platform that connects sellers with excess inventory to nearby buyers through intelligent dynamic pricing and real-time negotiation.

Problem

Every day, businesses accumulate excess inventory close to expiry. Retailers struggle to move stock quickly. Buyers have no visibility into available discounts. This results in:

  • Significant losses for sellers
  • Wasted resources
  • Missed savings opportunities for buyers

Solution

ClearStock is a B2B/B2C marketplace that:

  • Automatically prices inventory based on expiry timelines using AI
  • Connects nearby buyers and sellers through geospatial matching
  • Enables real-time negotiation with integrated chat and deal requests
  • Streamlines the entire transaction in one unified platform

Key Features

1. AI-Powered Dynamic Pricing

  • Analyzes product category, expiry date, and current price
  • Suggests optimal discount percentages automatically
  • Discount tiers:
    • ≤24 hours to expiry: 80% discount
    • ≤72 hours: 65% discount
    • ≤168 hours (1 week): 55% discount
    • ≤720 hours (1 month): 45% discount
    • ≤2160 hours (3 months): 35% discount
    • 3 months: 25% discount

2. Inventory Listings

  • Sellers create listings with product details, quantity, category, and expiry date
  • Location-based GeoJSON data for geospatial queries
  • Active listings displayed to nearby buyers
  • Seller management dashboard to track and update inventory

3. Geospatial Matching

  • Automatically notifies buyers within 50km radius of relevant deals
  • Location-based filtering reduces irrelevant notifications
  • Supports personalized notification radius preferences (default 15km)

4. Real-Time Deal Negotiation

  • Buyers make offers directly through deal requests
  • Integrated chat system for buyer-seller communication
  • Message history tied to specific deals
  • Quick back-and-forth negotiation without external tools
  • Status tracking: Pending → Accepted/Rejected/Sold/Cancelled

5. Notifications

  • New listing alerts for nearby buyers
  • Deal request notifications for sellers
  • Email and in-app notification options
  • Customizable notification preferences

6. Role-Based Access

  • Sellers: Create listings, manage inventory, respond to offers, negotiate via chat
  • Buyers: Browse listings, make offers, negotiate, close deals
  • Admin: Platform management (in progress)

Tech Stack

Backend

  • Runtime: Node.js
  • Framework: Express.js
  • Database: MongoDB
  • Authentication: JWT (30-day expiration)
  • AI Integration: Google Gemini API
  • Geospatial: MongoDB GeoJSON queries

Frontend

  • Framework: Next.js
  • Styling: Tailwind CSS
  • State Management: Zustand
  • Maps: Mapbox
  • Authentication: Clerk (integrated)

Getting Started

Prerequisites

  • Node.js (v14+)
  • MongoDB instance
  • Google Gemini API key
  • Mapbox API key

Backend Setup

  1. Install dependencies
cd backend
npm install
  1. Configure environment variables (.env)
MONGODB_URI=your_mongodb_url
JWT_SECRET=your_jwt_secret
GEMINI_API_KEY=your_gemini_api_key
MAPBOX_TOKEN=your_mapbox_token
PORT=5000
  1. Start the server
npm run dev

Server runs on http://localhost:5000

Frontend Setup

  1. Install dependencies
cd frontend
npm install
  1. Configure environment variables (.env.local)
NEXT_PUBLIC_API_URL=http://localhost:5000
NEXT_PUBLIC_MAPBOX_TOKEN=your_mapbox_token
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_key
  1. Start the development server
npm run dev

Frontend runs on http://localhost:3000

API Endpoints

Authentication

  • POST /api/auth/register - Create seller/buyer account
  • POST /api/auth/login - Login and get JWT token
  • GET /api/auth/me - Get current user profile

AI Pricing

  • POST /api/ai/check-food-safety - Get price suggestions for inventory

Inventory

  • POST /api/food - Create listing (seller only)
  • GET /api/food - Get all active listings
  • GET /api/food/:id - Get listing details
  • GET /api/food/my/listings - Get seller's listings
  • DELETE /api/food/:id - Delete listing (owner only)

Deal Requests

  • POST /api/requests - Create offer
  • GET /api/requests/my-requests - Get buyer's offers (customer only)
  • GET /api/requests/incoming - Get seller's incoming offers (seller only)
  • PATCH /api/requests/:id/status - Update offer status
  • DELETE /api/requests/:id - Cancel pending offer

Chat

  • POST /api/chat/send - Send message
  • GET /api/chat/:requestId - Get message history

Notifications

  • GET /api/notifications - Get user notifications
  • PATCH /api/notifications/:id/read - Mark notification as read

Workflow Example

  1. Seller registers and logs in
  2. Gets AI price suggestion for excess inventory
  3. Creates listing with suggested price
  4. Buyer nearby receives notification
  5. Buyer makes offer through deal request
  6. Chat negotiation happens in real-time
  7. Deal closes when both parties agree
  8. Status updates tracked for fulfillment

Project Status

Completed

  • User authentication with JWT
  • AI pricing engine with Gemini API
  • Inventory listing management
  • Deal request workflow
  • Real-time chat system
  • Geospatial notifications
  • Role-based access control
  • Error handling and validation
  • MongoDB persistence

In Progress / Future

  • Image upload to cloud storage
  • Payment integration
  • Order fulfillment tracking
  • WebSocket for live chat (currently polling)
  • Advanced search and filters
  • Analytics dashboard
  • Email notification service

Contributing

This is an educational project. Contributions and feedback are welcome.

License

Not specified yet.

Contact

For questions or feedback about ClearStock, please reach out through the project channels.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages