Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ“ A closed-ecosystem marketplace where every buyer and seller is a verified university student.

Features β€’ Architecture β€’ Tech Stack β€’ Setup β€’ API β€’ Deploy



πŸ”₯ Why UNIMART?

Traditional marketplaces have zero identity verification. Anyone can scam, ghost, or catfish. UNIMART is different.

Problem UNIMART Solution
Anonymous sellers πŸŽ“ Verified students only β€” matched against official university registry
No delivery proof πŸ” OTP handshake β€” buyer confirms receipt with a 6-digit code
Spam & bot accounts πŸ›‘οΈ Email OTP registration β€” only official university emails accepted
No accountability πŸ“‹ Full audit trail β€” every action is logged and traceable
Unsafe transactions 🀝 Campus-only β€” all trades happen between verified peers

✨ Features

πŸ‘€ Student Portal

  • Registry-Verified Signup β€” Only students in the official CSV master registry can create accounts
  • Email OTP Verification β€” Registration requires SMTP-delivered OTP to personal email
  • JWT Auth + Refresh Tokens β€” Secure session management with automatic token refresh
  • Profile Management β€” Avatar upload (Cloudinary), username changes (tracked), personal details
  • Dark/Light Theme β€” Full theme toggle with persistent preference

πŸͺ Marketplace

  • Product Listings β€” Multi-image upload via Cloudinary, 13 curated categories
  • Advanced Filtering β€” Search, category filter, price sort, condition filter
  • Real-Time Status β€” Products auto-transition: AVAILABLE β†’ RESERVED β†’ SOLD_OUT β†’ DELETED
  • Image Cropper β€” Built-in image cropping tool before upload

πŸ“¦ Order System

  • 4-Stage Order Flow β€” PENDING β†’ CONFIRMED β†’ COMPLETED (or CANCELLED)
  • OTP Delivery Verification β€” Seller generates OTP β†’ sent to buyer's email β†’ seller verifies on handoff
  • Cancellation Tracking β€” Reason required, cancelled-by party recorded, product auto-released
  • In-App Chat β€” Per-order messaging between buyer and seller (auto-deletes 24h after completion)

πŸ”” Notifications

  • Real-Time Bell β€” In-app notification center with unread count badge
  • Event-Driven β€” Notifications for order placed, confirmed, cancelled, completed
  • Mark Read/Unread β€” Individual and bulk notification management

πŸ›‘οΈ Admin Panel (Matrix-themed hacker UI)

  • Dashboard Analytics β€” Total users, products, orders, 7-day trends
  • User Management β€” Search, suspend, reinstate, soft-delete users
  • Product Moderation β€” Flag, status override, force-delete with FK cascade
  • Order Override β€” Admin can force-complete or cancel any order
  • Audit Logs β€” Every admin action logged with IP, timestamp, before/after state
  • User Activity Logs β€” Track login, registration, and order events

πŸ—οΈ Architecture

graph TB
    subgraph Frontend["βš›οΈ Frontend β€” React + Vite"]
        LP[Landing Page]
        AUTH[Login / Register]
        DASH[Dashboard]
        HOME[Marketplace]
        SELL[Sell Product]
        ORDERS[Orders + Chat]
        ADMIN[Admin Panel]
    end

    subgraph Backend["⚑ Backend β€” FastAPI"]
        AUTH_R[Auth Router]
        PROD_R[Products Router]
        ORD_R[Orders Router]
        OTP_R[OTP Router]
        CHAT_R[Chat Router]
        NOTIF_R[Notifications Router]
        UPLOAD_R[Upload Router]
        ADM_R[Admin Router]
    end

    subgraph Services["πŸ”§ Services"]
        REDIS[(Redis β€” OTP + Rate Limit)]
        PG[(PostgreSQL β€” Supabase)]
        CLOUD[☁️ Cloudinary β€” Images]
        SMTP[πŸ“§ SMTP β€” Emails]
        SCHED[⏰ APScheduler β€” Cleanup]
    end

    Frontend -->|Axios + JWT| Backend
    AUTH_R --> PG
    AUTH_R --> REDIS
    AUTH_R --> SMTP
    PROD_R --> PG
    ORD_R --> PG
    OTP_R --> REDIS
    OTP_R --> SMTP
    UPLOAD_R --> CLOUD
    SCHED --> PG
    ADM_R --> PG
Loading

πŸ“Š Database Schema

erDiagram
    official_records ||--o| user_profiles : "1:1 FK"
    user_profiles ||--o{ products : "sells"
    user_profiles ||--o{ orders : "buys"
    user_profiles ||--o{ orders : "sells"
    user_profiles ||--o{ notifications : "receives"
    products ||--o{ orders : "has"
    products ||--o{ product_images : "has"
    orders ||--o{ chat_messages : "has"
    admin_accounts ||--o{ admin_audit_logs : "produces"

    official_records {
        string register_number PK
        string full_name
        string university
        string college
        string department
        string official_email
    }

    user_profiles {
        string register_number PK
        string username
        string hashed_password
        string profile_picture_url
        string personal_mail_id
        boolean is_suspended
        boolean is_deleted
    }

    products {
        int id PK
        string seller_register_number FK
        string title
        float price
        string category
        text image_urls
        string product_status
        boolean is_flagged
    }

    orders {
        int id PK
        int product_id FK
        string buyer_register_number FK
        string seller_register_number FK
        string order_status
        string cancelled_by
        text cancellation_reason
    }
Loading

πŸ›  Tech Stack

Frontend

Technology Purpose
React 18 UI framework with hooks and context API
Vite 5 Lightning-fast HMR dev server and build tool
TailwindCSS 3 Utility-first responsive styling
React Router 6 Client-side routing with protected routes
Axios HTTP client with interceptors for JWT refresh
Lucide React Modern icon library

Backend

Technology Purpose
FastAPI Async Python web framework with auto-docs
SQLAlchemy 2 ORM with relationship mapping
PostgreSQL (Supabase) Production database with connection pooling
Redis OTP storage (TTL-based) + sliding-window rate limiting
Cloudinary Image upload, transformation, and CDN delivery
APScheduler Background jobs (sold-product cleanup, chat expiry)
PyJWT + BCrypt JWT token auth + password hashing
Alembic Database migrations
SMTP (smtplib) Transactional emails (OTP, delivery, completion)

πŸš€ Getting Started

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • Redis server running locally or remotely
  • PostgreSQL database (Supabase recommended)
  • Cloudinary account (free tier works)

1️⃣ Clone the Repository

git clone https://github.com/numankhan2007/UNIMART.git
cd UNIMART

2️⃣ Backend Setup

cd backend

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env with your credentials (see .env.example for reference)

# Seed official records (first time only)
python seed_data.py

# Start the server
uvicorn main:app --reload --port 8000

3️⃣ Frontend Setup

cd frontend

# Install dependencies
npm install

# Configure environment
echo "VITE_API_URL=http://localhost:8000" > .env.local

# Start dev server
npm run dev

4️⃣ Access the App

URL Description
http://localhost:5173 🏠 Landing Page
http://localhost:5173/login πŸ” Student Login
http://localhost:5173/admin/login πŸ–₯️ Admin Panel (hidden β€” no UI link)
http://localhost:8000/docs πŸ“– FastAPI Swagger Docs

πŸ“‘ API Reference

Authentication

Method Endpoint Description
GET /api/auth/verify/{register_number} Verify register number exists in registry
POST /api/auth/send-registration-otp Send registration OTP to email
POST /api/auth/verify-registration-otp Verify registration OTP
POST /api/auth/register Register new student account
POST /api/auth/login Login with register number or username
POST /api/auth/refresh Refresh access token
GET /api/auth/profile Get current user profile
PUT /api/auth/profile Update profile (avatar, username, etc.)

Products

Method Endpoint Description
GET /api/products List products (with filters)
POST /api/products Create new product listing
GET /api/products/{id} Get product details
PUT /api/products/{id} Update product
DELETE /api/products/{id} Delete product

Orders

Method Endpoint Description
POST /api/orders Create order (buyer)
GET /api/orders/buyer List buyer's orders
GET /api/orders/seller List seller's orders
PUT /api/orders/{id}/status Update order status
POST /api/orders/{id}/cancel Cancel with reason

OTP Delivery

Method Endpoint Description
POST /api/otp/generate Generate 6-digit delivery OTP
POST /api/otp/send-email Email OTP to buyer
POST /api/otp/verify Verify OTP β†’ complete transaction

Chat & Uploads

Method Endpoint Description
GET /api/chat/{order_id} Get chat messages
POST /api/chat/{order_id} Send chat message
POST /api/upload/image Upload single image
POST /api/upload/images Upload multiple images

Admin (JWT protected)

Method Endpoint Description
POST /api/admin/auth/login Admin login
GET /api/admin/dashboard/stats Dashboard analytics
GET /api/admin/users List/search users
PATCH /api/admin/users/{id} Edit user
POST /api/admin/users/{id}/suspend Suspend user
DELETE /api/admin/products/{id} Force-delete product
PATCH /api/admin/orders/{id}/status Override order status
GET /api/admin/audit-logs View admin audit trail
GET /api/admin/registry List/search student registry
POST /api/admin/registry/import Import CSV to student registry

πŸ”’ Security

Layer Implementation
Password Hashing BCrypt with salt rounds
Authentication JWT access tokens (30min) + refresh tokens
Rate Limiting Redis sliding-window (strict: 5/min for auth, relaxed: 200/min)
OTP Security Redis-only storage (no DB), 10min TTL, 5 max attempts
Image Validation Cloudinary-only URLs allowed (ALLOWED_IMAGE_HOSTS whitelist)
CORS Configurable allowed origins
Input Validation Pydantic v2 field validators on all endpoints
Admin Isolation Separate JWT secret, separate auth context, no UI entry point
Audit Trail Every admin action logged with IP and details
XSS/Clickjack X-Content-Type-Options, X-Frame-Options, Referrer-Policy headers

⏰ Background Jobs

Job Interval Description
Product Cleanup Every 24h Soft-deletes SOLD_OUT products older than 7 days
Chat Cleanup Every 1h Removes chat messages from orders completed 24h+ ago

🌐 Deployment

Frontend β†’ Vercel

cd frontend
npm run build
# Deploy via Vercel CLI or GitHub integration
# vercel.json handles SPA rewrites + security headers

Backend β†’ Render / Railway

# Procfile or start command:
uvicorn main:app --host 0.0.0.0 --port $PORT

Infrastructure Checklist

  • Supabase PostgreSQL provisioned
  • Redis instance (Upstash / Railway Redis)
  • Cloudinary account configured
  • SMTP credentials (Gmail App Password)
  • All SECRET_KEY values are 32+ chars
  • CORS_ORIGINS set to frontend domain
  • APP_ENV=production set
  • Official records CSV seeded

πŸ“ Project Structure

UNIMART/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ main.py                 # FastAPI app entry, lifespan, middleware
β”‚   β”œβ”€β”€ database.py             # SQLAlchemy engine + session
β”‚   β”œβ”€β”€ models.py               # 8 ORM models (User, Product, Order, Chat, etc.)
β”‚   β”œβ”€β”€ schemas.py              # Pydantic request/response schemas
β”‚   β”œβ”€β”€ security.py             # JWT + BCrypt utilities
β”‚   β”œβ”€β”€ dependencies.py         # Auth dependency injection
β”‚   β”œβ”€β”€ settings.py             # Environment helpers
β”‚   β”œβ”€β”€ redis_client.py         # Redis connection manager
β”‚   β”œβ”€β”€ scheduler.py            # APScheduler background jobs
β”‚   β”œβ”€β”€ seed_data.py            # Official records CSV seeder
β”‚   β”œβ”€β”€ admin_auth.py           # Admin JWT + seed logic
β”‚   β”œβ”€β”€ admin_models.py         # AdminAccount + AuditLog models
β”‚   β”œβ”€β”€ admin_schemas.py        # Admin Pydantic schemas
β”‚   β”œβ”€β”€ routers/
β”‚   β”‚   β”œβ”€β”€ auth.py             # Registration, login, profile
β”‚   β”‚   β”œβ”€β”€ products.py         # CRUD + status management
β”‚   β”‚   β”œβ”€β”€ orders.py           # Order lifecycle + cancellation
β”‚   β”‚   β”œβ”€β”€ otp.py              # OTP generate/verify/email
β”‚   β”‚   β”œβ”€β”€ chat.py             # Per-order messaging
β”‚   β”‚   β”œβ”€β”€ notifications.py    # In-app notification system
β”‚   β”‚   β”œβ”€β”€ upload.py           # Cloudinary image uploads
β”‚   β”‚   └── admin.py            # Full admin management suite
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── rate_limit.py       # Redis sliding-window rate limiter
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── email_service.py    # SMTP email templates
β”‚   └── .env.example            # Environment template
β”‚
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.jsx             # Root with providers + routing
β”‚   β”‚   β”œβ”€β”€ pages/              # 14 page components
β”‚   β”‚   β”‚   β”œβ”€β”€ Landing.jsx     # Public landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.jsx       # Student login
β”‚   β”‚   β”‚   β”œβ”€β”€ Register.jsx    # Multi-step registration
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.jsx        # Marketplace browse
β”‚   β”‚   β”‚   β”œβ”€β”€ Dashboard.jsx   # User profile + stats
β”‚   β”‚   β”‚   β”œβ”€β”€ SellProduct.jsx # Product listing form
β”‚   β”‚   β”‚   β”œβ”€β”€ Orders.jsx      # Order management
β”‚   β”‚   β”‚   └── ChatPage.jsx    # Per-order chat
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ common/         # Badge, Button, Modal, Toast, etc.
β”‚   β”‚   β”‚   β”œβ”€β”€ layout/         # Navbar, Footer, MobileNav
β”‚   β”‚   β”‚   β”œβ”€β”€ product/        # ProductCard, Filters, Grid
β”‚   β”‚   β”‚   β”œβ”€β”€ order/          # OTPModal, OrderModal, CancelModal
β”‚   β”‚   β”‚   └── dashboard/      # BuyHistory, SellHistory, MyProducts
β”‚   β”‚   β”œβ”€β”€ admin/              # Standalone admin SPA
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminApp.jsx    # Admin routing
β”‚   β”‚   β”‚   β”œβ”€β”€ pages/          # Dashboard, Users, Products, Orders, AuditLogs
β”‚   β”‚   β”‚   └── components/     # AdminLayout, AdminTable, AdminToast
β”‚   β”‚   β”œβ”€β”€ context/            # Auth, Theme, Order, Chat, Notification
β”‚   β”‚   β”œβ”€β”€ services/           # Axios API client
β”‚   β”‚   β”œβ”€β”€ constants/          # Categories, campuses, order status
β”‚   β”‚   β”œβ”€β”€ hooks/              # useBackNavigation
β”‚   β”‚   └── utils/              # Helper functions
β”‚   β”œβ”€β”€ vercel.json             # Deployment config
β”‚   └── tailwind.config.js      # Theme customization
β”‚
β”œβ”€β”€ LICENSE                     # Apache 2.0
└── README.md                   # You are here

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit your changes: git commit -m "Add amazing feature"
  4. Push to the branch: git push origin feature/amazing-feature
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the Apache License 2.0 β€” see the LICENSE file for details.


Built with πŸ’™ for university students, by university students.

UNIMART Β© 2026 β€’ github.com/numankhan2007/UNIMART

Releases

Packages

Contributors

Languages