Back to Projects

EATS Backend v1

A Ruby on Rails backend for EATS, a food discovery web application developed as a phase 5 project for Flatiron School. This version provides API endpoints and database management for the EATS frontend.

EATS Backend v1

Project Overview

EATS Backend v1 was developed as part of the phase 5 project for Flatiron School in Houston, Texas. This Ruby on Rails application serves as the backend for the EATS food discovery platform, providing API endpoints and database management.

Note: This project is no longer in active development. For the latest version, please see EATS 2024.

Key Features

  • RESTful API: Provides endpoints for food and restaurant data retrieval.
  • Database Management: Handles data persistence for user profiles and restaurant information.
  • Authentication: Implements user authentication and authorization.
  • Environment Configuration: Utilizes environment variables for secure configuration management.

Technologies Used

  • Framework: Ruby on Rails
  • Database: PostgreSQL
  • API Design: RESTful principles
  • Authentication: JWT, Devise

Setup and Installation

To set up the EATS Backend v1 locally:

  1. Clone the repository: git clone https://github.com/sir-udenna/rails-eats-2.git
  2. Navigate to the project directory: cd rails-eats-2
  3. Install dependencies: bundle install
  4. Set up environment variables:
    • Create a .env file in the root directory (use .envEXAMPLE as a template)
    • Configure necessary environment variables (see Environment Variables section)
  5. Set up the database: rails db:create db:migrate
  6. Start the server: rails server

Important: Ensure the backend server is running before starting the frontend application for full functionality.

Available Scripts

  • bundle install: Installs the project's Ruby dependencies.
  • rails server: Starts the backend server.
  • rails db:create db:migrate: Sets up the database.
  • rails db:seed: Populates the database with sample data (if available).

Environment Variables

Configure the following in your .env file:

  • DATABASE_URL: URL for your database connection.
  • SECRET_KEY_BASE: Secret key for securing your application.

API Endpoints

(List and briefly describe the main API endpoints, e.g.:)

  • GET /api/restaurants: Retrieves a list of restaurants.
  • POST /api/users: Creates a new user account.
  • GET /api/users/:id: Retrieves user profile information.

Key Challenges & Solutions

Complex Restaurant Data Relationships

Challenge: Modeling the relationships between users, restaurants, reviews, cuisines, and location data while maintaining query performance as the dataset grew. Solution: Designed a normalized database schema with proper indexing on frequently queried fields. Implemented ActiveRecord associations with careful attention to N+1 query prevention using includes() and joins().

JWT Authentication in Rails API Mode

Challenge: Implementing secure, stateless authentication for a React frontend while learning JWT best practices and Rails API-only configuration. Solution: Built custom JWT authentication middleware with proper token expiration and refresh logic. Implemented secure password hashing with bcrypt and added role-based authorization for different user types.

API Response Time Optimization

Challenge: Restaurant search queries were taking 2-3 seconds with complex filtering and sorting, making the user experience sluggish. Solution: Added database indexes on search fields, implemented Redis caching for popular searches, and optimized SQL queries using Rails query optimization techniques. Reduced average response time to under 500ms.

Environment Configuration Management

Challenge: Managing different configurations for development, testing, and production environments while keeping sensitive data secure. Solution: Implemented comprehensive environment variable management with Rails credentials system. Created separate database configurations and API keys for each environment, with proper fallbacks and validation.

Conclusion

EATS Backend v1 demonstrates my proficiency in building robust backend systems using Ruby on Rails. This project showcases my skills in API development, database design, and backend architecture. While no longer in active development, it served as a crucial component of the EATS ecosystem and laid the groundwork for future iterations of the project.