Skip to main content
Follow this guide to set up VisionaryAI for local development, including both the Next.js frontend and Azure Functions backend.

Prerequisites

Before starting, ensure you have the following installed:
  • Node.js: Version 18.x or higher
  • npm: Version 8.x or higher (or yarn/pnpm)
  • Azure Functions Core Tools: Version 4.x
  • Visual Studio Code: Recommended IDE
  • Git: For version control
  • OpenAI account: For DALL-E 3 and GPT API access
  • Azure account: For Blob Storage and Functions deployment

Installation

Clone the repository

Install dependencies

1

Install frontend dependencies

This installs Next.js, React, Tailwind CSS, and other frontend dependencies.
2

Install backend dependencies

This installs Azure Functions SDK, OpenAI client, and Azure Storage SDK.
You can use yarn or pnpm instead of npm if preferred. The project supports all major package managers.

Configuration

OpenAI API setup

1

Get OpenAI API key

  1. Visit OpenAI API Keys
  2. Click “Create new secret key”
  3. Copy the generated API key (starts with sk-)
  4. Note your organization ID from Settings
2

Create environment file

Create a .env.local file in the azure directory:
3

Add OpenAI credentials

Add the following to azure/.env.local:
Never commit .env.local files to version control. They should be listed in .gitignore.

Azure Blob Storage setup

1

Create Azure Storage Account

  1. Log in to Azure Portal
  2. Create a new Storage Account
  3. Choose a unique name for your storage account
  4. Select a region close to your users
  5. Use Standard performance tier for development
2

Create images container

  1. Navigate to your Storage Account
  2. Go to “Containers” under Data Storage
  3. Click ”+ Container”
  4. Name it images
  5. Set public access level to “Private”
3

Get storage credentials

  1. In your Storage Account, go to “Access keys”
  2. Copy the storage account name
  3. Copy one of the access keys (key1 or key2)
4

Add to environment file

Add to azure/.env.local:
Azure provides a free tier with 5 GB storage and 20,000 read operations. This is sufficient for development.

Running the application

Start the backend

1

Navigate to Azure directory

2

Start Azure Functions

Or using Azure Functions Core Tools directly:
3

Verify functions are running

You should see output like:
Keep this terminal window open. The functions run on port 7071 by default.

Update frontend API endpoints

For local development, update the API routes to point to your local Azure Functions:

Start the frontend

1

Open new terminal

Navigate to the project root directory.
2

Start Next.js development server

3

Open in browser

The Next.js development server includes hot module replacement (HMR), so changes to frontend code will automatically refresh the browser.

Development workflow

Project structure

Here’s the complete project structure:

Making changes

  1. Edit files in app/, components/, or lib/
  2. Save the file
  3. Browser automatically refreshes with changes
  4. Check console for any errors

Testing image generation

1

Open the application

2

Get a suggestion

Click “New suggestion” to get an AI-generated prompt idea.
3

Generate an image

Either:
  • Click “Use suggestion” to generate with the AI prompt
  • Enter your own prompt and click “Generate”
4

Monitor progress

  • Watch the toast notification for generation status
  • Check Azure Functions terminal for logs
  • Images appear in the gallery once uploaded
DALL-E 3 image generation typically takes 10-30 seconds. Be patient while the AI creates your image.

Troubleshooting

Problem: Functions fail to start or show errors.Solutions:
  • Verify Azure Functions Core Tools is installed: func --version
  • Check that .env.local exists and has correct credentials
  • Ensure Node.js version is 18.x or higher: node --version
  • Try deleting node_modules and running npm install again
Problem: “Invalid API key” or “Rate limit exceeded” errors.Solutions:
  • Verify API key starts with sk- and is complete
  • Check OpenAI account has available credits
  • Ensure you have access to DALL-E 3 API (may require paid plan)
  • Review OpenAI rate limits
Problem: “Storage account not found” or “Authentication failed”.Solutions:
  • Verify storage account name is correct (no typos)
  • Ensure access key is the full key (very long string)
  • Check that the images container exists
  • Confirm storage account is not behind a firewall
Problem: Generation succeeds but images don’t show in gallery.Solutions:
  • Click “Refresh Images” button
  • Check Azure Portal to verify blobs were uploaded
  • Verify SAS token generation is working (check backend logs)
  • Check browser console for CORS or network errors
Problem: Browser shows CORS policy errors.Solutions:
  • Ensure Azure Functions is running on port 7071
  • Verify API routes are pointing to localhost:7071
  • Configure CORS in Azure Portal for production deployments
  • Check that requests include proper headers

VS Code setup

Recommended VS Code extensions:
  • Azure Functions: Manage and debug Azure Functions
  • Tailwind CSS IntelliSense: Autocomplete for Tailwind classes
  • ES7+ React/Redux/React-Native snippets: React code snippets
  • Prettier: Code formatting
  • ESLint: JavaScript linting

Launch configuration

Create .vscode/launch.json for debugging:

Environment variables reference

Complete list of required environment variables:

Next steps

Architecture overview

Learn how the system components work together

Frontend development

Explore React components and UI patterns

Backend development

Deep dive into Azure Functions and AI integration

API Reference

Explore the complete API documentation