A full-stack secondhand marketplace for NYU students to buy, sell, and trade campus items. Built with Flask, MongoDB, Docker, and deployed to DigitalOcean App Platform. The intuition we had for this project came from our own experiencesβevery semester, our team members buy textbooks and furniture at the start, but at the end of the semester, we have to discard or waste them. We don't want to waste money or these resources, and we know there are students in the market who really want to buy these secondhand textbooks or items. Current solutions like Facebook Marketplace lack campus context, safety through university verification, and student-specific features. NYU Campus Marketplace solves this by creating a trusted, campus-centric trading platform exclusively for NYU students, featuring NYU email verification, campus-specific filtering (Brooklyn vs Washington Square), course code tagging for textbooks, and suggested meetup points students actually know, like Rogers Hall or Bobst Library.
- Leo Li - Leo Li
- Leo Qian - Leo Qian
- Hanjun Deng - Hanjun Deng
- Leo Fu - Leo Fu
- Kaiyuan Wu - Kaiyuan Wu
- Browse & Search: Filter items by category, campus location, and keywords
- Post Listings: Create listings with images, descriptions, and course codes (for textbooks)
- Messaging: Real-time chat between buyers and sellers
- Favorites: Save items to wishlist
- User Profiles: Manage listings and avatars
- Campus-Specific: NYU Brooklyn/Tandon and Washington Square locations
Two subsystems:
-
Flask API (
services/api/) - Python REST backend- Docker Image (CI): leoli120959/marketplace-api:latest
- Docker Image (App Platform): leoli120959/swap-hub-api:latest
- Port: env
PORT(compose sets 5001 and maps to host 5002; default 5000 if unset)
-
MongoDB (
services/mongo/) - Data persistence- Docker Image: leoli120959/marketplace-mongo:latest
- Port: 27017 (mapped to 27018 on host)
- Docker and Docker Compose
- Git
git clone https://github.com/swe-students-fall2025/5-final-reallyawesome.git
cd 5-final-reallyawesome
# Create environment file
cp .env.example .env
# Start services
docker compose up --buildOpen http://localhost:5002 in your browser.
# Setup Python environment
cd services/api
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -r requirements.txt
# Use mock database for testing
export USE_MOCK_DB=1
# Start Flask dev server
python app.pyCreate .env from .env.example:
cp .env.example .envRequired variables:
| Variable | Description | Default |
|---|---|---|
| MONGO_URI | MongoDB connection string | mongodb://mongo:27017 |
| MONGO_DB | Database name | marketplace |
| PORT | API server port | 5001 |
Optional:
| Variable | Description | Default |
|---|---|---|
| USE_MOCK_DB | Use in-memory DB for testing | 0 |
MongoDB automatically seeds initial data on startup via services/mongo/initdb/init.js:
- Sample "Welcome" item
- Sample "Notebook" item
Run all tests with coverage reporting:
cd services/api
pytest --cov=. --cov-report=term --cov-report=xmlVerify 80% coverage threshold:
coverage report --fail-under=80Test Coverage: Authentication, listings, search, messaging, favorites (80%+)
| Endpoint | Method | Description |
|---|---|---|
/api/health |
GET | Health check |
/api/listings |
GET/POST | Browse/create listings |
/api/auth/register |
POST | Register user |
/api/auth/login |
POST | Login user |
/api/threads |
POST/GET | Create/fetch message threads |
/api/messages |
POST/GET | Send/fetch messages |
/api/favorites |
POST/DELETE/GET | Manage wishlist |
See services/api/app.py for complete endpoint documentation.
Pre-built images available on Docker Hub:
# Pull and run API (App Platform image)
docker pull leoli120959/swap-hub-api:latest
docker run -p 5002:5001 -e PORT=5001 leoli120959/swap-hub-api:latest
# Pull and run MongoDB
docker pull leoli120959/marketplace-mongo:latest
docker run -p 27018:27017 leoli120959/marketplace-mongo:latestManual build:
docker build -f services/api/Dockerfile -t leoli120959/marketplace-api:latest .
docker build -f services/mongo/Dockerfile -t leoli120959/marketplace-mongo:latest services/mongo/GitHub Actions workflows trigger on push/PR to main:
- api.yml: Tests API, builds/pushes Docker image, triggers DigitalOcean App Platform deploy (if DO secrets set)
- mongo.yml: Builds/pushes MongoDB image, triggers DigitalOcean App Platform deploy (if DO secrets set)
- build-push.yml: Builds/pushes
swap-hub-apiimage for App Platform
Required secrets in GitHub:
DOCKERHUB_USERNAME,DOCKERHUB_TOKEN- Docker Hub creds- (Optional deploy)
DO_API_TOKEN,DO_APP_ID- to trigger App Platform redeploy for API - (Optional deploy)
DO_MONGO_APP_ID- to trigger Mongo-related App Platform redeploy MONGO_URI,MONGO_DB- Production MongoDB connection
βββ services/
β βββ api/ # Flask REST API
β β βββ app.py # Main application
β β βββ db.py # MongoDB interface
β β βββ Dockerfile
β β βββ requirements.txt
β β βββ tests/ # Unit tests
β βββ mongo/ # MongoDB setup
β βββ Dockerfile
β βββ initdb/ # Seed data
βββ templates/ # HTML pages
βββ static/ # CSS/JavaScript
βββ docker-compose.yml # Service orchestration
βββ .env.example # Environment template
Demo project - NOT production-ready:
- Passwords stored in plaintext (no bcrypt)
- Session management in memory
- No CSRF protection
- No rate limiting
Production TODO:
- Add bcrypt password hashing
- Use JWT tokens with Redis sessions
- Implement CSRF protection
- Add rate limiting (Flask-Limiter)
- Input validation with Marshmallow
- HTTPS with SSL certificates
Port conflicts?
# Change host port in docker-compose.yml
ports:
- "5003:5001" # Use 5003 instead of 5002MongoDB connection fails?
# Verify MongoDB is running
docker compose ps
# Check logs
docker compose logs mongoTests fail locally?
# Use mock database
export USE_MOCK_DB=1
pytest services/api/tests/GNU General Public License v3.0 - see LICENSE file for details.