Prerequisites
Before starting, ensure you have the following installed:Required software
Required software
- 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
Required accounts
Required accounts
- OpenAI account: For DALL-E 3 and GPT API access
- Azure account: For Blob Storage and Functions deployment
Installation
Clone the repository
Install dependencies
Install frontend dependencies
You can use
yarn or pnpm instead of npm if preferred. The project supports all major package managers.Configuration
OpenAI API setup
Get OpenAI API key
- Visit OpenAI API Keys
- Click “Create new secret key”
- Copy the generated API key (starts with
sk-) - Note your organization ID from Settings
Never commit
.env.local files to version control. They should be listed in .gitignore.Azure Blob Storage setup
Create Azure Storage Account
- Log in to Azure Portal
- Create a new Storage Account
- Choose a unique name for your storage account
- Select a region close to your users
- Use Standard performance tier for development
Create images container
- Navigate to your Storage Account
- Go to “Containers” under Data Storage
- Click ”+ Container”
- Name it
images - Set public access level to “Private”
Get storage credentials
- In your Storage Account, go to “Access keys”
- Copy the storage account name
- Copy one of the access keys (key1 or key2)
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
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:app/api/generateImage/route.ts
app/api/generateImage/route.ts
app/api/getImages/route.ts
app/api/getImages/route.ts
app/api/suggestion/route.ts
app/api/suggestion/route.ts
Start the frontend
Open in browser
Visit http://localhost:3000
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
- Frontend changes
- Backend changes
- Styling changes
- Edit files in
app/,components/, orlib/ - Save the file
- Browser automatically refreshes with changes
- Check console for any errors
Testing image generation
Open the application
Navigate to http://localhost:3000
Generate an image
Either:
- Click “Use suggestion” to generate with the AI prompt
- Enter your own prompt and click “Generate”
DALL-E 3 image generation typically takes 10-30 seconds. Be patient while the AI creates your image.
Troubleshooting
Azure Functions not starting
Azure Functions not starting
Problem: Functions fail to start or show errors.Solutions:
- Verify Azure Functions Core Tools is installed:
func --version - Check that
.env.localexists and has correct credentials - Ensure Node.js version is 18.x or higher:
node --version - Try deleting
node_modulesand runningnpm installagain
OpenAI API errors
OpenAI API errors
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
Azure Blob Storage errors
Azure Blob Storage errors
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
imagescontainer exists - Confirm storage account is not behind a firewall
Images not appearing
Images not appearing
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
CORS errors
CORS 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:Essential extensions
Essential 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:- Backend (azure/.env.local)
- Frontend (.env.local)
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