A modern web application for creating, managing, and using AI prompts with dynamic variables. Built with Flask API, PostgreSQL database, and a beautiful responsive UI.
Formerly known as Prompt Builder Application.
- Prompt Management: Create, edit, delete, and organize prompts
- Category System: Organize prompts into categories
- Dynamic Variables: Use
{variable_name}
syntax for dynamic content - Search & Filter: Find prompts quickly with search functionality
- Usage Tracking: Track how often prompts are used
- Modern UI: Beautiful, responsive interface with gradient design
- Real-time Stats: View total prompts, categories, and usage statistics
- PostgreSQL Support: Robust database with PostgreSQL
- Modular API: Organized API structure with separate modules
- RESTful API: Complete REST API for external integrations
PromptBuilderApplication/
├── api/ # API modules
│ ├── __init__.py
│ ├── categories.py # Category API endpoints
│ ├── prompts.py # Prompt API endpoints
│ └── stats.py # Statistics API endpoints
├── models/ # Database models
│ ├── __init__.py
│ ├── database.py # Database initialization
│ ├── category.py # Category model
│ └── prompt.py # Prompt model
├── config/ # Configuration
│ ├── __init__.py
│ └── database.py # Database configuration
├── templates/ # Web UI templates
│ └── index.html # Main application UI
├── app.py # Main application file
├── run.py # Application runner
├── setup_database.py # Database setup script
├── requirements.txt # Python dependencies
├── env.example # Environment variables example
└── README.md # This file
- Python 3.7+
- PostgreSQL 12+
- pip (Python package manager)
-
Clone or download the project files
-
Install Python dependencies:
pip install -r requirements.txt
-
Set up PostgreSQL database:
# Create database createdb prompt_builder # Or using psql psql -U postgres CREATE DATABASE prompt_builder;
-
Configure environment variables:
# Copy the example environment file cp env.example .env # Edit .env with your database credentials DB_HOST=localhost DB_PORT=5432 DB_NAME=prompt_builder DB_USER=postgres DB_PASSWORD=your_password_here SECRET_KEY=your-secret-key-here
-
Set up the database:
python setup_database.py
-
Run the application:
python run.py
-
Open your browser and navigate to:
http://localhost:5000
- Click "New Category" in the sidebar
- Enter a name and optional description
- Click "Save Category"
- Click "New Prompt" in the sidebar
- Fill in the title and content
- Select a category
- Use
{variable_name}
syntax for dynamic variables - Click "Save Prompt"
- Click "Use" on any prompt
- Fill in the variable values if the prompt has variables
- Click "Generate Prompt" to see the final result
- Copy the generated prompt for use
- Edit: Click the "Edit" button to modify a prompt
- Delete: Click the "Delete" button to remove a prompt
- Search: Use the search box to find specific prompts
- Filter by Category: Click on a category to filter prompts
The application provides a comprehensive RESTful API organized into modules:
GET /api/categories
- List all categoriesPOST /api/categories
- Create a new categoryGET /api/categories/<id>
- Get a specific categoryPUT /api/categories/<id>
- Update a categoryDELETE /api/categories/<id>
- Delete a categoryGET /api/categories/<id>/prompts
- Get prompts in a category
GET /api/prompts
- List all prompts (supportscategory_id
andsearch
query parameters)POST /api/prompts
- Create a new promptGET /api/prompts/<id>
- Get a specific promptPUT /api/prompts/<id>
- Update a promptDELETE /api/prompts/<id>
- Delete a promptPOST /api/prompts/<id>/use
- Use a prompt with variablesGET /api/prompts/search
- Advanced search with filteringGET /api/prompts/most-used
- Get most used promptsGET /api/prompts/recent
- Get recently created prompts
GET /api/stats
- Get overall application statisticsGET /api/stats/usage
- Get usage statisticsGET /api/stats/prompts/trending
- Get trending prompts
GET /health
- Application health check
The application supports dynamic variables in prompts using the {variable_name}
syntax:
Example Prompt:
Write a {tone} email to {recipient} about {subject}.
Make it {length} and include {specific_details}.
When using the prompt, you'll be asked to fill in:
tone
: professional, casual, friendlyrecipient
: client, colleague, friendsubject
: project update, meeting request, etc.length
: short, medium, longspecific_details
: any specific information to include
The application uses PostgreSQL for data storage with the following schema:
Categories Table:
id
(Primary Key)name
(Unique)description
created_at
Prompts Table:
id
(Primary Key)title
content
variables
(JSON string)category_id
(Foreign Key)created_at
updated_at
usage_count
Create a .env
file with the following variables:
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_NAME=prompt_builder
DB_USER=postgres
DB_PASSWORD=your_password_here
# Flask Configuration
FLASK_ENV=development
SECRET_KEY=your-secret-key-here
The application supports different database configurations:
- Development: PostgreSQL with debug mode
- Production: PostgreSQL with production settings
- Testing: SQLite in-memory database
# Get all categories
curl http://localhost:5000/api/categories
# Create a new category
curl -X POST http://localhost:5000/api/categories \
-H "Content-Type: application/json" \
-d '{"name": "Marketing", "description": "Marketing prompts"}'
# Get all prompts
curl http://localhost:5000/api/prompts
# Create a new prompt
curl -X POST http://localhost:5000/api/prompts \
-H "Content-Type: application/json" \
-d '{"title": "Email Template", "content": "Write a {tone} email about {subject}", "category_id": 1}'
# Use a prompt with variables
curl -X POST http://localhost:5000/api/prompts/1/use \
-H "Content-Type: application/json" \
-d '{"variables": {"tone": "professional", "subject": "project update"}}'
The UI uses CSS custom properties and can be easily customized by modifying the styles in templates/index.html
.
To use a different database, modify the configuration in config/database.py
.
The API can be extended by adding new modules in the api/
directory and registering them in app.py
.
-
PostgreSQL connection error:
- Ensure PostgreSQL is running
- Check database credentials in
.env
file - Verify database exists
-
Port already in use:
- Change the port in
run.py
orapp.py
- Change the port in
-
Database setup issues:
- Run
python setup_database.py --reset
to reset the database - Check PostgreSQL logs for errors
- Run
-
CORS issues:
- The application includes CORS headers for API access
For development, the application runs in debug mode by default. To disable debug mode, set FLASK_ENV=production
in your .env
file.
This project is open source and available under the MIT License.
Feel free to submit issues, feature requests, or pull requests to improve the application.