Skip to content

stevenhurwitt/fastapi-yelp-postgres

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

45 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Yelp Data Full-Stack Application

A complete full-stack application with FastAPI backend and React frontend for querying real Yelp data from PostgreSQL database.

🌟 Features

Backend (FastAPI)

  • Businesses: Query 150K+ businesses with filtering by city and star rating
  • Reviews: Access 6.9M+ reviews with filtering by business and user
  • Users: Browse 1.9M+ user profiles
  • Tips: Query tips with filtering by business and user
  • Checkins: Access check-in data by business
  • RESTful API: Complete CRUD operations with automatic documentation

Frontend (React + TypeScript)

  • Business Search: Search and filter businesses with modern UI
  • Review Browser: Browse reviews with pagination and filtering
  • Responsive Design: Mobile-friendly interface
  • Real-time Data: Connected to live backend API

πŸš€ Quick Start

Local Development

# Backend
source yelp-fastapi/bin/activate
uvicorn src.main:app --host 192.168.0.123 --port 8000 --reload

# Frontend  
cd frontend
yarn start

AWS Deployment (Production)

# One-command deployment
./deploy-complete.sh

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   React App     β”‚    β”‚   FastAPI       β”‚    β”‚   PostgreSQL    β”‚
β”‚   (Frontend)    │───▢│   (Backend)     │───▢│   (Database)    β”‚
β”‚   S3/CloudFront β”‚    β”‚   Fargate/ECS   β”‚    β”‚   RDS           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’° Hosting Costs

Option Monthly Cost Features
AWS Standard $25-35 Full production setup with ALB
AWS Budget $15-25 Direct Fargate access
AWS Ultra-Budget $8-15 Lambda + RDS (serverless)

πŸ“š Documentation

Project Structure

β”œβ”€β”€ src/                    # FastAPI Backend
β”‚   β”œβ”€β”€ main.py                 # Main FastAPI application
β”‚   β”œβ”€β”€ api/                    # API route handlers
β”‚   β”‚   β”œβ”€β”€ business_routes.py  # Business endpoints
β”‚   β”‚   β”œβ”€β”€ review_routes.py    # Review endpoints
β”‚   β”‚   β”œβ”€β”€ user_routes.py      # User endpoints
β”‚   β”‚   β”œβ”€β”€ tip_routes.py       # Tip endpoints
β”‚   β”‚   └── checkin_routes.py   # Checkin endpoints
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   └── config.py          # Application configuration
β”‚   β”œβ”€β”€ crud/
β”‚   β”‚   └── crud.py            # Database operations
β”‚   β”œβ”€β”€ db/
β”‚   β”‚   β”œβ”€β”€ database.py        # Database connection
β”‚   β”‚   └── models.py          # SQLAlchemy models
β”‚   └── schemas/
β”‚       └── schemas.py         # Pydantic schemas
β”œβ”€β”€ frontend/               # React Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/         # React components
β”‚   β”‚   β”œβ”€β”€ services/           # API service layer
β”‚   β”‚   β”œβ”€β”€ types/              # TypeScript definitions
β”‚   β”‚   └── App.tsx             # Main app component
β”‚   β”œβ”€β”€ public/
β”‚   └── package.json
└── requirements.txt        # Python dependencies

Setup

  1. Install dependencies:
pip install -r requirements.txt
  1. Configure environment variables:
# Copy the example environment file
cp .env.example .env

# Edit .env with your database credentials
DATABASE_HOST=localhost
DATABASE_PORT=5433
DATABASE_USER=your_username
DATABASE_PASSWORD=your_password
DATABASE_NAME=your_database
  1. Run the backend:
# Using uvicorn directly
uvicorn src.main:app --reload --host 192.168.0.123 --port 8000

# Or using the run script
python run.py
  1. Run the frontend (optional):
cd frontend
npm install
npm start

The frontend will be available at http://localhost:3000

API Endpoints

Businesses

  • GET /api/v1/businesses/ - List all businesses
  • GET /api/v1/businesses/{business_id} - Get specific business
  • GET /api/v1/businesses/city/{city} - Get businesses by city
  • GET /api/v1/businesses/stars/{min_stars} - Get businesses with minimum star rating

Reviews

  • GET /api/v1/reviews/ - List all reviews
  • GET /api/v1/reviews/{review_id} - Get specific review
  • GET /api/v1/reviews/business/{business_id} - Get reviews for a business
  • GET /api/v1/reviews/user/{user_id} - Get reviews by a user

Users

  • GET /api/v1/users/ - List all users
  • GET /api/v1/users/{user_id} - Get specific user

Tips

  • GET /api/v1/tips/ - List all tips
  • GET /api/v1/tips/{tip_id} - Get specific tip
  • GET /api/v1/tips/business/{business_id} - Get tips for a business
  • GET /api/v1/tips/user/{user_id} - Get tips by a user

Checkins

  • GET /api/v1/checkins/ - List all checkins
  • GET /api/v1/checkins/{checkin_id} - Get specific checkin
  • GET /api/v1/checkins/business/{business_id} - Get checkins for a business

Query Parameters

Most list endpoints support pagination:

  • skip: Number of records to skip (default: 0)
  • limit: Maximum number of records to return (default: 100)

Example: GET /api/v1/businesses/?skip=0&limit=50

Frontend Features

The React frontend provides:

  • Business Explorer: Search and filter businesses by city and rating
  • Review Browser: Browse reviews with engagement metrics
  • Responsive Design: Works on desktop and mobile
  • Real-time Data: Live connection to the FastAPI backend
  • Modern UI: Clean, intuitive interface with loading states

Frontend Screenshots

  • Business grid with search filters
  • Review cards with star ratings and engagement
  • Responsive mobile design
  • Interactive pagination

Interactive Documentation

Once the server is running, visit:

Interactive Documentation

Once the server is running, visit:

Environment Variables

The application uses the following environment variables (defined in .env file):

Database Configuration

  • DATABASE_HOST: Database host (default: localhost)
  • DATABASE_PORT: Database port (default: 5432)
  • DATABASE_USER: Database username
  • DATABASE_PASSWORD: Database password
  • DATABASE_NAME: Database name

Server Configuration

  • API_HOST: API server host (default: 127.0.0.1)
  • API_PORT: API server port (default: 8000)
  • DEBUG: Debug mode (default: false)

API Information

  • API_TITLE: API title (default: Yelp Data API)
  • API_DESCRIPTION: API description
  • API_VERSION: API version (default: 1.0.0)

Database Schema

The application uses the following PostgreSQL tables:

  • business (business_id, name, address, city, state, postal_code, latitude, longitude, stars, review_count, is_open, attributes, categories, hours)
  • reviews (review_id, user_id, business_id, stars, useful, funny, cool, text, date, year, month)
  • yelp_users (user_id, name, review_count, yelping_since, friends, useful, funny, cool, fans, elite, average_stars, compliment_*)
  • tips (user_id, business_id, text, date, compliment_count, year)
  • checkins (business_id, date)

About

fast api for yelp data stored in postgres

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published