Skip to content

alanisawesome2018/Sustainability-project

Repository files navigation

DormDealz - College Marketplace

A full-stack college-based used clothes marketplace where students can buy and sell gently used clothing. Built with FastAPI (Python) backend and Next.js (React/TypeScript) frontend.

Features

πŸ›οΈ Core Functionality

  • Dual Mode Interface: Toggle between buyer and seller modes
  • Product Listings: Upload multiple photos, detailed descriptions, and pricing
  • Search & Filter: Find items by category, condition, price range, and keywords
  • Real-time Chat: Direct messaging between buyers and sellers
  • Dummy Payment System: Simulated credit card checkout flow
  • Order Management: Track purchases and sales with order status updates

πŸ” Authentication

  • User registration and login (imported from email product)
  • JWT-based authentication
  • Profile management with college affiliation

πŸ’¬ Communication

  • Real-time chat system (Alibaba-style)
  • Conversation history
  • Unread message notifications
  • Product-specific inquiries

πŸ“¦ Product Management

  • Create, read, update, delete listings
  • Multiple image uploads (up to 5 per product)
  • Category and condition filtering
  • View counts and seller statistics

Tech Stack

Backend

  • FastAPI: Modern Python web framework
  • SQLAlchemy: ORM for database operations
  • SQLite: Lightweight database (easily switchable to PostgreSQL)
  • JWT: Token-based authentication
  • Bcrypt: Password hashing
  • Pydantic: Data validation

Frontend

  • Next.js 14: React framework with App Router
  • TypeScript: Type-safe JavaScript
  • Tailwind CSS: Utility-first CSS framework
  • Axios: HTTP client
  • React Hook Form: Form management
  • React Hot Toast: Notifications
  • Lucide React: Icon library

Project Structure

Sustainability project/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ routers/
β”‚   β”‚   β”œβ”€β”€ auth.py          # Authentication endpoints
β”‚   β”‚   β”œβ”€β”€ products.py      # Product CRUD operations
β”‚   β”‚   β”œβ”€β”€ orders.py        # Order management & payments
β”‚   β”‚   └── messages.py      # Chat system
β”‚   β”œβ”€β”€ auth.py              # Auth utilities
β”‚   β”œβ”€β”€ config.py            # Configuration
β”‚   β”œβ”€β”€ database.py          # Database connection
β”‚   β”œβ”€β”€ models.py            # SQLAlchemy models
β”‚   β”œβ”€β”€ schemas.py           # Pydantic schemas
β”‚   β”œβ”€β”€ main.py              # FastAPI application
β”‚   └── init_db.py           # Database initialization
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ login/           # Login page
β”‚   β”‚   β”œβ”€β”€ register/        # Registration page
β”‚   β”‚   β”œβ”€β”€ marketplace/     # Main marketplace
β”‚   β”‚   β”‚   β”œβ”€β”€ add-product/ # Product creation
β”‚   β”‚   β”‚   β”œβ”€β”€ product/[id]/# Product detail
β”‚   β”‚   β”‚   β”œβ”€β”€ checkout/[id]/# Checkout flow
β”‚   β”‚   β”‚   β”œβ”€β”€ messages/    # Chat interface
β”‚   β”‚   β”‚   └── orders/      # Order history
β”‚   β”‚   └── page.tsx         # Landing page
β”‚   └── lib/
β”‚       β”œβ”€β”€ api.ts           # API client
β”‚       └── auth.ts          # Auth utilities
β”œβ”€β”€ requirements.txt         # Python dependencies
└── README.md

Setup Instructions

Prerequisites

  • Python 3.10+
  • Node.js 18+
  • npm or yarn

