Skip to content

Phoenixlazim/MockAPI

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MockAPI

A mock API parsing contact information via Gemini API and crossmatching the returned json with postgresql.

Contact Parser (Gemini → JSON)

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 pip

macOS / Linux

git clone <YOUR_REPO_URL>
cd <YOUR_REPO_FOLDER>

python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip

2) Install dependencies

Make sure you have a requirements.txt like this:

flask
python-dotenv
google-genai

Then install:

Windows / macOS / Linux

pip install -r requirements.txt

3) Create .env

Create 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.


4) Run the server

Windows / macOS / Linux

python app.py

You should see something like:

  • Running on http://127.0.0.1:8000

Open in browser:

  • http://localhost:8000

5) Using the UI

  • 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.

API

GET /health

Returns:

{ "status": "ok" }

POST /parse

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

  • llm is optional; defaults to gemini-2.5-flash
  • text is required

Common problems

“Missing GEMINI_API_KEY”

  • Confirm .env exists in the project root (same folder as app.py)
  • Confirm the variable name is exactly: GEMINI_API_KEY

About

A mock API parsing contact information via Gemini API and crossmatching the returned json with postgresql.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • Python 46.9%
  • CSS 26.9%
  • JavaScript 13.8%
  • HTML 12.4%