A modern AI chatbot application built with Java Swing, featuring a clean dark-themed interface and integration with Google's Gemini API.

- Modern Dark UI: Clean, professional interface using FlatLaf
- User Authentication: Secure login and registration system
- AI Integration: Powered by Google Gemini API for intelligent conversations
- Voice Support: Voice input and text-to-speech capabilities
- Chat History: Persistent storage and retrieval of conversations
- User Settings: Customizable voice preferences and settings
- Responsive Design: Optimized for different screen sizes
- Java 11 or higher
- Maven 3.6 or higher
- Google Gemini API key
-
Clone the repository
git clone <repository-url> cd java_project
-
Install dependencies
mvn clean install
-
Configure Gemini API
- Get your API key from Google AI Studio
- Set the API key as a system property:
java -DGEMINI_API_KEY=your-api-key-here -jar target/ai-chatbot-1.0.0.jar
-
Run the application
mvn exec:java -Dexec.mainClass="com.chatbot.Main"Or build and run the JAR:
mvn package java -DGEMINI_API_KEY=your-api-key-here -jar target/ai-chatbot-1.0.0.jar
- Registration: Create a new account with username and password
- Login: Sign in with your credentials
- Chat: Type messages or use the microphone button for voice input
- History: View previous conversations using the History button
- Settings: Customize voice preferences and other options
- Database: SQLite for local data storage
- UI Framework: Java Swing with FlatLaf for modern appearance
- AI Service: Google Gemini API integration
- Voice Service: Built-in Java audio capabilities
- Security: Password hashing with salt for secure authentication
src/main/java/com/chatbot/
├── Main.java # Application entry point
├── database/
│ └── DatabaseManager.java # Database operations
├── model/
│ ├── User.java # User data model
│ └── ChatMessage.java # Chat message model
├── service/
│ ├── GeminiService.java # AI service integration
│ └── VoiceService.java # Voice input/output
├── ui/
│ ├── LoginFrame.java # Login interface
│ ├── RegisterFrame.java # Registration interface
│ ├── MainFrame.java # Main chat interface
│ ├── ChatHistoryDialog.java # Chat history viewer
│ ├── SettingsDialog.java # Settings configuration
│ └── components/ # Custom UI components
└── util/
└── PasswordUtil.java # Password hashing utilities
- Secure password hashing with SHA-256 and salt
- User registration with validation
- Session management
- Real-time conversation with Gemini API
- Error handling and fallback responses
- Conversation context preservation
- Microphone input for voice messages
- Text-to-speech for AI responses
- Configurable voice speed settings
- SQLite database for user data and chat history
- Automatic database initialization
- Chat history with timestamps
- Dark theme with professional appearance
- Smooth animations and hover effects
- Responsive layout for different screen sizes
- Custom styled components
The application uses FlatLaf's dark theme. You can modify colors in the UI components or switch to light theme by changing the look and feel in Main.java.
To use a different AI service, implement a new service class following the pattern in GeminiService.java.
The voice functionality can be enhanced by integrating with external speech-to-text and text-to-speech services.
- Database Connection: Ensure write permissions in the application directory
- API Key: Verify your Gemini API key is valid and properly set
- Audio Issues: Check microphone permissions and audio device availability
The application logs errors to the console. Enable debug logging by adding logging configuration.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini API for AI capabilities
- FlatLaf for modern UI components
- SQLite for embedded database functionality