Welcome to the practice problem! This exercise will help you get familiar with the hackathon workflow, tooling, and evaluation process before tackling the main challenge.
Build a REST API that:
- Extracts structured contact information from natural language text using an LLM
- Validates the extracted contact against a database to check if they exist
Input: A natural language sentence containing contact details Output: Structured JSON with extracted fields + database validation
Request:
{
"text": "You can reach John Smith at john.smith@acme.com or call him at 555-123-4567",
"llm": "gpt-4o-mini"
}Response:
{
"name": "John Smith",
"email": "john.smith@acme.com",
"phone": "555-123-4567",
"found_in_database": true,
"company": "Acme Corporation"
}If the contact is NOT found in the database:
{
"name": "Unknown Person",
"email": "unknown@test.com",
"phone": "555-000-0000",
"found_in_database": false,
"company": null
}Your API may support one or more of these LLM options (passed in the llm field):
gemini-2.5-flashgemini-2.5-flash-previewgpt-4o-mini
Recommendation: Use a Gemini model (preferably gemini-2.5-flash) unless you have a specific reason to use GPT.
You will need an API key for the provider backing the model you use:
- Gemini: Create/manage keys in Google AI Studio
Documentation: Using Gemini API keys - OpenAI (GPT): Create/manage keys in the OpenAI API dashboard
Documentation: Developer quickstart
Store keys in environment variables and do not commit them to git.
Work through these checkpoints to build your solution step by step.
You can run the database using Docker (recommended) or locally.
- Make sure you have Docker installed
- Start the provided services:
docker-compose up -d
- Verify PostgreSQL is running:
docker exec -it practice_db psql -U postgres -d practice_db -c "SELECT 'Hello, Database!';"
- Open pgweb to explore the database: http://localhost:8082
- Install PostgreSQL and make sure the
psqlCLI is available - Create the database (example):
createdb -U postgres practice_db
- Load the schema + seed data from
data/init.sql:psql -U postgres -d practice_db -f data/init.sql
- Verify it worked:
psql -U postgres -d practice_db -c "SELECT 'Hello, Database!';"
You can use any PostgreSQL client (pgAdmin, DBeaver, etc.) to inspect the data.
Why a database? While this practice problem doesn't require database queries, the main hackathon will. This checkpoint ensures your database setup works correctly.
Connect to the database and explore the schema:
# Docker:
docker exec -it practice_db psql -U postgres -d practice_db
# Local:
psql -U postgres -d practice_dbRun these commands:
\dt -- List all tables
SELECT * FROM contacts; -- View sample contacts
SELECT * FROM companies; -- View sample companiesNote the contacts in the database - your API will need to check if extracted contacts exist here!
Create a REST API with the following endpoint:
POST /parse
Request body:
{
"text": "Contact Jane Doe at jane.doe@global.com, phone: 555-234-5678",
"llm": "gpt-4o-mini"
}Response:
{
"name": "Jane Doe",
"email": "jane.doe@global.com",
"phone": "555-234-5678",
"found_in_database": true,
"company": "Global Industries"
}Requirements:
- Use the specified LLM to extract
name,email, andphonefrom the text - Query the database to check if a contact with that name exists
- If found, set
found_in_database: trueand include theircompany - If not found, set
found_in_database: falseandcompany: null - If a field is not present in the text, return
nullfor that field
Health Check Endpoint:
GET /health
Response:
{
"status": "ok",
"database": "connected"
}The key skill here is getting the LLM to return properly structured JSON. Tips:
- Use system prompts to instruct the LLM on the exact output format
- Use JSON mode if the LLM API supports it (e.g., OpenAI's
response_format) - Validate the response before returning it to ensure it matches the expected schema
Example system prompt:
Extract contact information from the given text.
Return a JSON object with these fields:
- name: The person's full name (string or null)
- email: The email address (string or null)
- phone: The phone number (string or null)
Return ONLY the JSON object, no other text.
Once your server is running, test it against our test cases:
# Make sure your server is running on port 8000
python checker/checker.py --url http://localhost:8000The checker will:
- Send test requests to your
/parseendpoint - Compare your responses against expected outputs
- Report how many tests passed
Goal: Pass all test cases before moving to the main challenge!
Parses contact information from natural language text and validates against database.
Request:
| Field | Type | Required | Description |
|---|---|---|---|
| text | string | Yes | Natural language text containing contact info |
| llm | string | Yes | LLM to use: gemini-2.5-flash, gemini-2.5-flash-preview, or gpt-4o-mini |
API keys: If you select a Gemini model, you’ll need a Gemini API key. If you select a GPT model, you’ll need an OpenAI API key.
- Gemini key docs: Using Gemini API keys
- OpenAI key dashboard: OpenAI API keys
Response:
| Field | Type | Description |
|---|---|---|
| name | string|null | Extracted full name |
| string|null | Extracted email address | |
| phone | string|null | Extracted phone number |
| found_in_database | boolean | Whether the contact was found in database |
| company | string|null | Company name if found, otherwise null |
Health check endpoint.
Response:
| Field | Type | Description |
|---|---|---|
| status | string | Should be "ok" |
| database | string | Should be "connected" |
mock-problem/
├── README.md # This file
├── docker-compose.yml # Docker services configuration
├── data/
│ └── init.sql # Database initialization script
└── checker/
├── checker.py # Test runner script
└── test_cases.json # Test cases
- Start simple - Get a basic endpoint working before adding LLM integration
- Test incrementally - Run the checker after each change
- Handle edge cases - What if the text has no email? No phone?
- Check your JSON - Make sure field names match exactly (
name, notName)
Good luck!