An intelligent API that transforms natural language questions into optimized SQL queries over the Northwind (MySQL) database, using language models (LLMs), semantic validation, and RAG (retrieval-augmented generation).
- ✨ Overview
- 🧠 Technologies Used
- 🧱 Architecture
- 🚀 How to Run Locally
- 🔐 Environment Variables
- 📡 API Endpoints
- 📊 Usage Examples
- 🧪 Tests
- ☁️ Cloud Deployment (CI/CD)
- 📎 References
FinTechX faces challenges such as:
- Low personalization in customer service
- Complex processes
- Limited predictive and analytical capabilities
An LLM-powered API that:
- Interprets human questions
- Generates secure and explainable SQL
- Returns data and insights with high performance
| Category | Technology |
|---|---|
| Backend API | FastAPI |
| Database | MySQL (Northwind) |
| LLM | OpenAI GPT-4 |
| Vector Search (RAG) | FAISS (optional) |
| Cache | Redis (optional) |
| SQL Validation | sqlglot, sqlvalidator |
| Frontend (optional) | Streamlit |
| Testing | Pytest / Postman |
| CI/CD | GitHub Actions / Render |
User → FastAPI → GPT-4 → SQL Generation → SQL Validation → MySQL (Northwind)
↑ ↓
RAG / Cache Data + Explanation
- Modular architecture (following SOLID principles)
- Clear separation of responsibilities (services, repositories, schemas)
- Extensible for metrics, security, and visual frontend
git clone https://github.com/iarlenaquiles/fintechx.git
cd fintechxpython -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windowspip install -r requirements.txtCreate a .env file in the project root or copy from .env.example:
OPENAI_API_KEY=sk-...
DATABASE_HOST=northwind-mysql-db.ccghzwgwh2c7.us-east-1.rds.amazonaws.com
DATABASE_USERNAME=user_read_only
DATABASE_PASSWORD=laborit_teste_2789
DATABASE_NAME=northwinduvicorn app.main:app --reloadAccess Swagger documentation at:
| Name | Description |
|---|---|
| OPENAI_API_KEY | OpenAI API key |
| DATABASE_HOST | MySQL database host |
| DATABASE_USERNAME | Read-only database user |
| DATABASE_PASSWORD | Database password |
| DATABASE_NAME | Database name (northwind) |
Query the database using natural language.
{
"question": "What are the best-selling products?"
}{
"sql": "...",
"data": [...],
"explanation": "Query created to retrieve the best-selling products by quantity."
}Which products are the most popular among corporate customers?
What is the sales volume by city?
Which customers made the most purchases?
What is the average ticket per purchase?
pytest tests/Or import the Postman collection located at:
tests/FinTechX.postman_collection.json
- Dockerfile included (optional)
- Deploy on Render or Railway
render.yamlfor automatic CI/CD- GitHub Actions (
.github/workflows/deploy.yml)
- FastAPI Documentation
- Northwind Database Schema
- OpenAI API
- LangChain
- RAG Pattern
git clone <REPOSITORY_URL>
cd <REPOSITORY_NAME>docker compose up --buildhttp://localhost:8000
docker compose down