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 |
- 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
- 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
- 4-Stage Order Flow β
PENDING β CONFIRMED β COMPLETED(orCANCELLED) - 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)
- 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
- 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
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
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
}
| 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 |
| 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) |
- Python 3.10+
- Node.js 18+
- Redis server running locally or remotely
- PostgreSQL database (Supabase recommended)
- Cloudinary account (free tier works)
git clone https://github.com/numankhan2007/UNIMART.git
cd UNIMARTcd 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 8000cd frontend
# Install dependencies
npm install
# Configure environment
echo "VITE_API_URL=http://localhost:8000" > .env.local
# Start dev server
npm run dev| 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 |
| 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.) |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
cd frontend
npm run build
# Deploy via Vercel CLI or GitHub integration
# vercel.json handles SPA rewrites + security headers# Procfile or start command:
uvicorn main:app --host 0.0.0.0 --port $PORT- Supabase PostgreSQL provisioned
- Redis instance (Upstash / Railway Redis)
- Cloudinary account configured
- SMTP credentials (Gmail App Password)
- All
SECRET_KEYvalues are 32+ chars -
CORS_ORIGINSset to frontend domain -
APP_ENV=productionset - Official records CSV seeded
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
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m "Add amazing feature" - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
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