Skip to content

MdHicham/RappelOn-API

Repository files navigation

Rappelon API πŸ“§

A smart email monitoring and reminder system that automatically scans your Gmail inbox for important emails and sends you reminders when action is needed.

🌟 Features

  • Automated Email Scanning: Monitors your Gmail inbox for specific keywords
  • Smart Categorization: Automatically labels emails as "Urgent" or "Offers" based on content
  • Reminder System: Sends you email reminders for emails that need attention
  • REST API: Simple HTTP endpoints to trigger email processing
  • Configuration Management: Easy-to-use API for updating settings
  • CORS Support: Ready for frontend integration

πŸš€ Quick Start

Prerequisites

  • .NET 8.0 SDK
  • Gmail account with App Password enabled
  • IMAP access enabled in Gmail

Installation

  1. Clone the repository

    git clone <repository-url>
    cd Rappelon-api
  2. Configure your Gmail settings

    Copy config.example.json to config.json and update with your credentials:

    {
      "imap_server": "imap.gmail.com",
      "smtp_server": "smtp.gmail.com",
      "smtp_port": 465,
      "email_user": "your-email@gmail.com",
      "email_pass": "your-app-password",
      "keywords_urgent": ["urgent", "immediate", "important"],
      "keywords_offre": ["offer", "promotion", "deal"],
      "check_folder": "INBOX",
      "max_emails_to_check": 20
    }
  3. Restore packages and run

    dotnet restore
    dotnet build
    dotnet run
  4. Access the API

    • Swagger UI: https://localhost:7198/swagger
    • API Base URL: https://localhost:7198/api

πŸ“‘ API Endpoints

Email Processing

  • GET /api/email/check - Trigger email scanning and processing

Configuration Management

  • GET /api/config - Get current configuration
  • PUT /api/config - Update configuration

βš™οΈ Configuration

The system uses a config.json file with the following parameters:

Parameter Description Example
imap_server Gmail IMAP server "imap.gmail.com"
smtp_server Gmail SMTP server "smtp.gmail.com"
smtp_port SMTP port (usually 465) 465
email_user Your Gmail address "user@gmail.com"
email_pass Gmail App Password "abcdefghijklmnop"
keywords_urgent Keywords for urgent classification ["urgent", "asap"]
keywords_offre Keywords for offer classification ["sale", "discount"]
check_folder Gmail folder to monitor "INBOX"
max_emails_to_check Number of recent emails to scan 20

πŸ” Gmail Setup

  1. Enable 2-Factor Authentication on your Gmail account
  2. Generate an App Password:
    • Go to Google Account settings
    • Security β†’ 2-Step Verification β†’ App passwords
    • Generate a password for "Mail"
    • Use this password in config.json
  3. Enable IMAP:
    • Gmail Settings β†’ Forwarding and POP/IMAP
    • Enable IMAP access

πŸ—οΈ Architecture

β”œβ”€β”€ Controllers/
β”‚   β”œβ”€β”€ EmailController.cs    # Email processing endpoints
β”‚   └── ConfigController.cs   # Configuration management
β”œβ”€β”€ Services/
β”‚   └── EmailProcessor.cs     # Core email processing logic
β”œβ”€β”€ Models/
β”‚   └── Config.cs            # Configuration model
└── config.json              # Application configuration

πŸ”§ Development

Project Structure

  • EmailProcessor: Core service that handles Gmail connection and email processing
  • EmailController: REST API endpoints for triggering email processing
  • ConfigController: API for managing application configuration
  • Config/ConfigLoader: Configuration management utilities

Key Features

  • Dependency Injection: EmailProcessor is registered as a scoped service
  • Error Handling: Comprehensive error handling with detailed logging
  • CORS: Configured for frontend integration (React on localhost:3000)
  • Swagger: Auto-generated API documentation

Building

dotnet build

Running Tests

dotnet test

πŸš€ Deployment

Development

dotnet run --environment Development

Production

dotnet publish -c Release

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“ License

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

πŸ› Troubleshooting

Common Issues

  1. Authentication Failed

    • Verify your Gmail App Password is correct
    • Ensure 2FA is enabled on your Google account
  2. IMAP Connection Issues

    • Check that IMAP is enabled in Gmail settings
    • Verify firewall isn't blocking ports 993/465
  3. No Emails Processed

    • Check that your keywords match email content
    • Verify max_emails_to_check is sufficient
    • Ensure emails aren't already replied to
  4. Port Already in Use

    • Stop any running instances: taskkill /f /im Rappelon-api.exe
    • Or change ports in launchSettings.json

πŸ“ž Support

  • Create an issue for bug reports
  • Submit feature requests via GitHub issues
  • Check existing issues before creating new ones

πŸ™ Acknowledgments

  • Built with ASP.NET Core 8.0
  • Uses MailKit for Gmail integration
  • Swagger for API documentation