Bathroom Map is a web application that helps users find and review bathrooms in various buildings on NYU's campus. It provides information about bathroom locations, accessibility features, cleanliness ratings, and more.
- Web App: DockerHub - bathroom-map-webapp
- Database: MongoDB Official Image
The Bathroom Map project consists of two main subsystems:
- Web Application (Flask): A Python-based web application built with Flask that provides the API endpoints and web interfaces for users to interact with the bathroom map.
- Database (MongoDB): A MongoDB database that stores information about bathrooms, user reviews, and user accounts.
- Docker and Docker Compose
- Git
-
Clone the repository:
git clone https://github.com/software-students-spring2025/5-final-null cd 5-final-null
-
Create environment variables file:
cp web-app/.env.example web-app/.env
-
Edit the
.env
file with your specific configuration if needed. -
Start the application with Docker Compose:
docker-compose up -d
-
The application will be running at http://localhost:5001
The application requires the following environment variables, which can be set in the .env
file:
FLASK_APP
: Name of the Flask application file (default: app.py)FLASK_ENV
: Environment mode (development/production)MONGO_DBNAME
: Name of the MongoDB database (default: bathroom_map)MONGO_URI
: MongoDB connection URI (default: mongodb://admin:secret@mongo:27017)SECRET_KEY
: Secret key for Flask session encryptionJWT_SECRET_KEY
: Secret key for JWT token generation
Example .env
file:
FLASK_APP=app.py
FLASK_ENV=development
FLASK_PORT=5000
MONGO_DBNAME=bathroom_map
MONGO_URI=mongodb://admin:secret@mongo:27017
SECRET_KEY=development_key_change_in_production
The application automatically initializes the required database collections and indexes on startup. No manual steps are required.
The application provides the following main API endpoints:
POST /api/auth/register
: Register a new userPOST /api/auth/login
: Login a userPOST /api/auth/logout
: Logout a user
GET /api/bathrooms
: Get all bathrooms with optional filteringGET /api/bathrooms/<bathroom_id>
: Get details of a specific bathroomPOST /api/bathrooms
: Create a new bathroom (requires authentication)PUT /api/bathrooms/<bathroom_id>
: Update a bathroom (requires authentication)DELETE /api/bathrooms/<bathroom_id>
: Delete a bathroom (requires authentication)GET /api/bathrooms/nearby
: Find bathrooms near a specific location
GET /api/bathrooms/<bathroom_id>/reviews
: Get all reviews for a bathroomPOST /api/bathrooms/<bathroom_id>/reviews
: Create a new review (requires authentication)GET /api/reviews/<review_id>
: Get a specific reviewPUT /api/reviews/<review_id>
: Update a review (requires authentication)DELETE /api/reviews/<review_id>
: Delete a review (requires authentication)
-
Clone the repository:
git clone https://github.com/software-students-spring2025/5-final-null cd 5-final-null
-
Create environment variables file:
cp web-app/.env.example web-app/.env
-
Edit the
.env
file with your development configuration. -
Build and start the containers using Docker Compose:
docker-compose up -d --build
-
The application will be running at http://localhost:5001
-
View application logs:
docker-compose logs -f web-app
-
To stop the containers:
docker-compose down
If you're actively making changes to the code and want to see changes without rebuilding:
-
Start the MongoDB container only:
docker-compose up -d mongo
-
Create a Python virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies:
cd web-app pip install -r requirements.txt
-
Run the Flask application with hot reloading:
FLASK_ENV=development FLASK_APP=app.py MONGO_URI=mongodb://admin:secret@localhost:27017 flask run --host=0.0.0.0 --port=5001
cd web-app
pytest
To get coverage report:
pytest --cov=.
The application is automatically deployed to Digital Ocean when changes are pushed to the main branch. The deployment process includes:
- Running tests
- Building a Docker image
- Pushing the image to Docker Hub
- Deploying to Digital Ocean
To manually deploy:
- Ensure you have proper access to the Digital Ocean droplet
- SSH into the droplet
- Pull the latest changes and restart the containers:
cd ~/bathroom-map docker-compose pull docker-compose up -d