An AI-powered image generator that lets users create artwork from text prompts and browse a gallery of generated images.
- Frontend: Next.js App Router (TypeScript), Tailwind CSS, SWR,
next/image - AI: OpenAI (DALL·E for images, GPT for prompt suggestions)
- Backend: Azure Functions (Node.js)
- Storage: Azure Blob Storage with SAS tokens
This project is portfolio-ready: it demonstrates full‑stack integration with AI services, cloud functions, secure media storage, and modern React patterns.
- Text-to-image generation via OpenAI DALL·E
- Smart prompt suggestions via GPT (server-side)
- Image gallery with on-demand revalidation (SWR)
- Optimized delivery using
next/imageand domain allowlisting - Secure uploads to Azure Blob Storage via SAS tokens
- User enters a prompt (or fetches a suggestion).
- The Next.js API forwards the request to Azure Functions.
- Azure Function calls OpenAI to generate the image, downloads the result, and uploads it to Azure Blob Storage using a short‑lived SAS token.
- The gallery fetches signed URLs from Azure Functions and renders images using
next/image.
- Frontend routes and UI in
app/andcomponents/ - API proxy endpoints in
app/api/*/route.ts - Azure Functions in
azure/src/functions/ - Azure helpers in
azure/lib/
app/
api/
generateImage/route.ts # Forwards image generation requests to Azure Function
getImages/route.ts # Fetches gallery entries from Azure Function
suggestion/route.ts # Fetches GPT-generated prompt suggestion
layout.tsx, page.tsx # App Router layout and page
components/ # UI components (Header, Images, PromptInput)
lib/ # Client-side fetch helpers
azure/
src/functions/ # Azure Functions: generateImage, getImages, getChatGPTSuggestion, generateSASToken
lib/ # Azure helpers: OpenAI client and SAS token generator
local.settings.example.json # Example Azure Functions local settings
- Node.js 16+ (recommended 18)
- Azure account with a Storage Account and a Blob container named
images - OpenAI account and API key
- Azure Functions Core Tools for local development (
func)
npm i
cd ./azure && npm i- Frontend (
.env.localat project root):
# Azure Functions base URL (local or deployed)
AZURE_FUNCTIONS_ENDPOINT_URL=http://localhost:7071- Azure Functions (
azure/local.settings.json): copy from the example and fill values.
cd ./azure && copy local.settings.example.json local.settings.json
# then edit local.settings.json and set:
# - AZURE_STORAGE_ACCOUNT_NAME
# - AZURE_STORAGE_ACCOUNT_KEY
# - OPENAI_ORGANIZATION_ID
# - OPENAI_API_KEYImportant: Never commit real secrets. Use the example files and environment‑specific overrides.
In two terminals:
# Terminal A (frontend)
npm run dev
# Terminal B (azure functions)
cd ./azure && npm run startOpen http://localhost:3000.
-
POST /api/generateImage- Body:
{ "prompt": string } - Forwards to Azure Function
generateImageand returns a status message.
- Body:
-
GET /api/getImages- Returns
{ imageUrls: { name: string; url: string }[] }from Azure FunctiongetImages.
- Returns
-
GET /api/suggestion- Returns a GPT‑generated prompt suggestion (string).
generateImage(POST): Creates image via OpenAI, uploads to Blob Storage.getImages(GET): Lists blobs, returns signed URLs and names (sorted by timestamp).getChatGPTSuggestion(GET): Returns a creative prompt suggestion.generateSASToken(GET): Issues short‑lived SAS tokens (internal helper).
next.config.jswhitelists image domains. Updateimages.domainsif your storage account name differs.- Gallery container name is
images. Ensure this container exists in your Storage Account. - Frontend uses SWR with
cache: 'no-store'for fresh data.
- Secrets management: Use
.env.local(frontend) andlocal.settings.json(functions). Do not commit secrets. - Edge‑safe API proxying: Frontend never exposes OpenAI keys; all AI calls run server‑side in Azure Functions.
- Short‑lived access: Blob access secured via SAS tokens with minimal permissions and limited expiry.
- Optimized media:
next/imagefor responsive, optimized delivery; domain allowlisting innext.config.js. - Type safety & linting: TypeScript, ESLint, and conventional React patterns.
- Clear separation of concerns: UI in Next.js, AI + storage in Azure Functions.
- Frontend: Deploy to Vercel or Azure Static Web Apps. Set
AZURE_FUNCTIONS_ENDPOINT_URLto your deployed functions base URL. - Azure Functions: Deploy via Azure Functions Core Tools or Azure Portal. Configure app settings to match
local.settings.jsonkeys.
Built with Next.js, OpenAI, and Microsoft Azure. Inspired by modern AI tooling demos and adapted for production‑ready patterns.