Skip to content

Ape108/USDAChatBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

USDA Rural Opportunity Navigator 🚜

Overview

USDA Rural Opportunity Navigator is an AI-powered chatbot and analytics platform designed to connect rural Americans with crucial USDA Rural Development resources. Built in 24 hours for the HackMidwest-USDAChallenge, our solution leverages advanced web scraping, MongoDB vector search, and a Retrieval-Augmented Generation (RAG) model to deliver accurate, context-aware answers about USDA programs.

In addition to the chatbot, we provide a customizable, USDA-facing data analytics dashboard. This tool offers actionable insights from user interaction data, helping the agency better understand community needs and resource engagement.


Features

  • Conversational AI Chatbot: Answers questions about USDA Rural Development programs using RAG and OpenAI models.
  • Web Scraping Pipeline: Extracts and updates USDA.gov program data for the knowledge base.
  • MongoDB Vector Search: Enables semantic retrieval of relevant program info.
  • Data Analytics Dashboard: Visualizes user engagement, satisfaction, and trending topics for USDA analysts.
  • Location-Aware Matching: Suggests state-specific resources based on user location.

Architecture

┌────────────┐     ┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│  Frontend  │ <-> │ FastAPI API  │ <-> │ MongoDB Atlas│ <-> │ Web Scraper  │
│ (React)    │     │ (Python)     │     │ (Vector DB)  │     │ (Python)     │
└────────────┘     └──────────────┘     └──────────────┘     └──────────────┘
        │
        ▼
┌────────────────────────────┐
│ Data Analytics Dashboard   │
│ (React + Plotly)          │
└────────────────────────────┘

Quickstart

1. Clone the Repo

git clone https://github.com/Ape108/USDAChatBot.git
cd USDAChatBot

2. Backend Setup (Python)

a. Create & Activate Virtual Environment

./scripts/setup_venv.sh
source .venv/bin/activate

b. Install Dependencies

pip install -r backend/requirements.txt

c. Set Environment Variables

Create a .env file in backend/ with:

OPENAI_API_KEY=your-openai-key
MONGO_URI=your-mongodb-uri

d. Run the API Server

cd backend
uvicorn main_backend:app --reload

3. Frontend Setup (React + Vite)

cd frontend
npm install
npm run dev

The app will be available at http://localhost:5173 by default.


Components

Chatbot (AI + RAG)

  • Backend: backend/main_backend.py, backend/usda_chat_api.py, backend/AItester/usda_vector_search.py
  • Frontend: frontend/src/components/Chatbot/Chatbot.jsx
  • Vector Search: Uses OpenAI embeddings + MongoDB Atlas for semantic retrieval.

Data Analytics Dashboard

  • Backend: backend/data-analytics/
    • Loads and processes chatbot_interaction_data.csv
    • Generates interactive Plotly visualizations (KPIs, trends, maps, satisfaction, etc.)
  • Frontend: frontend/src/components/Dashboard/Dashboard.jsx

Web Scraper

  • Scripts: backend/webscraper/
    • Scrapes USDA.gov sitemaps and program pages
    • Populates MongoDB with up-to-date program info and embeddings

Data & Documentation


Example User Data Schema

See backend/data-analytics/chatbot_interaction_data.csv for sample fields:

session_id user_id timestamp user_location_state user_query bot_response_summary user_feedback topic_category
SESS001 USER112 2025-10-01T08:05:30Z TX I need a loan... Provided an overview... 1 Economic Development

Contributing

Pull requests and feedback are welcome! For major changes, please open an issue first to discuss what you would like to change.


License

This project is for demonstration purposes at CrackMidwest 2025. See individual files for third-party licenses.

About

AI-powered chatbot and analytics dashboard connecting rural Americans with USDA Rural Development resources. Built with RAG, MongoDB vector search, and real user insights.

Resources

Stars

Watchers

Forks

Contributors