I'll edit the README to include information about the screenshots and add a setup guide for OpenRouter API keys. Here's the updated version:
ComfortBot is an AI-powered chat application that provides comfort, guidance, and wisdom based on Islamic teachings. The application responds to users' emotional needs and concerns by sharing relevant Hadiths, Quranic verses, and spiritual advice.
- Conversational UI for expressing concerns and seeking guidance
- AI responses with relevant Islamic teachings
- Properly formatted Hadiths with sources and references
- Links to original sources for further reading
- Clean, responsive design for all devices
The application is built using:
- React & TypeScript
- Tailwind CSS for styling
- Shadcn UI component library
- OpenRouter API with DeepSeek model for AI responses
- Clone the repository
- Install dependencies
npm install - Set up your OpenRouter API key:
- Visit https://openrouter.ai/ and create an account
- Generate a new API key from your dashboard
- Create a
.envfile in the root directory with:OPENROUTER_API_KEY=your_api_key_here NEXT_PUBLIC_OPENROUTER_API_KEY=your_api_key_here
- Start the development server
npm run dev
- Open the application in your browser
- Type your concern, question, or emotional state in the chat input
- Receive a compassionate response with relevant Islamic guidance
- Click on "Read More" links to access the original sources
- Start a new conversation when needed
- "I'm feeling anxious about my future"
- "How can I deal with the loss of a loved one?"
- "I'm struggling with my faith"
- "Feeling angry about the political situation in my country"
- "How can I improve my relationship with my parents?"
- "I need guidance on how to be more patient"
- "How can I overcome negative thoughts?"
- "What does Islam teach about gratitude?"
The AI is guided by a carefully crafted system prompt that instructs it to:
1. Understand the user's emotional state or issue they're facing
2. Provide a brief compassionate response
3. Share a relevant Hadith, Surah, or Dua that addresses their situation
4. Include the source of the Hadith (e.g., Sahih Bukhari, Sahih Muslim)
5. Provide a direct link to the source on Sunnah.com
-
Response Formatting Issues:
- The AI model occasionally included syntax artifacts like escaped braces (
\{,\}) and formatting commands (\boxed{}) in its responses - Solution: Enhanced text cleaning in both the ChatMessage component and parseAIResponse utility function
- The AI model occasionally included syntax artifacts like escaped braces (
-
Parsing Complex Responses:
- Extracting the different parts of the response (message, hadith, source, link, closing) required careful regex pattern matching
- Solution: Improved the pattern matching logic and added additional cleanup steps
-
Layout and Presentation:
- Designing a clear separation between user messages, AI messages, and quoted hadiths
- Solution: Custom styling with distinct visual elements for each component (bubbles, borders, colors)
-
Responsive Design:
- Ensuring readability on all device sizes
- Solution: Tailwind CSS responsive classes and careful component sizing
-
API Integration:
- Managing API response errors and loading states
- Solution: Comprehensive error handling and loading indicators
- Audio recitation of Hadiths and Quranic verses
- Support for multiple languages
- User authentication to save conversation history
- Topic categorization for spiritual guidance
- Expanded reference database including additional authentic sources
This project is open source and available under the MIT License.


