A hands-on workshop project to learn how to build AI-powered applications using Google's Gemini API.
This repository contains a Personal AI Chatbot project that demonstrates:
- β Integration with Google Gemini API
- β FastAPI backend for handling chat requests
- β Modern React frontend with beautiful UI
- β Real-time conversational AI
- β Customizable system instructions
Building-with-Gemini-API/
βββ services/
β βββ chatbot/ # FastAPI backend
β βββ main.py # FastAPI app with CORS
β βββ utils.py # Gemini API integration
β βββ schema.py # Pydantic models
β βββ .env # API keys (create this)
βββ chatbot_frontend/ # React + TypeScript frontend
β βββ src/
β β βββ App.tsx # Main chatbot component
β β βββ App.css # Component styles
β β βββ index.css # Design system
β βββ package.json
βββ README.md
By the end of this workshop, you will:
- β Understand how to use the Gemini API
- β Create a personalized AI chatbot
- β Build a FastAPI backend
- β Connect a React frontend to your API
- β Deploy your chatbot (optional)
- Python 3.8+
- Node.js 16+
- Google Gemini API Key (Get one here)
# Navigate to the chatbot service
cd services/chatbot
# Create a virtual environment (optional but recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install fastapi uvicorn python-decouple google-genai
# Create .env file with your API key
echo "GEMINI_API_KEY=your_api_key_here" > .env
# Start the backend server
uvicorn main:app --reloadThe backend will be running at http://localhost:8000
# In a new terminal, navigate to chatbot_frontend
cd chatbot_frontend
# Install dependencies
npm install
# Start the development server
npm run devThe frontend will be running at http://localhost:5173
Open services/chatbot/utils.py and fill in the TODO sections with your personal information:
system_instruction = """
# TODO: Define who you are and what you do
You are [YOUR ROLE HERE]
# TODO: Fill in your personal details
- Name: [YOUR NAME]
- Title: [YOUR TITLE]
- Skills: [YOUR SKILLS]
# ... and more!
"""Location: services/chatbot/utils.py
Fill in the TODO sections with:
- Your name and role
- Your responsibilities
- Personal information (education, skills, projects)
- Career goals and interests
Time: 15-20 minutes
- Start both backend and frontend
- Ask your chatbot questions like:
- "What projects have you worked on?"
- "What are your skills?"
- "Tell me about your education"
- Verify the responses match your system instruction
Time: 10 minutes
Location: frontend/src/index.css
Try changing:
- Color scheme (edit CSS variables)
- Chatbot avatar emoji
- Welcome message
- Button styles
Time: 15 minutes
Health check endpoint
Response:
{
"message": "Hello World"
}Send a message to the chatbot
Request:
{
"messages": [
{
"role": "user",
"message": "Hello, who are you?"
}
]
}Response:
{
"role": "model",
"message": "Hi! I'm [Your Name]'s AI assistant..."
}- Modern Dark Theme with gradient accents
- Smooth Animations for messages and interactions
- Typing Indicators when the bot is thinking
- Auto-scroll to latest messages
- Error Handling with user-friendly messages
- Responsive Design for mobile and desktop
- FastAPI - Modern Python web framework
- Google Gemini API - AI language model
- Pydantic - Data validation
- python-decouple - Environment variable management
- React - UI library
- TypeScript - Type safety
- Vite - Build tool
- CSS3 - Modern styling with custom properties
Error: "GEMINI_API_KEY not found"
- Make sure you created the
.envfile inservices/chatbot/ - Verify your API key is correct
Error: "Module not found"
- Run
pip install -r requirements.txt(if exists) - Or manually install:
pip install fastapi uvicorn python-decouple google-genai
CORS Error
- Make sure the backend is running on
http://localhost:8000 - Check that CORS middleware is configured in
main.py
Connection Failed
- Verify both backend and frontend are running
- Check the browser console for detailed error messages
- Start Simple: Get the basic chatbot working first
- Test Often: Test after each change to catch issues early
- Be Creative: Make the chatbot reflect your personality
- Ask Questions: Don't hesitate to ask for help
- Have Fun: Experiment with different prompts and styles!
After completing the workshop, you can:
- π Deploy your chatbot to production
- π¨ Add more UI features (voice input, file uploads)
- π€ Implement function calling for dynamic actions
- π Add conversation history persistence
- π Add user authentication
MIT License - Feel free to use this project for learning and personal use!
This is a workshop project, but suggestions and improvements are welcome!
Happy Coding! π
Made with π€ for the SETIF Developers Group Workshop