A full-stack TypeScript application demonstrating AI integration with multiple LLM providers, featuring an intelligent chatbot and AI-powered product review summarization.
- Overview
- Features
- Tech Stack
- Project Structure
- Getting Started
- API Documentation
- Development
- Contributing
- License
This project showcases modern full-stack development with AI integration, built using TypeScript, React, and Express. It demonstrates how to integrate multiple AI providers (OpenAI, Ollama, Hugging Face) into a production-ready application with features like intelligent chatbots and AI-powered content summarization.
-
π€ Multi-Provider AI Integration
- Support for OpenAI, Ollama, and Hugging Face
- Flexible AI provider switching
- Configurable prompts and models
-
π¬ Intelligent Chatbot
- Real-time chat interface
- Context-aware conversations
- Typing indicators and smooth UX
-
β Product Review System
- Display product reviews with ratings
- Star rating visualization
- Review filtering and sorting
-
π AI-Powered Review Summarization
- Generate intelligent summaries from multiple reviews
- Cached summaries with expiration
- Efficient data processing
-
ποΈ Modern Architecture
- Monorepo structure with workspaces
- Type-safe database queries with Prisma
- RESTful API design
- Responsive UI with Tailwind CSS
- React 19 - UI library
- TypeScript - Type safety
- Vite - Build tool and dev server
- Tailwind CSS - Utility-first CSS framework
- React Query - Data fetching and caching
- Radix UI - Accessible component primitives
- Axios - HTTP client
- Express 5 - Web framework
- Bun - JavaScript runtime
- TypeScript - Type safety
- Prisma 7 - Next-generation ORM
- MySQL - Relational database
- Zod - Schema validation
- OpenAI - GPT models
- Ollama - Local LLM support
- Hugging Face - Open-source models
- Husky - Git hooks
- lint-staged - Pre-commit linting
- Prettier - Code formatting
- ESLint - Code linting
build-ai-powered-apps/
βββ packages/
β βββ client/ # React frontend application
β β βββ src/
β β β βββ components/ # React components
β β β β βββ chat/ # Chatbot components
β β β β βββ reviews/ # Review components
β β β β βββ ui/ # UI primitives
β β β βββ lib/ # Utilities
β β βββ package.json
β β
β βββ server/ # Express backend application
β βββ controllers/ # Route controllers
β βββ services/ # Business logic
β βββ repositories/ # Data access layer
β βββ routes.ts # API routes
β βββ prisma/ # Prisma schema and migrations
β βββ generated/ # Generated Prisma client
β βββ package.json
β
βββ package.json # Root package.json (workspaces)
βββ README.md
- Node.js v20.19+, v22.12+, or v24.0+
- Bun v1.0+ (Install Bun)
- MySQL 8.0+ (or MariaDB 10.3+)
- Git
-
Clone the repository
git clone https://github.com/andreassosilo/build-ai-powered-apps.git cd build-ai-powered-apps -
Install dependencies
bun install
-
Install dependencies for each package
cd packages/client && bun install cd ../server && bun install
Create a .env file in the packages/server directory:
# Database Configuration
DATABASE_URL="mysql://username:password@localhost:3306/database_name"
DATABASE_HOST="localhost"
DATABASE_USER="your_username"
DATABASE_PASSWORD="your_password"
DATABASE_NAME="your_database"
# Server Configuration
PORT=3000
# AI Provider Configuration
# OpenAI
OPENAI_API_KEY="your_openai_api_key"
OPENAI_MODEL="gpt-3.5-turbo"
# Ollama (optional)
OLLAMA_BASE_URL="http://localhost:11434"
OLLAMA_MODEL="llama2"
# Hugging Face (optional)
HUGGINGFACE_API_KEY="your_huggingface_api_key"-
Create your MySQL database
CREATE DATABASE your_database_name;
-
Run Prisma migrations
cd packages/server bunx prisma migrate dev -
Generate Prisma Client
bunx prisma generate
Development mode (runs both client and server):
From the root directory:
bun run devOr run separately:
Terminal 1 - Server:
cd packages/server
bun run devTerminal 2 - Client:
cd packages/client
bun run devThe application will be available at:
- Frontend: http://localhost:5173
- Backend API: http://localhost:3000
Send a message to the AI chatbot.
Request Body:
{
"prompt": "Hello, how are you?",
"conversationId": "optional-conversation-id"
}Response:
{
"message": "I'm doing well, thank you! How can I help you today?",
"conversationId": "conversation-id"
}Get all reviews for a specific product.
Parameters:
id(number) - Product ID
Response:
[
{
"id": 1,
"author": "John Doe",
"rating": 5,
"content": "Great product!",
"createdAt": "2024-01-01T00:00:00.000Z",
"productId": 1
}
]Generate an AI summary of all reviews for a product.
Parameters:
id(number) - Product ID
Response:
{
"summary": "Based on 10 reviews, this product has an average rating of 4.5 stars...",
"generatedAt": "2024-01-01T00:00:00.000Z",
"expiresAt": "2024-01-02T00:00:00.000Z"
}Format code with Prettier:
bun run formatThis project uses Husky for Git hooks. Pre-commit hooks will automatically:
- Run lint-staged to format and lint staged files
- Ensure code quality before commits
Open Prisma Studio (visual database editor):
cd packages/server
bunx prisma studioCreate a new migration:
cd packages/server
bunx prisma migrate dev --name your_migration_nameReset database:
cd packages/server
bunx prisma migrate resetContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is open source and available under the MIT License.
Andreas Sosilo
- GitHub: @andreassosilo
- Twitter: @andreassosilo
- LinkedIn: Andreas Sosilo
- Prisma for the amazing ORM
- Vite for the blazing-fast build tool
- Bun for the fast JavaScript runtime
- All the open-source contributors and libraries that made this project possible
β If you found this project helpful, please consider giving it a star!