This project scrapes apartment floorplan data from various websites and provides a visual representation of one-bedroom apartments, categorizing them based on price and size.
- React: Frontend library used for building the user interface.
- Recharts: React-based charting library used to create scatter plots.
- Flask: A lightweight backend framework in Python to handle API requests and serve apartment data.
- PostgreSQL: The relational database used to store apartment and complex details.
- Beautiful Soup: A Python library for web scraping to pull data from apartment websites.
- APScheduler: A Python job scheduling library, used to run the scraping task daily.
- dotenv: A library to load environment variables from an
.envfile.
-
Web Scraping: The
scrape.pyscript fetches apartment details such as floorplan name, available units, bedrooms, bathrooms, size, availability date, and price from predefined URLs. Data validation functions ensure only meaningful data is considered. -
Data Storage: The scraped data is inserted into a PostgreSQL database, which has two main tables:
apartmentsandcomplexes. Complex data is referenced in the apartment table using foreign keys. Duplication is avoided by having unique constraints in place. -
API Endpoints:
/api/apartments: Fetches apartment data by joining theapartmentsandcomplexestables.- Test this
GETrequest using:curl http://127.0.0.1:5000/api/apartments
-
Frontend (React):
- Fetches data from the Flask API upon loading.
- Filters and formats the data for 1-bedroom apartments.
- Displays the data on a scatter plot where the x-axis represents the size (square footage) and the y-axis represents the price. Each apartment complex is color-coded, and hovering over a point provides more details about the apartment.
-
Background Task: A daily scraping task is scheduled using APScheduler.
- Environment Variables: The project uses environment variables (stored in
.envfile) to securely handle database credentials. - Database: The PostgreSQL database must be set up with the name
apartments_db, and the necessary tables (apartmentsandcomplexes) will be created by the scripts if they don't exist.
- Start the Flask backend: python app.py
- Start the React frontend: npm start