Backend Setup

  1. Navigate to project directory:

    cd "/Users/jb/Desktop/pastor_ai/Sustainability project"
  2. Create and activate virtual environment:

    python3 -m venv venv
    source venv/bin/activate  # On Windows: venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt
  4. Create environment file:

    cp .env.example .env

    Note: Email configuration is optional and currently disabled

  5. Initialize database:

    python -m backend.init_db
  6. Run backend server:

    uvicorn backend.main:app --reload --port 8000

    Backend will be available at: http://localhost:8000 API docs: http://localhost:8000/docs

Frontend Setup

  1. Navigate to frontend directory:

    cd frontend
  2. Install dependencies:

    npm install
  3. Create environment file:

    cp .env.local.example .env.local
  4. Run development server:

    npm run dev

    Frontend will be available at: http://localhost:3000

Usage Guide

For Buyers

  1. Register/Login: Create an account with your college email
  2. Browse Products: View all available items on the marketplace
  3. Search & Filter: Use search bar and filters to find specific items
  4. View Details: Click on products to see full details and photos
  5. Contact Seller: Message sellers directly to ask questions
  6. Purchase: Click "Buy Now" and complete checkout with dummy credit card
  7. Track Orders: View purchase history in Orders section

For Sellers

  1. Toggle to Sell Mode: Use the Buy/Sell toggle in the header
  2. Add Product: Click "Add New Product" button
    • Upload 1-5 photos
    • Add title, description, price
    • Select category, condition, size, brand
  3. Manage Listings: View all your products and their status
  4. Respond to Messages: Chat with interested buyers
  5. Update Order Status: Mark orders as shipped/delivered
  6. Track Sales: View sales history and statistics

Dummy Payment

  • Use any 16-digit number as a credit card
  • Example: 1234 5678 9012 3456
  • All payments are simulated and will succeed

API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login user
  • GET /api/auth/me - Get current user info
  • PUT /api/auth/me - Update profile

Products

  • GET /api/products/ - List all products (with filters)
  • GET /api/products/{id} - Get product details
  • GET /api/products/my-products - Get user's listings
  • POST /api/products/ - Create new product
  • PUT /api/products/{id} - Update product
  • DELETE /api/products/{id} - Delete product

Orders

  • POST /api/orders/ - Create order (purchase)
  • GET /api/orders/my-purchases - Get purchase history
  • GET /api/orders/my-sales - Get sales history
  • PUT /api/orders/{id}/status - Update order status

Messages

  • POST /api/messages/ - Send message
  • GET /api/messages/conversations - Get all conversations
  • GET /api/messages/with/{user_id} - Get messages with user
  • GET /api/messages/unread-count - Get unread count

Features Comparison with Alibaba

βœ… Buyer and seller modes βœ… Product listings with images βœ… Direct chat between buyers and sellers βœ… Search and filtering βœ… Order management βœ… User profiles βœ… Payment processing (dummy)

Future Enhancements

  • Email verification (currently disabled)
  • Real payment gateway integration (Stripe, PayPal)
  • Image optimization and CDN
  • Push notifications
  • Rating and review system
  • College-based filtering
  • Advanced search with Elasticsearch
  • Mobile app (React Native)
  • Real-time WebSocket chat
  • Admin dashboard

Troubleshooting

Backend Issues

  • Import errors: Make sure you're in the project root and virtual environment is activated
  • Database errors: Delete marketplace.db and run python -m backend.init_db again
  • Port already in use: Change port in uvicorn command

Frontend Issues

  • Module not found: Run npm install again
  • API connection failed: Ensure backend is running on port 8000
  • Image upload fails: Check uploads/ directory exists

Development Notes

  • Authentication logic imported from email product as requested
  • Email verification temporarily disabled (email config left blank)
  • SQLite used for easy setup (production should use PostgreSQL)
  • Images stored locally (production should use cloud storage like AWS S3)
  • Chat polling every 3 seconds (production should use WebSockets)

License

MIT License - Feel free to use for educational purposes

Support

For issues or questions, please check the troubleshooting section or review the API documentation at http://localhost:8000/docs


Built with ❀️ for college sustainability

About

Amherst College Hackathon Project

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors