AI-powered customer reviews analysis with Astro and Gemini API via Vercel’s AI SDK. Modified from this Next.js template, described as follows.
This is a demo of AI generated summaries of customer reviews for an e-commerce storefront. The demo takes a set of customer reviews, and uses an LLM to create summaries of those reviews. It then displays the summary and the reviews in a demo UI.
- Node v18.20.8 or v20.3.0, v22.0.0 or higher
- Gemini API key – get free here
- Upstash Redis DB – get free here
npm create astro@latest my-astro-project -- --template ekafyi/astro-ai-review-summary
- Clone this repo / use as template / open in cloud IDE above
- Run
mv .env.example .envand fill in the credentials - Run
npm installandnpm run dev(or your preferred package manager)
- Astro web framework
- Performant by default
- Server Islands for enabling server-side functionalities by component. Keep rest of page static or long-cached for optimal performance.
- Adapters for deploy target. Deploy to Vercel (default), Netlify, Cloudflare, Node.js, and more.
Imagecomponent for image transformation
- AI SDK
- Unified API for interfacing with LLMs from various providers. Supports Google (default), OpenAI, Anthropic, and more.
- React + Tailwind CSS + shadcn/ui for UI components
- Upstash Redis for data persistence
- Basic must-haves
public # unprocessed static files
src # details below
├── assets
├── components
│ ├── astro
│ └── ui
├── layouts
├── lib
├── pages
└── styles
Image files to be processed by Astro Image component
/- React UI components
/astro- Astro Server Island components
- Astro Image component
- Sitewide footer and header
/ui- (Auto generated) shadcn/ui components
Sitewide layout component
ai-summarizer.ts– text generation with AI SDKfake-api.ts,fake-logger.ts– self-explanatory :)redis.ts– instantiate storagesample-data.ts– products and reviews data modelutils.ts– (Auto generated) shadcn/ui CSS class helper
Astro page components
index.astro- show list of products
products/[productId].astro- show a product
- show reviews of given product
- show summary of reviews of given product
- get summary from storage if exists
- generate with AI if it does not exist, then write to storage
CSS file
This template uses the @astrojs/vercel adapter. Steps to deploy:
- Create a free Vercel account
- Create a new project and import your repository
- Paste your
.envvalue in the "Deploy" screen
To deploy elsewhere, install your preferred adapter, eg. npx astro add netlify.
Docs: https://docs.astro.build/en/guides/on-demand-rendering/#server-adapters
Use another provider:
// src/lib/ai-summarizer.ts
- import { google } from "@ai-sdk/google";
+ import { openai } from "@ai-sdk/openai";Docs: https://ai-sdk.dev/providers/ai-sdk-providers
Add an Astro frontend framework integration:
pnpm astro add svelte
You can use multiple framework integrations together – eg. React and Svelte.
You can use regular HTML markup and vanilla JS in Astro components.
Docs:
- https://docs.astro.build/en/guides/framework-components
- https://docs.astro.build/en/basics/astro-components/
Vanilla CSS is supported by default. Edit in src/styles/global.css.
Docs: https://docs.astro.build/en/guides/styling/
Remove Tailwind:
- Run
pnpm remove tailwindcss @tailwindcss/vite - Remove imports from
src/styles/global.css
Remove shadcn/ui: (this repo only uses the Avatar component)
- Remove files:
rm components.json src/lib/utils.ts - Remove dir:
rm -rf src/components/ui - Remove supporting libraries:
pnpm remove tailwind-merge @radix-ui/react-avatar