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
Install backend dependencies
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
Create environment file
.env.local file in the azure directory:Add OpenAI credentials
azure/.env.local:.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)
Add to environment file
azure/.env.local:Running the application
Start the backend
Navigate to Azure directory
Start Azure Functions
Verify functions are running
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 new terminal
Start Next.js development server
Open in 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
Get a suggestion
Generate an image
- Click “Use suggestion” to generate with the AI prompt
- Enter your own prompt and click “Generate”
Monitor progress
- Watch the toast notification for generation status
- Check Azure Functions terminal for logs
- Images appear in the gallery once uploaded
Troubleshooting
Azure Functions not starting
Azure Functions not starting
- 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
- 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
- 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
- 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
- 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)