Skip to content

MSG-Mutual-Support-to-Grow/JSON-Prompt-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

74 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“ Text to JSON Prompt Converter

A complete Full-Stack AI-powered application that converts plain text into context-aware, structured JSON prompts for better AI model comprehension.
The system features a React + Tailwind frontend for easy text input and history tracking, and a FastAPI + Pydantic AI + Mistral AI backend for intelligent JSON generation and validation.

🌐 Live Demo

  • Frontend (Static Site): https://json-prompt-generator.onrender.com
  • Backend API: https://json-prompt-backend.onrender.com

πŸš€ Features

πŸ”Ή Backend (FastAPI + Pydantic AI + Mistral AI)

  • Advanced Pydantic AI Integration: Strong validation and structured responses
  • Mistral AI Powered: Context-aware JSON generation with relevant keys only
  • Smart Validation: Multi-layer type checking and error recovery
  • Async Operations: High-performance async/await for scalability
  • Robust Error Handling: Built-in retry logic, graceful fallbacks
  • Multi-Domain Support: Handles code generation, travel planning, data science, writing, and more

πŸ”Ή Frontend (React + Tailwind)

  • Instant Text-to-JSON Conversion
  • Conversion History: Stores latest 5 conversions
  • Copy to Clipboard for generated JSON
  • Responsive UI with sidebar navigation
  • Customizable JSON Structure

πŸ›  Tech Stack

Backend:

  • FastAPI (Python 3.9+)
  • Pydantic AI with Mistral AI integration
  • Uvicorn
  • python-dotenv

Frontend:

  • React + TypeScript
  • Vite
  • Tailwind CSS
  • Lucide React Icons

πŸ“‚ Project Structure

JSON-Prompt-Generator/
β”œβ”€β”€ backend/                  # FastAPI backend
β”‚   β”œβ”€β”€ main.py
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── generator.py
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── .env
β”‚
β”œβ”€β”€ frontend/                  # React frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.tsx
β”‚   β”‚   β”œβ”€β”€ main.tsx
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ TextToJsonConverter.tsx
β”‚   β”‚   β”‚   └── HistoryView.tsx
β”‚   β”œβ”€β”€ index.html
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ tailwind.config.js
β”‚   └── vite.config.ts
└── README.md

βš™οΈ Installation & Setup

1️⃣ Clone Repository

git clone https://github.com/MSG-Mutual-Support-to-Grow/JSON-Prompt-Generator.git
cd JSON-Prompt-Generator

2️⃣ Backend Setup

The backend setup instructions are in the backend/README.md


3️⃣ Frontend Setup

The frontend setup instructions are in the frontend/README.md


πŸ“‘ API Endpoints

POST /prompts/transform

Transform plain text into structured JSON with context-aware key selection.

Request:

{
  "text": "plan a trip to Tokyo in December",
  "num_keys": 5,
  "include_ai_content": true
}

Response Example:

{
  "response": {
    "text": "plan a trip to Tokyo in December",
    "city": "Tokyo",
    "country": "Japan",
    "month": "December",
    "activities": ["sightseeing", "food tours"]
  },
  "source": "mistral"
}

GET /

Health check endpoint.


πŸ–₯ Example Workflows

  • Programming β†’ Generates language, framework, libraries, etc.
  • Travel β†’ Generates destination, budget, activities, etc.
  • Content Writing β†’ Generates topic, tone, audience, word_count.

🎨 Frontend Features

  • Text Input β†’ JSON Output instantly via API
  • Copy JSON to Clipboard
  • View Conversion History
  • Responsive Design for desktop & mobile

πŸ”§ Development


🐞 Troubleshooting

  • Backend not starting? Activate venv and check .env file
  • CORS issues? Update allow_origins in main.py
  • Port conflicts? Change with --port flag in uvicorn or vite

πŸ“œ License

This project is licensed under the MIT License.


πŸ‘₯ Contributors

🀝 Contributing

Pull requests are welcome! Please follow:

  1. PEP 8 for Python code
  2. TypeScript standards for frontend
  3. Add docstrings/comments for clarity

About

An Open-Source JSON Prompt Generator that observes the pattern of the user's normal (free-text) prompt,then converts it into a structured JSON prompt based on inferred structure.

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors