Skip to content

Leo-codingMaster/fullstack-market-application

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

NYU Campus Marketplace

API CI/CD MongoDB CI/CD Test Coverage

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.

πŸ‘₯ Team

πŸ“‹ Features

  • 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

πŸ—οΈ System Architecture

Two subsystems:

  1. Flask API (services/api/) - Python REST backend

  2. MongoDB (services/mongo/) - Data persistence

πŸš€ Quick Start

Prerequisites

  • Docker and Docker Compose
  • Git

Run with Docker (Recommended)

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 --build

Open http://localhost:5002 in your browser.

Run Locally (Development)

# 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.py

Open http://localhost:5000

βš™οΈ Configuration

Environment Variables

Create .env from .env.example:

cp .env.example .env

Required 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

Database Seeding

MongoDB automatically seeds initial data on startup via services/mongo/initdb/init.js:

  • Sample "Welcome" item
  • Sample "Notebook" item

πŸ§ͺ Testing

Run all tests with coverage reporting:

cd services/api
pytest --cov=. --cov-report=term --cov-report=xml

Verify 80% coverage threshold:

coverage report --fail-under=80

Test Coverage: Authentication, listings, search, messaging, favorites (80%+)

πŸ“‘ API Endpoints

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.

🐳 Docker Images

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:latest

Manual 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/

πŸ”„ CI/CD Pipeline

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-api image 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

πŸ“ Project Structure

β”œβ”€β”€ 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

πŸ”’ Security Notes

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

πŸ› Troubleshooting

Port conflicts?

# Change host port in docker-compose.yml
ports:
  - "5003:5001"  # Use 5003 instead of 5002

MongoDB connection fails?

# Verify MongoDB is running
docker compose ps

# Check logs
docker compose logs mongo

Tests fail locally?

# Use mock database
export USE_MOCK_DB=1
pytest services/api/tests/

πŸ“„ License

GNU General Public License v3.0 - see LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors