Skip to content

About

FastAPI service for retrieving and caching college essay prompts by school name. The API combines browser automation, HTML parsing, MongoDB caching, API-key authentication, and request rate limiting into a small admissions-data backend.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

EssayPromptsAPI

FastAPI service for retrieving and caching college essay prompts by school name. The API combines browser automation, HTML parsing, MongoDB caching, API-key authentication, and request rate limiting into a small admissions-data backend.

This project was built as a practical education-technology API: students, counselors, and advising products can request structured essay prompt data instead of manually searching college prompt pages.

Core Features

  • POST /get_essay_prompts/ for one college
  • POST /get_multiple_essay_prompts/ for comma-separated college lists
  • Selenium-driven scraping flow for prompt discovery
  • BeautifulSoup parsing into structured prompt objects
  • MongoDB cache to avoid repeat scraping
  • API-key check through the x-api-key header
  • SlowAPI rate limiting at 5 requests per minute
  • Azure App Service deployment workflow files

Architecture

Client
  -> FastAPI endpoint
  -> API key validation
  -> MongoDB cache lookup
  -> Selenium browser scrape on cache miss
  -> BeautifulSoup prompt extraction
  -> MongoDB insert
  -> JSON response

Example Request

curl -X POST "http://localhost:8000/get_essay_prompts/" \
  -H "Content-Type: application/json" \
  -H "x-api-key: YOUR_API_KEY" \
  -d "{\"college_name\":\"University of Washington\"}"

Example response shape:

{
  "college_name": "University of Washington",
  "prompts": [
    {
      "title": "Prompt title",
      "required": "Required",
      "word_count": "300 words",
      "description": "Prompt text",
      "options": null
    }
  ]
}

Run Locally

Use Python 3.10 or 3.11 for the pinned dependency set.

python -m venv .venv
.venv\Scripts\activate
pip install -r requirements.txt
uvicorn main:app --reload

The code currently uses a placeholder MongoDB URI in main.py:

MongoClient("you_credentials")

For production, move this to an environment variable such as MONGODB_URI and seed valid API keys in the api_keys collection.

Data Model

Each cached college record stores:

{
  "college_name": "School name",
  "prompts": [
    {
      "title": "Prompt title",
      "required": "Required or optional",
      "word_count": "Word count text",
      "description": "Prompt body",
      "options": [
        {
          "option_title": "Option A",
          "option_description": "Option prompt"
        }
      ]
    }
  ]
}

Verification

Current checks performed:

  • python -m py_compile main.py passes
  • Dependencies install from requirements.txt
  • Full import check currently fails on Python 3.12 because fastapi==0.95.2 and pydantic==1.10.7 are not compatible with that runtime

Production Hardening Roadmap

  • Move MongoDB credentials to environment variables
  • Upgrade FastAPI and Pydantic for Python 3.12 compatibility
  • Replace endpoint dependency usage for the rate limiter with the recommended SlowAPI decorator pattern
  • Add pytest coverage for clean_text, parser output, cache hit/miss behavior, and auth failure cases
  • Add a mock scraper fixture so tests do not depend on a live browser or external website
  • Add OpenAPI examples and response schemas
  • Add Dockerfile plus a one-command local MongoDB setup

About

FastAPI service for retrieving and caching college essay prompts by school name. The API combines browser automation, HTML parsing, MongoDB caching, API-key authentication, and request rate limiting into a small admissions-data backend.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages