Skip to content

Commit 255ca4d

Browse files
committed
frontend ui updated and readme files
1 parent ce5116d commit 255ca4d

12 files changed

Lines changed: 416 additions & 687 deletions

File tree

README.md

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,32 @@
11
# AskSQL AI
22

3-
Convert your natural language questions into executable SQL queries using Google Gemini AI. Features a modern glass-morphism UI built with React and a robust FastAPI backend.
3+
Convert natural language questions into PostgreSQL queries with a heavy-duty, premium AI-powered interface.
44

55
## 🚀 Features
66

7-
- **NL to SQL**: Translate complex questions into PostgreSQL queries.
8-
- **Auto Schema Loading**: Automatically fetches your database schema to provide context to the AI.
9-
- **Safe Execution**: Only permits `SELECT` queries to ensure database safety.
10-
- **Schema Management**: Create new tables directly from the UI.
11-
- **Glass-morphism UI**: Beautiful, responsive blue & white theme.
7+
- **Intuitive NL to SQL**: Powered by Gemini 2.5 Flash for high accuracy.
8+
- **Midnight Sapphire UI**: Ultra-premium dark theme with advanced glassmorphism.
9+
- **Live Database Connection**: Automatically reflects your current schema.
10+
- **Dynamic Schema Creator**: Create tables with support for **TEXT, INTEGER, FLOAT, TIMESTAMP, and DATE**.
11+
- **Execution Safety**: Strict read-only validation blocks destructive commands.
1212

1313
## 🛠️ Tech Stack
1414

15-
- **Backend**: FastAPI, PostgreSQL, google-genai SDK.
16-
- **Frontend**: React (Vite), TypeScript, Custom CSS.
17-
- **Deployment**: Docker, Docker Compose.
18-
- **AI**: Gemini 1.5 Flash.
15+
- **Frontend**: React 18, Vite, TypeScript, Custom CSS (Midnight theme).
16+
- **Backend**: FastAPI, PostgreSQL, Google GenAI SDK.
17+
- **Orchestration**: Docker & Docker Compose.
1918

20-
## 📦 Getting Started
19+
## 📦 Quick Start
2120

22-
### Prerequisites
23-
24-
- Docker and Docker Compose
25-
- Google Gemini API Key (Get one [here](https://makersuite.google.com/))
26-
27-
### Configuration
28-
29-
1. Create a `.env` file in the `backend/` directory (you can copy `.env.example`):
21+
1. **API Key**: Get a Gemini API key from [Google AI Studio](https://aistudio.google.com/).
22+
2. **Environment**: Add your keys and DB config to `backend/.env`.
23+
3. **Run**:
3024
```bash
31-
GEMINI_API_KEY=your_key_here
32-
DB_HOST=db
33-
DB_NAME=asksql
34-
DB_USER=postgres
35-
DB_PASSWORD=postgres
25+
docker-compose up --build
3626
```
3727

38-
### Running with Docker
39-
40-
```bash
41-
docker-compose up --build
42-
```
43-
44-
- **Frontend**: [http://localhost:3000](http://localhost:3000)
45-
- **Backend API**: [http://localhost:8000](http://localhost:8000)
46-
- **API Docs**: [http://localhost:8000/docs](http://localhost:8000/docs)
47-
48-
## 📁 Project Structure
49-
50-
- `backend/`: FastAPI application.
51-
- `app/api/`: API endpoints (`query`, `schema`).
52-
- `app/services/`: Business logic (SQL generation, execution, validation).
53-
- `app/schemas/`: Pydantic models.
54-
- `frontend/`: React application.
55-
- `src/components/`: Reusable UI components (ResultDisplay, SchemaCreator, etc.).
56-
- `src/index.css`: Core design system & glass-morphism styles.
28+
Access the app at: `http://localhost:3000`
5729

5830
## 🔒 Security
5931

60-
Matches are restricted to `SELECT` statements. The `sql_validator` service blocks any keywords like `DROP`, `DELETE`, or `UPDATE` during natural language query processing.
32+
All generated SQL queries are parsed for restricted keywords (`DROP`, `DELETE`, etc.) before execution to ensure a read-only experience for the AI.

backend/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# AskSQL AI - Backend
2+
3+
FastAPI service handling NL to SQL conversion, schema exploration, and safe query execution.
4+
5+
## 🚀 Key Features
6+
- **GenAI Integration**: Uses Gemini 1.5 Flash with optimized system instructions.
7+
- **SQL Guardrails**: Custom validator blocks non-SELECT statements.
8+
- **Schema Reflection**: Real-time introspection of the `public` schema.
9+
- **Table Creator**: Support for common PostgreSQL types (`INT`, `TEXT`, `REAL`, etc).
10+
11+
## 🛠️ Technical Details
12+
- **Framework**: FastAPI
13+
- **DB Driver**: Psycopg2
14+
- **Validation**: Pydantic v2
15+
- **AI**: Google Generative AI
16+
17+
## 🔧 Local Development
18+
19+
1. **Install**: `pip install -r requirements.txt`
20+
2. **Env**: Set `GEMINI_API_KEY` and DB credentials in `.env`.
21+
3. **Run**: `uvicorn main:app --reload`

backend/app/services/schema_creator.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,13 @@
33

44
ALLOWED_TYPES = {
55
"text": "TEXT",
6+
"string": "TEXT",
67
"int": "INTEGER",
8+
"integer": "INTEGER",
9+
"number": "REAL",
710
"float": "REAL",
811
"timestamp": "TIMESTAMP",
12+
"date": "TIMESTAMP",
913
}
1014

1115

frontend/README.md

Lines changed: 15 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,19 @@
1-
# React + TypeScript + Vite
1+
# AskSQL AI - Frontend
22

3-
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
3+
A high-performance React frontend featuring a premium "Midnight Sapphire" glassmorphism aesthetic.
44

5-
Currently, two official plugins are available:
5+
## 🎨 Design System
6+
- **Midnight Deep**: Dark mode by default for high visual comfort.
7+
- **Glassmorphism**: 25px blur with subtle white borders.
8+
- **Electric Accents**: Vibrant blues and cyans for interactive elements.
9+
- **Typeface**: 'Outfit' for titles, 'JetBrains Mono' for code.
610

7-
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
8-
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
11+
## 🚀 Highlights
12+
- **Schema Explorer**: Visual modal to browse existing tables and columns.
13+
- **Table Architect**: GUI for creating new tables (supports `int`, `text`, `float`, etc).
14+
- **Result Playground**: High-contrast tables and syntax-highlighted SQL view.
15+
- **Centralized API**: Typed service layer for all backend communications.
916

10-
## React Compiler
11-
12-
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
13-
14-
## Expanding the ESLint configuration
15-
16-
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
17-
18-
```js
19-
export default defineConfig([
20-
globalIgnores(['dist']),
21-
{
22-
files: ['**/*.{ts,tsx}'],
23-
extends: [
24-
// Other configs...
25-
26-
// Remove tseslint.configs.recommended and replace with this
27-
tseslint.configs.recommendedTypeChecked,
28-
// Alternatively, use this for stricter rules
29-
tseslint.configs.strictTypeChecked,
30-
// Optionally, add this for stylistic rules
31-
tseslint.configs.stylisticTypeChecked,
32-
33-
// Other configs...
34-
],
35-
languageOptions: {
36-
parserOptions: {
37-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
38-
tsconfigRootDir: import.meta.dirname,
39-
},
40-
// other options...
41-
},
42-
},
43-
])
44-
```
45-
46-
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
47-
48-
```js
49-
// eslint.config.js
50-
import reactX from 'eslint-plugin-react-x'
51-
import reactDom from 'eslint-plugin-react-dom'
52-
53-
export default defineConfig([
54-
globalIgnores(['dist']),
55-
{
56-
files: ['**/*.{ts,tsx}'],
57-
extends: [
58-
// Other configs...
59-
// Enable lint rules for React
60-
reactX.configs['recommended-typescript'],
61-
// Enable lint rules for React DOM
62-
reactDom.configs.recommended,
63-
],
64-
languageOptions: {
65-
parserOptions: {
66-
project: ['./tsconfig.node.json', './tsconfig.app.json'],
67-
tsconfigRootDir: import.meta.dirname,
68-
},
69-
// other options...
70-
},
71-
},
72-
])
73-
```
17+
## 🛠️ Build & Run
18+
1. `npm install`
19+
2. `npm run dev`

frontend/src/App.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ function App() {
4444

4545
return (
4646
<div className="app">
47+
<div className="app-bg"></div>
48+
<div className="app-bg-glow"></div>
49+
4750
<Header
4851
onSchemaView={handleSchemaView}
4952
onSchemaCreate={() => setShowCreator(true)}

frontend/src/components/Header.css

Lines changed: 32 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,76 @@
11
.header {
22
position: sticky;
3-
top: var(--spacing-md);
4-
margin: var(--spacing-md) auto;
3+
top: 1.5rem;
4+
margin: 1.5rem auto;
55
max-width: 1200px;
6-
padding: var(--spacing-lg) var(--spacing-xl);
7-
z-index: 100;
6+
padding: 1rem 2rem;
7+
z-index: 1000;
8+
border-radius: var(--radius-full) !important;
9+
background: rgba(255, 255, 255, 0.03) !important;
10+
border: 1px solid rgba(255, 255, 255, 0.05) !important;
811
}
912

1013
.header-content {
1114
display: flex;
1215
justify-content: space-between;
1316
align-items: center;
14-
gap: var(--spacing-lg);
1517
}
1618

1719
.logo-section {
1820
display: flex;
1921
align-items: center;
20-
gap: var(--spacing-md);
22+
gap: 1rem;
2123
}
2224

2325
.logo-icon {
24-
width: 48px;
25-
height: 48px;
26-
background: linear-gradient(135deg, var(--primary-blue) 0%, var(--accent-cyan) 100%);
27-
border-radius: var(--radius-md);
26+
width: 42px;
27+
height: 42px;
28+
background: linear-gradient(135deg, var(--royal-blue), var(--accent-glow));
29+
border-radius: 12px;
2830
display: flex;
2931
align-items: center;
3032
justify-content: center;
31-
color: var(--white);
32-
box-shadow: 0 4px 15px rgba(37, 99, 235, 0.3);
33-
animation: float 3s ease-in-out infinite;
33+
color: white;
34+
box-shadow: 0 0 20px rgba(37, 99, 235, 0.4);
3435
}
3536

36-
@keyframes float {
37-
38-
0%,
39-
100% {
40-
transform: translateY(0px);
41-
}
42-
43-
50% {
44-
transform: translateY(-5px);
45-
}
46-
}
47-
48-
.logo-text {
49-
display: flex;
50-
flex-direction: column;
51-
gap: 0;
52-
}
53-
54-
.app-title {
55-
font-size: 1.75rem;
56-
font-weight: 700;
57-
color: var(--text-primary);
58-
display: flex;
59-
align-items: center;
60-
gap: var(--spacing-xs);
37+
.logo-text h1 {
38+
font-size: 1.5rem;
39+
font-weight: 800;
40+
letter-spacing: -0.02em;
6141
margin: 0;
62-
line-height: 1;
6342
}
6443

6544
.ai-badge {
66-
background: linear-gradient(135deg, var(--primary-blue) 0%, var(--accent-cyan) 100%);
45+
background: linear-gradient(135deg, var(--accent-glow), var(--primary-glow));
6746
-webkit-background-clip: text;
68-
-webkit-text-fill-color: transparent;
6947
background-clip: text;
70-
font-weight: 800;
48+
-webkit-text-fill-color: transparent;
7149
}
7250

7351
.app-subtitle {
74-
font-size: 0.875rem;
75-
color: var(--text-secondary);
52+
font-size: 0.75rem;
53+
color: var(--text-muted);
54+
font-weight: 500;
55+
text-transform: uppercase;
56+
letter-spacing: 0.05em;
7657
margin: 0;
77-
margin-top: 2px;
7858
}
7959

8060
.header-nav {
8161
display: flex;
82-
gap: var(--spacing-sm);
62+
gap: 0.8rem;
8363
}
8464

8565
@media (max-width: 768px) {
8666
.header {
87-
padding: var(--spacing-md);
88-
}
89-
90-
.header-content {
91-
flex-direction: column;
92-
text-align: center;
93-
}
94-
95-
.logo-section {
96-
flex-direction: column;
67+
top: 1rem;
68+
padding: 0.8rem 1.2rem;
69+
margin: 1rem;
70+
border-radius: var(--radius-md) !important;
9771
}
9872

99-
.app-title {
100-
font-size: 1.5rem;
73+
.app-subtitle {
74+
display: none;
10175
}
10276
}

0 commit comments

Comments
 (0)