Welcome to the Visual AI Prompting Canvas! This is an innovative, node-based web application that allows you to visually compose and interact with generative AI. Instead of just writing text prompts, you can connect images and ideas in a freeform canvas, creating a powerful and intuitive workflow for generating new visuals with the Google Gemini API.
- Node-Based Interface: Create and manage different types of nodes:
- Upload/Image: Add your own images to the canvas as inputs.
- Prompt: Write text prompts that can take images as context.
- Generated: View and use AI-generated images as inputs for further prompts.
- Visual Connections: Intuitively connect nodes by dragging lines between them to build complex creative workflows.
- AI-Powered Image Generation: Leverages the Google Gemini API's multimodal capabilities to edit and generate images based on a combination of text and image inputs.
- Infinite Interactive Canvas: Pan and zoom around a limitless canvas to organize your ideas without constraints.
- Dynamic UI: Elements like the prompt node automatically resize to fit your content, ensuring a clean and user-friendly experience.
- High-Performance Interactions: Enjoy smooth, lag-free dragging of nodes and connections, thanks to direct DOM manipulation during high-frequency events.
- Modern & Clean Aesthetic: A polished and visually appealing interface that makes the creative process enjoyable.
This project is built with a modern frontend stack, focusing on performance, scalability, and a great developer experience.
- Framework: React
- Language: TypeScript
- Styling: Tailwind CSS
- Generative AI: Google Gemini API (
@google/genai) - Unique IDs: UUID
To run the Visual AI Prompting Canvas on your local machine, please follow these steps.
- Node.js: Ensure you have a recent version of Node.js installed (LTS version recommended). You can download it from nodejs.org.
- Package Manager: This guide uses
npm, which is included with Node.js. You can also useyarnorpnpm. - Google Gemini API Key: You'll need an API key to use the generative AI features.
- Go to Google AI Studio.
- Click "Get API key" and create a new API key in a project.
- Copy the key securely. Do not commit it to your repository.
-
Clone the Repository
git clone https://github.com/your-username/visual-ai-canvas.git cd visual-ai-canvas -
Install Dependencies
Since this project is set up as a static application without a
package.json, you would typically introduce a build tool like Vite or Create React App. For the purpose of running this specific structure, let's assume you'll set up a minimal environment.If you were to use Vite (recommended):
# In a new project initialized with Vite + React + TS npm install @google/genai uuid npm install -D @types/uuid -
Set Up Environment Variables
The application expects your Gemini API key to be available as an environment variable. In a typical local development setup (like with Vite), you would:
a. Create a file named
.env.localin the root of your project directory.b. Add your API key to this file. Remember to replace
YOUR_GEMINI_API_KEYwith your actual key.# .env.local API_KEY=YOUR_GEMINI_API_KEYThe
geminiService.tsfile is configured to read this key. In a Vite project, you would access it viaimport.meta.env.VITE_API_KEYafter renaming the variable in the.env.localfile. -
Run the Development Server
If you are using a simple static server, you can use a tool like
serve:# Install serve globally if you don't have it npm install -g serve # Serve the project directory serve .
You will then be able to access the application in your browser at the local address provided by the server (e.g.,
http://localhost:3000).Note: For
process.env.API_KEYto work correctly in a browser environment, a build tool like Vite is required to substitute the variable at build time. Theservemethod above will not work out-of-the-box without modifying the code to either hardcode the key (not recommended) or load it from a configuration file.
