A mock API parsing contact information via Gemini API and crossmatching the returned json with postgresql.
A tiny Flask app that takes a free-form text string, sends it to Gemini, and returns a JSON object:
{
"name": "John Smith",
"email": "john.smith@acme.com",
"phone": "555-123-4567",
"found_in_database": false,
"company": null
}
## Prerequisites
* Python **3.10+** (recommended: 3.11 or 3.12)
* A Gemini API key
---
## 1) Clone + create virtual environment
### Windows (PowerShell)
```powershell
git clone <YOUR_REPO_URL>
cd <YOUR_REPO_FOLDER>
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pipgit clone <YOUR_REPO_URL>
cd <YOUR_REPO_FOLDER>
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pipMake sure you have a requirements.txt like this:
flask
python-dotenv
google-genaiThen install:
pip install -r requirements.txtCreate a file named .env in the project root:
GEMINI_API_KEY="YOUR_KEY_HERE"Keep the quotes if you want — both quoted and unquoted values work.
python app.pyYou should see something like:
- Running on
http://127.0.0.1:8000
Open in browser:
http://localhost:8000
- Type something like:
You can reach John Smith at john.smith@acme.com or call him at 555-123-4567 - Click Send
- The JSON response will appear in the output panel.
Returns:
{ "status": "ok" }Send JSON:
{ "text": "Contact Jane Doe at jane.doe@global.com", "llm": "gemini-2.5-flash" }Returns:
{
"name": "Jane Doe",
"email": "jane.doe@global.com",
"phone": null,
"found_in_database": false,
"company": null
}Notes
llmis optional; defaults togemini-2.5-flashtextis required
- Confirm
.envexists in the project root (same folder asapp.py) - Confirm the variable name is exactly:
GEMINI_API_KEY