Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Ash914027/CipherSQLstudio

Repository files navigation

🧠 CipherSQLStudio – SQL Learning Platform πŸš€

A browser-based SQL learning platform where students can practice SQL queries against pre-configured assignments with real-time execution and AI-powered intelligent hints πŸ€–.


Screenshot 2025εΉ΄12月30ζ—₯ 001621

πŸ“‹ Table of Contents

  • ✨ Features
  • πŸ›  Technology Stack
  • πŸ— Architecture Overview
  • πŸ“¦ Prerequisites
  • πŸš€ Installation
  • πŸ” Environment Variables
  • ▢️ Running the Application
  • πŸ“ Project Structure
  • πŸ”„ Data Flow
  • πŸ“˜ API Documentation
  • πŸ” Security Features
  • 🧠 Technology Choices Explanation
  • πŸ–Ό Screenshots
  • 🀝 Contributing
  • πŸ“„ License

✨ Features

πŸ”Ή Core Functionality

  • πŸ“š Assignment Library – Browse SQL assignments by difficulty (Easy / Medium / Hard)
  • πŸ’» Interactive SQL Editor – Write and execute SQL queries directly in the browser
  • πŸ—‚οΈ Schema Viewer – View table structures and sample data
  • ▢️ Real-time Query Execution – Execute queries against a PostgreSQL sandbox database
  • πŸ€– AI-Powered Hints – Intelligent guidance (hints only, no direct solutions)
  • πŸ“Š Results Visualization – Scrollable, formatted result tables
  • ⚠️ Error Handling – Clear syntax and logical error messages

πŸ” Security Features

  • πŸ›‘ SQL injection prevention through query validation
  • πŸ”’ Read-only database access for students
  • ⏱ Query execution timeout (5 seconds)
  • 🚦 API rate limiting
  • βœ… Whitelist-based SQL keyword filtering

🎨 Design Features

  • πŸ“± Mobile-first responsive design (320px β†’ 1280px+)
  • πŸŒ™ Dark theme optimized for reading code
  • πŸ‘† Touch-friendly UI elements (minimum 44px)
  • ✨ Smooth animations and transitions
  • 🧩 BEM methodology for SCSS organization

πŸ›  Technology Stack

🎨 Frontend

Technology Version Purpose
βš› React 18.2.0 Component-based UI
🎨 SCSS 1.70.0 Styling with variables & nesting
πŸ” Axios 1.6.5 API communication
🧭 React Router 6.21.0 Client-side routing

🧩 Backend

Technology Version Purpose
🟒 Node.js β‰₯18 Runtime environment
πŸš€ Express.js 4.18.2 Web framework
🐘 PostgreSQL β‰₯14 Sandbox DB for query execution
πŸƒ MongoDB β‰₯6 Assignment persistence
🧬 Mongoose 8.1.0 MongoDB ODM

πŸ€– LLM Integration

  • 🧠 OpenAI GPT-4 (Recommended)
  • 🌐 Google Gemini
  • πŸ§ͺ Anthropic Claude

🧰 Development Tools

  • πŸ“œ Morgan – HTTP request logging
  • πŸ›‘ Helmet – Security headers
  • 🌍 CORS
  • 🚦 Express Rate Limit
  • πŸ”„ Nodemon

πŸ— Architecture Overview

graph TD A[CLIENT: React + SCSS] -- Axios API Calls --> B[EXPRESS SERVER] B --> C[PostgreSQL: Sandbox Execution] B --> D[MongoDB: User Data & Metadata] B --> E[LLM API: AI Hints/Feedback]

πŸ“ Project Structure

cipher-sql-studio/
β”‚
β”œβ”€β”€ client/ # Frontend React App
β”‚ β”œβ”€β”€ public/ # Static assets
β”‚ └── src/
β”‚ β”œβ”€β”€ components/ # UI Components (Editor, Results, Sidebar)
β”‚ β”œβ”€β”€ services/ # API service layer (Axios)
β”‚ β”œβ”€β”€ hooks/ # Custom React hooks
β”‚ β”œβ”€β”€ styles/ # SCSS / CSS modules
β”‚ β”œβ”€β”€ App.jsx # Root component
β”‚ └── index.js # React entry point
β”‚
β”œβ”€β”€ server/ # Backend Express App
β”‚ β”œβ”€β”€ src/
β”‚ β”‚ β”œβ”€β”€ config/ # DB & App configuration
β”‚ β”‚ β”œβ”€β”€ models/ # MongoDB schemas (Metadata/Assignments)
β”‚ β”‚ β”œβ”€β”€ controllers/ # Route handlers
β”‚ β”‚ β”œβ”€β”€ services/ # Business logic & LLM integration
β”‚ β”‚ β”œβ”€β”€ routes/ # API endpoints
β”‚ β”‚ └── middleware/ # Security & Error handling
β”‚ └── seeds/ # Database seeders
β”‚
β”œβ”€β”€ database/ # Database scripts
β”‚ └── postgres/
β”‚ β”œβ”€β”€ schema.sql # Sandbox table definitions
β”‚ └── sample_data.sql# Initial sandbox data
β”‚
└── docs/ # Documentation (API, Architecture)

πŸ“ Server Configuration (server/.env)

Create a .env file in the server directory:

Code snippet

SERVER CONFIG

  • PORT=5000
  • NODE_ENV=development

DATABASES

  • POSTGRES_HOST=localhost
  • POSTGRES_USER=postgres
  • POSTGRES_PASSWORD=your_password
  • POSTGRES_DB=cipher_sql_sandbox -MONGODB_URI=mongodb://localhost:27017/cipher_sql_studio

AI CONFIG

  • LLM_PROVIDER=openai
  • OPENAI_API_KEY=sk-your-key-here

SECURITY

-MAX_QUERY_EXECUTION_TIME=5000 -MAX_RESULT_ROWS=1000

▢️ Running the Application

πŸ§ͺ Development Mode

To get the environment up and running, open two separate terminal windows:

πŸ”Ή Terminal 1: Backend

cd server
npm run dev

🌐 Access Points

Component URL
🎨 Frontend UI http://localhost:3000
πŸš€ Backend API http://localhost:5000/api
❀️ Health Check http://localhost:5000/api/health

πŸ“„ Notes

  • πŸ›‘οΈ Security: The PostgreSQL sandbox is designed for read-only or simulated environments. Ensure user permissions are strictly restricted in production to prevent unauthorized data modification.
  • πŸ€– AI Hints: Execution and rate limits apply based on your chosen LLM provider's subscription plan.
  • πŸ› οΈ Troubleshooting: If you encounter any issues, please check the logs in the server terminal for detailed error messages.

✨ Happy Coding! You are all set to start building with CipherSQLStudio.

About

a browser-based SQL learning platform where students can practice SQL queries against pre-configured assignments with real-time execution and intelligent hints.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /