Skip to content

Repetto-A/cotibot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Agromaq Quotation System

A comprehensive quotation system for agricultural machinery with web interface, API, and Telegram bot integration.

🚀 Features

  • Web Interface: Modern React frontend with Tailwind CSS
  • Dynamic Catalog: Organized machinery catalog with 10+ categories and 50+ products
  • REST API: FastAPI backend for quotation management
  • Telegram Bot: Generate quotations, search products, and manage prices via Telegram
  • PDF Generation: Professional quotation PDFs with company branding
  • Admin Dashboard: Web-based admin panel for managing quotations
  • Database: SQLite/PostgreSQL support for data persistence
  • Search Functionality: Advanced search across products and categories

📸 Screenshots

Panel de Control

Panel de Control

Login del panel de Administración

Acceso al Panel

Panel de Administración

Panel de Administración

Interacción con el Bot de Telegram

Bot de Telegram

🏗️ Architecture

Frontend (React/Vite) → API (FastAPI) → Database (SQLite)
                    ↘
                     Telegram Bot

🛠️ Local Development Setup

Prerequisites

  • Node.js 18+
  • Python 3.11+
  • Git

Frontend Setup

  1. Install dependencies:
npm install
  1. Start development server:
npm run dev

The frontend will be available at http://localhost:5173

Backend Setup

  1. Navigate to backend directory:
cd backend
  1. Create virtual environment:
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install -r requirements.txt
  1. Copy environment variables:
cp .env.example .env
  1. Configure environment variables in .env:
TELEGRAM_TOKEN=your_telegram_bot_token
ADMIN_USER_IDS=123456789,987654321
API_BASE_URL=http://localhost:8000
ADMIN_USER=admin
ADMIN_PASS=your_secure_password
  1. Start the API server:
uvicorn app:app --reload

API will be available at http://localhost:8000

Telegram Bot Setup

  1. Create a bot with @BotFather
  2. Get your bot token and add it to .env
  3. Get your Telegram user ID and add it to ADMIN_USER_IDS
  4. Run the bot:
python telegram_bot.py

🚀 Deployment

Frontend Deployment (Vercel)

  1. Install Vercel CLI:
npm install -g vercel
  1. Deploy:
vercel --prod

Backend Deployment (Render)

  1. Fork this repository
  2. Create a new Web Service on Render
  3. Connect your repository
  4. Set environment variables:
    • ADMIN_USER: Admin username
    • ADMIN_PASS: Admin password
    • TELEGRAM_TOKEN: Your Telegram bot token
    • ADMIN_USER_IDS: Comma-separated list of admin Telegram user IDs

The render.yaml file will handle the deployment automatically.

Environment Variables

Create the following environment variables in your deployment platform:

Backend (Render):

  • ADMIN_USER: Admin username for web dashboard
  • ADMIN_PASS: Admin password for web dashboard
  • TELEGRAM_TOKEN: Telegram bot token
  • ADMIN_USER_IDS: Comma-separated admin Telegram user IDs

Frontend (Vercel):

  • VITE_API_URL: URL of your deployed backend API

📱 Telegram Bot Commands

User Commands

  • /start - Welcome message and command list
  • /help - Show available commands
  • /list_machines - List all available machines with prices
  • /search <term> - Search machinery by name or category
  • /quote <code> <name> <contact> - Generate quotation

Admin Commands

  • /set_price <code> <price> - Update machine price

Example Usage

/search tolva
/quote ACO001 Juan Pérez +54911234567
/set_price ACO001 40000
/list_machines

🧪 Testing

Backend Tests

cd backend
pytest tests/ -v

Frontend Tests

npm test

🎨 Customization

Brand Colors

Update the brand colors in tailwind.config.js:

colors: {
  'agromaq-green': {
    600: '#16a34a', // Primary green
    // ... other shades
  },
  'agromaq-yellow': {
    500: '#eab308', // Primary yellow
    // ... other shades
  }
}

Company Logo

Replace the Tractor icon in the header with your actual logo:

// In src/App.tsx
<div className="w-10 h-10 bg-green-600 rounded-lg flex items-center justify-center">
  <img src="/logo.png" alt="Agromaq" className="w-6 h-6" />
</div>

📊 API Documentation

Once the backend is running, visit:

  • API Docs: http://localhost:8000/docs
  • Alternative Docs: http://localhost:8000/redoc

Key Endpoints

  • GET /machines - List all machines
  • POST /quotation - Create new quotation
  • GET /quotation/{id}/download - Download quotation PDF
  • GET /admin/quotations - List all quotations (admin only)
  • PUT /admin/machine/{code}/price - Update machine price (admin only)

Machine Categories

The system includes the following product categories:

  • Acoplados rurales: 7 products
  • Acoplados tanque: 7 products
  • Tolvas: 8 products
  • Cargadores y elevadores: 3 products
  • Carretón: 1 product
  • Otros implementos rurales: 2 products
  • Palas de arrastre: 5 products
  • Rastras: 5 products
  • Sin fines (transportadores): 4 products
  • Tráilers: 1 product

🔐 Security

  • Admin authentication using HTTP Basic Auth
  • Telegram bot admin verification via user ID whitelist
  • Environment variables for sensitive data
  • CORS configuration for production

📈 Monitoring

  • Application logs via standard Python logging
  • Database queries monitored
  • API endpoint performance tracking
  • Telegram bot error handling

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

📄 License

This project is licensed under the MIT License.

Built with ❤️

About

Agricultural machinery quotation system — Telegram bot for field use, React web admin panel, FastAPI backend, PDF generation, 50+ products

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors