Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

🤖 Bots

AI-powered application prototypes with model integration, APIs, databases, and deployable interfaces.

A collection of intelligent bots built with state-of-the-art transformer models and real-time data processing pipelines, ready for production deployment.


📋 Table of Contents


🎯 Overview

Bots is a comprehensive repository showcasing multiple AI-powered bot implementations:

  • T5 Bot: Advanced text-to-text generation (summarization, translation) using Google's T5 model
  • CandleBot: Real-time forex candlestick data collection and persistence with intelligent failover

Each bot demonstrates production-ready patterns including REST APIs, database integration, containerization, and scalable deployment configurations.


🚀 Projects

T5 Bot

A full-stack NLP application that uses Google's T5 (Text-to-Text Transfer Transformer) model to perform advanced text operations.

Capabilities:

  • 📝 Text Summarization
  • 🌍 Multi-language Translation (English, French, German)
  • 🔄 Chained Operations (summarize → translate)

Architecture:

  • Backend: FastAPI with async support
  • Frontend: React 18 with Vite
  • Database: PostgreSQL
  • ML Framework: PyTorch + Hugging Face Transformers

Key Files:

  • T5/T5_Bot/app.py - Flask application with T5 endpoints
  • T5/requirements.txt - Python dependencies
  • T5/docker-compose.yml - Full stack orchestration

CandleBot

A specialized bot for capturing financial market data in real-time from MetaTrader 5, with built-in resilience for network failures.

Capabilities:

  • 📊 Real-time 1-minute candlestick data collection from EURUSD
  • 💾 Persistent storage to SQL Server
  • 🔄 Automatic offline mode with sync on reconnection
  • 📝 Comprehensive logging and error tracking

Key Files:

  • CandleBot/save_realtime_candles.py - Main data collection script

🛠️ Tech Stack

Backend

  • Python 3.10+ - Core language
  • FastAPI - Modern async web framework
  • Flask - Lightweight alternative for T5_Bot
  • PyTorch 2.1+ - Deep learning framework
  • Transformers 4.30+ - NLP models (Hugging Face)
  • SQLAlchemy 2.0+ - ORM for database interactions
  • Uvicorn - ASGI server

Database

  • PostgreSQL 15 - Primary data store
  • SQL Server - CandleBot data persistence

Frontend

  • React 18 - UI library
  • Vite - Build tool and dev server
  • Axios - HTTP client
  • React Router - Client-side routing

DevOps & Tools

  • Docker - Containerization
  • Docker Compose - Multi-container orchestration
  • pytest - Testing framework
  • Black - Code formatting
  • Flake8 - Linting
  • mypy - Type checking

⚡ Quick Start

T5 Bot (Docker Compose - Recommended)

# Clone the repository
git clone https://github.com/Maee127/Bots.git
cd Bots/T5

# Configure environment
cp .env.example .env
# Edit .env with your settings (DB credentials, API host, debug mode, etc.)

# Start all services (Postgres, API, Frontend)
docker-compose up --build

# Services will be available at:
# - API: http://localhost:8000
# - Frontend: http://localhost:5173
# - PostgreSQL: localhost:5432

T5 Bot (Local Development)

cd Bots/T5

# Create virtual environment
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env

# Run FastAPI server
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

# In another terminal, start frontend
cd frontend
npm install
npm run dev

CandleBot

cd Bots/CandleBot

# Install dependencies
pip install MetaTrader5 pyodbc pandas

# Configure SQL Server connection in save_realtime_candles.py
# Update the connection string with your database credentials

# Run the bot
python save_realtime_candles.py

📁 Project Structure

Bots/
├── T5/                              # T5 Text-to-Text Bot
│   ├── T5_Bot/                      # Flask application
│   │   ├── app.py                   # Main Flask app with ML endpoints
│   │   ├── templates/               # HTML templates
│   │   │   └── index.html           # Web interface
│   │   ├── static/                  # Frontend assets
│   │   │   ├── style.css            # Styling
│   │   │   ├── script.js            # Client-side logic
│   │   │   └── assets/              # Images and resources
│   │   └── requirements.txt         # Project dependencies
│   ├── frontend/                    # React application (Vite)
│   │   ├── src/                     # React components
│   │   ├── public/                  # Static assets
│   │   ├── vite.config.js           # Vite configuration
│   │   └── package.json             # NPM dependencies
│   ├── app/                         # FastAPI application (planned)
│   │   └── main.py                  # FastAPI entry point
│   ├── requirements.txt             # Python dependencies
│   ├── pyproject.toml               # Project configuration
│   ├── setup.py                     # Python package setup
│   ├── Dockerfile                   # Multi-stage build
│   ├── docker-compose.yml           # Full stack composition
│   ├── .env.example                 # Environment variables template
│   └── README.md                    # T5 Bot documentation
│
├── CandleBot/                       # Forex Data Collection Bot
│   ├── save_realtime_candles.py     # Main data collection script
│   ├── logs/                        # Log directory
│   └── EURUSD_candle_logger.log     # Log file
│
├── README.md                        # This file
└── .gitignore                       # Git ignore rules

✨ Features

T5 Bot

  • ✅ Text Summarization - Condense long texts while preserving meaning
  • ✅ Multi-language Translation - Translate between English, French, and German
  • ✅ Chained Operations - Summarize then translate in one workflow
  • ✅ REST API - FastAPI endpoints for programmatic access
  • ✅ Web UI - React-based user interface
  • ✅ Database Integration - Store and retrieve operations
  • ✅ Containerized - Docker support for easy deployment
  • ✅ Scalable - Async processing with uvicorn

CandleBot

  • ✅ Real-time Data - 1-minute candlestick data from MetaTrader 5
  • ✅ Persistent Storage - SQL Server integration
  • ✅ Offline Resilience - JSON fallback when database is unavailable
  • ✅ Auto-sync - Automatic data synchronization on reconnection
  • ✅ Comprehensive Logging - Detailed logs for monitoring and debugging
  • ✅ Error Handling - Graceful failure recovery

📦 Installation

Prerequisites

  • Python 3.10+ - Core runtime
  • Node.js 16+ - Frontend build tools
  • Docker & Docker Compose - For containerized deployment
  • PostgreSQL - For T5 Bot database (or use Docker image)
  • SQL Server - For CandleBot (optional, uses offline fallback if unavailable)

Step-by-Step Setup

1. Clone the Repository

git clone https://github.com/Maee127/Bots.git
cd Bots

2. T5 Bot Setup

Option A: Docker Compose (Recommended)

cd T5
cp .env.example .env
docker-compose up --build

Option B: Local Development

cd T5

# Python setup
python -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

# Frontend setup
cd frontend
npm install

# Back to T5 root
cd ..

3. CandleBot Setup

cd CandleBot
pip install MetaTrader5 pyodbc pandas
# Configure database connection in save_realtime_candles.py

🎮 Usage

T5 Bot - Text Summarization

Via REST API:

curl -X POST http://localhost:8000/api/summarize \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Your long text here that you want to summarize..."
  }'

Via Web UI:

  1. Navigate to http://localhost:5173
  2. Enter text in the input area
  3. Click "Summarize in Original Language"
  4. View results in the output box

T5 Bot - Translation

Via REST API:

curl -X POST http://localhost:8000/api/translate \
  -H "Content-Type: application/json" \
  -d '{
    "text": "Hello, how are you?",
    "source_language": "English",
    "target_language": "French"
  }'

Via Web UI:

  1. Select source and target languages
  2. Enter text
  3. Click "Translate Original Text"
  4. View translated result

T5 Bot - Chained Operations

  1. Summarize text
  2. Translate the summary to another language
  3. Click "Translate Summary"

CandleBot - Data Collection

cd CandleBot
python save_realtime_candles.py

What it does:

  • Connects to MetaTrader 5
  • Fetches EURUSD 1-minute candles
  • Stores in SQL Server
  • Falls back to JSON file if database unavailable
  • Syncs offline data when connection restored
  • Logs all operations to EURUSD_candle_logger.log

🚢 Deployment

Docker Deployment (T5 Bot)

Build Image:

cd T5
docker build -t bots:latest .

Run Container:

docker run -p 8000:8000 \
  -e DATABASE_URL="postgresql://user:pass@postgres:5432/bots" \
  -e DEBUG=false \
  bots:latest

Docker Compose (Full Stack)

cd T5
docker-compose up -d

Environment Configuration (.env):

# Database
DB_USER=bots_user
DB_PASSWORD=secure_password_here
DB_NAME=bots

# API
PYTHON_ENV=production
DEBUG=false
API_HOST=0.0.0.0
API_PORT=8000

# Frontend
VITE_API_URL=https://your-api-domain.com

Cloud Deployment

The repository is structured for easy deployment to:

  • AWS (ECS, Lambda, RDS)
  • Google Cloud (Cloud Run, Cloud SQL)
  • Azure (Container Instances, PostgreSQL)
  • Heroku (with Procfile)
  • Kubernetes (with Helm charts)

🛠️ Development

Running Tests

cd T5

# Run all tests
pytest

# Run with coverage
pytest --cov=app

# Run specific test file
pytest tests/test_bot.py

Code Quality

cd T5

# Format code with Black
black .

# Lint with Flake8
flake8 .

# Type check with mypy
mypy .

# Frontend linting
cd frontend
npm run lint
npm run format

Development Server with Hot Reload

cd T5

# Terminal 1: Backend
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000

# Terminal 2: Frontend
cd frontend
npm run dev

API Documentation

Once the FastAPI server is running:


🤝 Contributing

We welcome contributions! Please follow these steps:

  1. Fork the repository

    git clone https://github.com/yourusername/Bots.git
    cd Bots
  2. Create a feature branch

    git checkout -b feature/amazing-feature
  3. Make your changes

    • Write clean, well-documented code
    • Add tests for new functionality
    • Follow the existing code style (Black, Flake8)
  4. Commit your changes

    git commit -m 'Add amazing feature'
  5. Push to your fork

    git push origin feature/amazing-feature
  6. Open a Pull Request

    • Provide a clear description of changes
    • Link any related issues
    • Include screenshots for UI changes

Code Style Guidelines

  • Use Black for Python formatting
  • Use Prettier for JavaScript formatting
  • Write type hints for Python functions
  • Add docstrings to classes and functions
  • Keep lines under 88 characters (Black default)

📝 License

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

You are free to use, modify, and distribute this software for any purpose, including commercial use.


👤 Author

Maee127 - GitHub Profile


🙏 Acknowledgments


💬 Support & Issues


📊 Project Stats

  • Language: Python (58%), CSS (16.1%), HTML (10%), JavaScript (9.1%), Dockerfile (6.8%)
  • Repository: Maee127/Bots
  • License: MIT
  • Status: Active Development

🗺️ Roadmap

  • Enhanced FastAPI backend with full OpenAPI documentation
  • Advanced model fine-tuning and custom training pipelines
  • Real-time WebSocket support for live updates
  • Multi-model orchestration (BERT, GPT, T5 variants)
  • Production-grade monitoring and observability
  • Kubernetes deployment manifests
  • CI/CD pipeline with GitHub Actions
  • Performance optimization and caching layer

Made by MAedeh Torkian: Maee127


This README includes:
- ✅ Clear project overview
- ✅ Detailed quick start guides for both projects
- ✅ Complete tech stack documentation
- ✅ Installation and setup instructions
- ✅ Usage examples with code snippets
- ✅ Deployment guidelines
- ✅ Development workflow
- ✅ Contributing guidelines
- ✅ Professional structure and formatting
- ✅ Links to resources and support

You can now copy this and create your `README.md` file in the root of your repository!

About

AI-powered application prototypes with model integration, APIs, databases, and deployable interfaces.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages