Skip to content

Tanyasharma71/peacebot-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

81 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ•ŠοΈ Peacebot-AI β€” Your Friendly Mental Health Companion

GitHub Repo stars GitHub forks GitHub issues License

πŸ“‘ Table of Contents


πŸ§˜β€β™€οΈ Introduction

Peacebot-AI is an AI-powered mental health chatbot designed to provide empathetic conversations, stress management tips, and mindfulness guidance to users seeking emotional support.

It aims to create a safe, non-judgmental, and supportive environment through intelligent and compassionate AI-driven dialogue. 🌸


πŸ’‘ Key Features

  • πŸ’¬ Conversational support for stress, anxiety, and emotional wellness
  • 🧠 Natural language responses powered by OpenAI’s GPT models
  • πŸ“š Personalized mindfulness & coping strategies
  • πŸ”’ Privacy-first β€” no user data storage or profiling
  • πŸ•’ Available anytime, anywhere, for daily motivation and reflection
  • βš™οΈ Modular architecture for easy customization and expansion

🧰 Tech Stack

Component Technology
Language Python
Backend Framework Flask
AI Integration OpenAI GPT API
Frontend HTML, CSS, JavaScript
Configuration Management configparser, .env support
Logging Python logging (JSON-structured logs)
Version Control Git & GitHub

πŸ—‚οΈ Project Structure

peacebot-ai/
β”œβ”€β”€ src/
β”‚ β”œβ”€β”€ app.py # Flask entry point
β”‚ β”œβ”€β”€ peacebot.py # Core AI response logic
β”‚ β”œβ”€β”€ utils/
β”‚ β”‚ β”œβ”€β”€ config_loader.py # Handles .ini config and fallbacks
β”‚ β”‚ β”œβ”€β”€ logger_config.py # JSON-based structured logging
β”‚ β”‚ β”œβ”€β”€ retry_utils.py # Retry & exponential backoff logic
β”‚ β”‚ └── init.py
β”‚ β”œβ”€β”€ static/
β”‚ β”‚ β”œβ”€β”€ index.html # Frontend chat interface
β”‚ β”‚ └── js/
β”‚ β”‚ └── script.js
β”‚ └── init.py
β”‚
β”œβ”€β”€ gratitude_log.json # Logs user gratitude entries
β”œβ”€β”€ peacebot.ini # Config file (API keys, retry, etc.)
β”œβ”€β”€ requirements.txt # Python dependencies
β”œβ”€β”€ .env # (Optional) API key storage
β”œβ”€β”€ README.md # Project documentation
└── LICENSE # MIT License

πŸš€ Quickstart

1️⃣ Create and activate a virtual environment

Windows PowerShell

python -m venv .venv
.venv\Scripts\Activate.ps1

macOS/Linux

python3 -m venv .venv
source .venv/bin/activate

2️⃣ Install dependencies

pip install -r requirements.txt

3️⃣ Configure your API key

Option 1 β€” Using Environment Variable

setx OPENAI_API_KEY "your_openai_key_here"

Option 2 β€” Using .env File

Create a .env file in the project root:

OPENAI_API_KEY=your_openai_key_here

4️⃣ Run the App

python src/app.py

Visit http://127.0.0.1:5000 in your browser. You can chat with Peacebot directly in the web interface.

5️⃣ API Usage

Method Endpoint Description
POST /api/chat Send a message to Peacebot and receive a response

Example Request:

{
  "message": "I'm feeling anxious today."
}

Example Response:

{
  "response": "I hear you. It sounds like you're having a tough day. Try a short breathing exercise β€” inhale deeply for 4 seconds..."
}

🧩 Configuration (peacebot.ini)

Example peacebot.ini:

[openai]
api_key = your_openai_key_here
model = gpt-3.5-turbo

[retry]
max_retries = 3
base_delay = 2

[logging]
level = INFO

πŸ”„ Logging Example

Peacebot logs structured information for traceability:

{"time": "2025-11-08 14:42:01", "level": "INFO", "module": "peacebot", "message": "Response generated successfully"}
{"time": "2025-11-08 14:42:05", "level": "WARNING", "module": "peacebot.retry", "message": "Retry 1/3 for OpenAI request"}

🌱 Future Scope

  • 🧩 Integrate emotion detection using NLP
  • πŸ“ˆ Add mood visualization dashboard
  • πŸ—“οΈ Implement daily mental wellness check-ins
  • πŸ” Optional user authentication for personal sessions
  • πŸ’Ύ Support cloud-based session storage
  • 🧠 Add local LLM fallback (offline mode)

🀝 Contributing

We welcome all contributions!
Please read the CONTRIBUTING.md file before submitting pull requests.

To suggest new ideas or report bugs:
Open an issue in the Issues tab with descriptive titles and clear acceptance criteria Example Issue Ideas

ID Issue Title Summary
#2 Add Config System Introduce configparser-based modular configuration
#3 Retry & Failure Handling Add exponential backoff for API resilience
#4 Add Emotion Classification Use sentiment analysis to tailor responses
#5 Web Dashboard Visualize user moods and gratitude logs

πŸ“‘ Contribution Guidelines

  • ⭐ Star the repository to show your support.
  • 🍴 Fork the repo and create a new branch for your feature, fix, or idea.
  • πŸ’» Make your changes β€” code, design, documentation, anything that improves the project!
  • βœ… Commit your updates with a meaningful message.
  • πŸ” Create a Pull Request β€” our team will review, suggest, and merge if all looks great.
  • πŸ–ΌοΈ Add screenshots or demo links if applicable.

For more detailed steps, see the CONTRIBUTING.md file.


🧑 Contributing is Fun!

We welcome all contributions and ideas β€” whether it's:

  • A new feature ✨
  • UI/UX improvements 🎨
  • Bug fixes πŸ›
  • or Documentation updates πŸ“˜

Your voice matters!
Feel free to open issues, start discussions, or reach out with feedback πŸ’¬


πŸ‘₯ Contributors

Thanks to these wonderful people for contributing to PeaceBot-AI πŸ’–

Contributors

Contributors Graph by Vaunt.dev


πŸ§ͺ Running the Test Suite

Peacebot now includes a robust test suite for its core backend utilities and tracing middleware.

1️⃣ Run All Tests

From your project root:

pytest -v

2️⃣ Run a Specific Test File

For example, to only test the retry utility:

pytest tests/test_retry_utils.py -v

3️⃣ βœ… Expected Output

===================== test session starts =====================
collected 9 items

tests/test_request_id_context.py ....                      [ 25%]
tests/test_logger_config.py ....                           [ 50%]
tests/test_retry_utils.py ....                             [ 75%]
tests/test_decorators.py ....                              [100%]

====================== 9 passed in 1.52s ======================

πŸ“„ License

This project is licensed under the MIT License. See the LICENSE file for details.

πŸ’¬ A Final Note

πŸ§˜β€β™€οΈ PeaceBot-AI β€” Because everyone deserves a moment of peace.
β€œThe greatest weapon against stress is our ability to choose one thought over another.” β€” William James

⭐ If you find this project helpful, consider giving it a star on GitHub!

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 10