Skip to content

jacobalbert3/Jacob_Albert_HappyRobot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Happy Robot Case - Backend

LIVE DEPLOYMENT
https://railway.com/project/50197769-0617-4beb-b7b2-4e11048a7114?environmentId=1725d808-7434-4aab-97a1-ece085b07e5b

SAMPLE REQUESTS
Ready-to-use curl commands: See curl.txt for complete examples

API Routes

Method Endpoint Description Authentication Request Body
GET / Health check endpoint None None
POST /auth/register Register new user None username, email, password
POST /auth/login Login user and get API key None username, password
POST /auth/generate-api-key Generate new API key Required None
GET /loads/ Get all loads Required None
POST /loads/search Search loads by criteria Required origin_city, origin_state, destination_city, destination_state, earliest_time, earliest_time_date, latest_time, latest_time_date
GET /carrier/?mc={mc_number} Check carrier MC number status Required None
POST /call-results/ Create new call result Required load_id, mc_number, duration, result, sentiment, final_price, final_offer
GET /call-results/ Get all call results Required None
GET /booked-loads/ Get successfully booked loads Required None
POST /negotiate-price Negotiate price between offered and negotiated Required offered_price, negotiated_price
POST /populate Populate database with fake load data Required None

Local Development

  1. Create virtual environment:
python3 -m venv .venv
source .venv/bin/activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Set up environment variables:
cp env.example .env

# IMPORTANT -> Edit .env with your actual API keys. You will need database config and FMCSA API key
  1. Run the server:
uvicorn app.main:app --reload
  1. Check if running (replace port)
curl -X GET "http://localhost:8000/"

Production Deployment on Railway

Prerequisites

  • GitHub account
  • Railway account (sign up at railway.app)
  • FMCSA API key (get from FMCSA website)

Step 1: Create Railway Project

  1. Go to railway.app and sign in
  2. Click "New Project"
  3. Select "Deploy from GitHub repo"
  4. Choose your HR-Case repository
  5. Railway will automatically detect it as a Python project

Step 3: Add PostgreSQL Database

  1. In your Railway project dashboard, click "New"
  2. Select "Database" → "PostgreSQL"
  3. Railway will create a PostgreSQL instance
  4. Note the connection details (you'll need these)

Step 4: Configure Environment Variables

  1. In your Railway project, go to the "Variables" tab

  2. Add these environment variables:

    FMCSA_API_KEY=your_fmcsa_api_key_here
    DATABASE_URL= {INSERT shared variable {DATABASE_URL} with Postgres instance }
    

    Note: Railway automatically provides the DATABASE_URL when you add a PostgreSQL service. You can find it in the PostgreSQL service's "Variables" tab.

  3. Optional variables (Railway sets these automatically):

    PORT=8080
    RAILWAY_ENVIRONMENT=production
    

Step 5: Deploy

  1. Railway will automatically deploy when you push to GitHub
  2. Or manually trigger deployment:
    • Go to your service in Railway dashboard
    • Click "Deploy" if needed

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors