Project Info
This project did not submit a demo video on Devpost.
Inspiration
We've all seen how difficult it can be for people facing serious hardships—like homelessness, addiction, or food insecurity—to find the help they need. The systems in place are often fragmented, confusing, and overwhelming to navigate. We were inspired to build something that could act as a compassionate first point of contact. We imagined a tool that could instantly provide clear, empathetic guidance, 24/7, to someone in crisis, bridging the gap between needing help and getting it. We wanted to create a digital safety net that wasn't just a directory, but a genuine companion on the path to stability.
What it does
BetterLyf is an AI-powered life assistant designed to provide immediate, personalized support to vulnerable individuals. Through a simple, voice-enabled chat interface, users can: Get Connected to Local Resources: Tell the app their situation (e.g., "I'm homeless in Oakland"), and it instantly provides a formatted list of nearby shelters, food banks, or clinics, complete with contact information and access instructions. Receive Empathetic Coaching: The AI has a "Life Coach" mode that offers motivational support and practical advice, helping users break down overwhelming problems into manageable steps. Experience a Judgment-Free Conversation: The platform is built on a foundation of empathy and trauma-informed principles, ensuring users feel safe and understood, not judged. View and Manage Resources: A comprehensive admin dashboard allows case workers or administrators to monitor conversations, view user needs, and see how the system is being used in real-time.
How we built it
BetterLyf is built on a modern, robust tech stack designed for scalability and real-time interaction: Backend: We used Python with the Flask framework to create a lightweight and powerful API. This handles all the core logic, from user management to AI orchestration. AI & Language Models: The "brains" of our operation is Google's Gemini, which we use for all conversational AI. We spent significant time on prompt engineering to create our distinct "coach" and "resource assistant" personalities. Database: We used SQLite for its simplicity and ease of use in storing user data and conversation histories, all managed through SQLAlchemy. Frontend: The user interface is built with standard HTML, CSS, and JavaScript, ensuring it's accessible and responsive. The chat interface is designed to be clean, intuitive, and easy to use, even for non-technical users.
Challenges we ran into
One of our biggest challenges was balancing empathy with efficiency in the AI's responses. Initially, the AI was either too direct and robotic, or too verbose and not actionable enough. It took many iterations of prompt engineering to find the right voice—one that is compassionate but also provides clear, direct help. Another hurdle was maintaining conversational context. Early versions of the bot would "forget" what the user said just a few messages ago. We had to implement a robust system for storing and retrieving conversation history with every API call, which made the AI significantly smarter and the conversations feel much more natural. Finally, we learned that user experience is paramount. We started with an optional user information form, but quickly realized that making it mandatory was essential for the AI to provide truly personalized and effective guidance right from the start.
Accomplishments we're proud of
We are incredibly proud of creating an AI that feels genuinely human and helpful. The ability of the "Life Coach" to provide empathetic, non-judgmental support is something we believe can make a real difference. Building the dual-mode personality—switching between a resourceful assistant and a motivational coach—was a complex undertaking, and we're thrilled with how it turned out. It allows the user to get exactly the kind of help they need at any given moment. Finally, getting the full-featured admin dashboard up and running was a major accomplishment. It provides a powerful tool for monitoring the system and understanding user needs on a broader scale, which is essential for any organization that would implement this.
What we learned
This project was a deep dive into the practical application of large language models for social good. We learned that the "magic" of AI is really in the details—the careful crafting of prompts, the thoughtful management of conversation history, and the relentless focus on the end user's emotional state. We also learned that building a tool for people in crisis comes with a heavy responsibility. Every design choice, from the color of a button to the wording of a prompt, has to be made with empathy and a trauma-informed perspective.
What's next
for BetterLyf The journey for BetterLyf is just beginning. Our next steps are focused on expanding its impact and capabilities: Maps Integration: We plan to integrate Google Maps to visually show users where resources are located and provide real-time directions. Proactive Email Support: We want to build a system that can automatically email users a summary of the resources they discussed, so they have a permanent record. Guided Journaling: We envision a feature where users can journal their thoughts and feelings, and the AI can provide supportive analysis and track their emotional progress over time. Expanding the Resource Database: We aim to continuously expand and verify our database of local services to ensure our users are always getting the most accurate and up-to-date information.
CAG Chatbot Flask API
A Flask-based REST API for a CAG (Context-Aware Generation) chatbot system.
Features
- RESTful API endpoints for chat interactions
- Chat history management
- User session handling
- Configurable CAG integration
- CORS support for frontend integration
- Comprehensive error handling and logging
Project Structure
.
├── app.py # Main Flask application
├── config.py # Configuration management
├── cag_service.py # CAG chatbot service layer
├── requirements.txt # Python dependencies
└── README.md # This file
Setup Instructions
1. Install Dependencies
pip install -r requirements.txt
2. Environment Configuration
Create a .env file in the root directory with the following variables:
# Flask Configuration
SECRET_KEY=your-secret-key-here
DEBUG=True
PORT=5000
# CAG Chatbot Configuration
CAG_API_KEY=your-cag-api-key
CAG_MODEL_NAME=your-model-name
CAG_API_URL=https://api.cag.example.com
# Logging Configuration
LOG_LEVEL=INFO
3. Run the Application
Development Mode
python app.py
Production Mode
gunicorn -w 4 -b 0.0.0.0:5000 app:app
The application will be available at http://localhost:5000
API Endpoints
Health Check
- GET
/ - Returns application status
Chat Endpoints
Send Message
- POST
/api/chat - Body:
{ "message": "Hello, how are you?", "user_id": "user123" } - Response:
{ "response": "Hello! I'm doing well, thank you for asking.", "user_id": "user123", "timestamp": "2024-01-01T12:00:00" }
Get Chat History
- GET
/api/chat/history?user_id=user123 - Response:
{ "chat_history": [ { "user_id": "user123", "message": "Hello", "timestamp": "2024-01-01T12:00:00", "type": "user" }, { "user_id": "bot", "message": "Hello! How can I help you?", "timestamp": "2024-01-01T12:00:01", "type": "bot" } ], "total_messages": 2 }
Clear Chat History
- POST
/api/chat/clear - Body:
{ "user_id": "user123" } - Response:
{ "message": "Chat history cleared for user user123", "remaining_messages": 0 }
CAG Integration
The application includes a placeholder CAG service in cag_service.py. To integrate with your actual CAG system:
- Update the
CAGService.generate_response()method incag_service.py - Configure your CAG API credentials in the environment variables
- Implement the actual API calls to your CAG system
Example CAG Integration
def generate_response(self, message: str, user_id: str, context: Optional[Dict[str, Any]] = None) -> str:
payload = {
'message': message,
'user_id': user_id,
'model': self.model_name,
'context': context or {}
}
headers = {
'Authorization': f'Bearer {self.api_key}',
'Content-Type': 'application/json'
}
response = requests.post(
f"{self.api_url}/generate",
json=payload,
headers=headers,
timeout=30
)
response.raise_for_status()
return response.json()['response']
Development
Adding New Endpoints
- Add your route in
app.py - Implement proper error handling
- Add logging for debugging
- Update this README with endpoint documentation
Testing
You can test the API using curl or any HTTP client:
# Health check
curl http://localhost:5000/
# Send a message
curl -X POST http://localhost:5000/api/chat \
-H "Content-Type: application/json" \
-d '{"message": "Hello", "user_id": "test_user"}'
# Get chat history
curl http://localhost:5000/api/chat/history?user_id=test_user
Deployment
Docker (Optional)
Create a Dockerfile:
FROM python:3.9-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:5000", "app:app"]
Environment Variables for Production
- Set
DEBUG=False - Use a strong
SECRET_KEY - Configure your CAG API credentials
- Set appropriate
LOG_LEVEL
Error Handling
The application includes comprehensive error handling:
- 400: Bad Request (missing required fields)
- 404: Not Found (invalid endpoints)
- 500: Internal Server Error (server-side issues)
All errors return JSON responses with descriptive messages.
Logging
The application uses Python's logging module with configurable log levels. Logs include:
- Incoming requests
- CAG API interactions
- Error conditions
- Application startup/shutdown
Security Considerations
- CORS is enabled for frontend integration
- Input validation on all endpoints
- Environment variable configuration for sensitive data
- Error messages don't expose internal system details
Contributing
- Follow the existing code structure
- Add proper error handling and logging
- Update documentation for new features
- Test your changes thoroughly
Analysis
View
Metric
- 17
- 6
Figures cover GitHub contributors during the hackathon window. A co-authored commit counts in full for each author, so per-member totals add up to more than the whole-team figures.
Technology
- FlaskIn code
- HTMLIn code
- PythonIn code
3 of 3 appear in the indexed code.
AI coding agents
No AI coding agent signals were found in this repository.
Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.
Codebase size
Source size
750 KB
Source files
40
Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.
Repository
1300Sarthak/Helper
45 files · 755 KB · @ cb6f480
Structure
Interface
4 files · 9%Screens, components and styles rendered to the user.
API & routing
5 files · 11%Request entry points: routes, handlers and controllers.
Application logic
18 files · 40%Domain rules, services and shared utilities.
Data & schema
6 files · 13%Schema definitions, migrations and data access.
Supporting
Layers are inferred from where files sit in the tree, not from reading the code. A project that names its directories unconventionally will read oddly here — open the file browser to check anything the diagram implies.
Languages
- Markdown48%
- Python28%
- HTML24%
Share of indexed source by file size. Binary and vendored files are excluded.
Dependencies
requirements.txt
pypi · 5- Flask
- Flask-CORS
- Flask-SQLAlchemy
- python-dotenv
- requests
Declared in the repository’s manifests at the indexed commit. A declared package is not proof it is used, and runtime dependencies are listed first.
This project’s features have not been analysed yet.
Export this project's context (description, README, evidence, key source files) to chat with an AI agent elsewhere.