Gmail Detector is a Node.js application that uses the Gmail API to detect grammar and spelling issues in local files. It scans configured directories, creates temporary email drafts with file contents, and leverages Gmail’s language detection to extract suggested corrections. The tool supports automated batch processing of multiple files and generates detailed reports and logs of all identified issues and recommendations for review.
Built in 2021, integrating Gmail API for automated language analysis and reporting pipeline.
- 📧 Gmail API integration for authentication
- 📁 Scans files from specified directories
- ✍️ Creates email drafts with file contents
- ✅ Detects grammar and spelling mistakes
- 💡 Extracts recommended corrections
- 📊 Generates detailed logs and reports
- 🔄 Automated batch processing
- Gmail API Integration: Secure OAuth2 authentication and draft creation
- File Scanning: Automated scanning of configured directories
- Grammar & Spelling Detection: Leverages Gmail's built-in language detection
- Reporting: Detailed logs and correction recommendations
- Clean Architecture: Modular and maintainable code
- Error Handling: Unique error codes for easy troubleshooting
- Structured Logging: Comprehensive logging system
- Configuration Management: Flexible configuration system
- Easy Setup: Simple installation and configuration
- Clear Documentation: Detailed instructions
- Code Quality: Clean, readable, and maintainable
- Testable Architecture: Well-organized code structure
This project follows clean architecture principles:
- Modular Design: Code organized into separate modules
- Error Handling: Every error includes a unique error code
- Structured Logging: Comprehensive logging for all operations
- Configuration Management: Centralized configuration system
- Testability: Pure functions and modular design for easy testing
npm startThis will start the grammar and spelling checker, which will:
- Authenticate with Gmail API
- Scan configured directories
- Process each file
- Generate reports
Start the application:
npm startBackup project:
npm run backupgmail-detector/
├── src/ # Source code
├── misc/
│ ├── backups/ # Code backups
│ └── documents/ # Project documentation
│ ├── todo_tasks.txt # Planned features
│ ├── complete_tasks.txt # Finished tasks
│ ├── finalize_tasks.txt # Pre-release checklist
│ └── error_index.txt # Error codes reference
├── CONTRIBUTING.md # Contribution guidelines
├── INSTRUCTIONS.md # Detailed setup and usage
├── LICENSE # MIT License
└── README.md # This file
- Modular Architecture: Separation of concerns
- Configuration Pattern: Centralized configuration
- Error Handling Pattern: Unique error codes
- Logging Pattern: Structured logging
- Repository Pattern: File system operations
- Test with Dummy Account: Use a dummy Gmail account for testing
- Review Configuration: Verify all settings are correct
- Backup Files: Backup files before processing
- Start Small: Test with a small set of files first
- Clean Code: Keep code simple and readable
- Error Handling: Always handle errors with unique codes
- Logging: Log all important operations
- Documentation: Keep documentation up-to-date
- Testing: Test changes thoroughly
For questions, issues, or contributions:
- GitHub Issues: https://github.com/orassayag/gmail-detector/issues
- Email: orassayag@gmail.com
flowchart TD
A[Start Application] --> B[Authenticate with Gmail API]
B --> C[Scan Target Directory]
C --> D[Read File Contents]
D --> E[Create Email Draft]
E --> F[Run Grammar/Spelling Check]
F --> G[Extract Suggestions]
G --> H{More Files?}
H -->|Yes| D
H -->|No| I[Generate Report]
I --> J[Log Results]
J --> K[End]
style B fill:#4285f4,color:#fff
style F fill:#ea4335,color:#fff
style I fill:#34a853,color:#fff
sequenceDiagram
participant User
participant App
participant FileSystem
participant Gmail API
participant Report Generator
User->>App: npm start
App->>Gmail API: Authenticate
Gmail API-->>App: Access Token
App->>FileSystem: Scan Directory
FileSystem-->>App: File List
loop For Each File
App->>FileSystem: Read File Content
FileSystem-->>App: File Content
App->>Gmail API: Create Email Draft
App->>Gmail API: Check Grammar/Spelling
Gmail API-->>App: Suggestions
App->>Report Generator: Log Results
end
Report Generator-->>User: Final Report
- Node.js (v12 or higher)
- npm
- Gmail account (dummy account recommended)
- Google Cloud Project with Gmail API enabled
- Clone the repository:
git clone https://github.com/orassayag/gmail-detector.git
cd gmail-detector- Install dependencies:
npm install- Set up Gmail API credentials:
- Create a project in Google Cloud Console
- Enable the Gmail API
- Create OAuth2 credentials
- Download and configure credentials
Configure the application settings:
- Set source directory path for files to check
- Define file extensions to scan
- Configure output directory for logs
- Set up Gmail API credentials path
Start the grammar/spelling checker:
npm startThe application will:
- Authenticate with Gmail
- Scan the configured directory
- Process each file
- Create email drafts
- Extract grammar/spelling suggestions
- Generate a comprehensive report
All errors include a unique serial number (starting from 1000000) for easy identification. See misc/documents/error_index.txt for the complete error code reference.
This project is in the planning/early development phase. See misc/documents/todo_tasks.txt for planned features:
Planned Features:
- Copy code from 'udemy-courses' project
- Set up Gmail account integration
- Implement file scanning functionality
- Create email draft generation
- Extract grammar/spelling suggestions
- Implement logging and reporting
The project follows these principles:
- Clean, simple, and readable code
- Clear and consistent naming conventions
- Modular code structure
- Comprehensive error handling with unique error codes
- Well-documented code with explanatory comments
Before making changes:
- Create a backup (
npm run backupor manually) - Review maintenance checklist
After making changes:
- Verify everything works
- Update documentation if needed
- Commit and push to Git
- Update external backups
Contributions to this project are released to the public under the project's open source license.
Everyone is welcome to contribute. Contributing doesn't just mean submitting pull requests—there are many different ways to get involved, including answering questions and reporting issues.
Please feel free to contact me with any question, comment, pull-request, issue, or any other thing you have in mind.
See CONTRIBUTING.md for detailed contribution guidelines.
- Or Assayag - Initial work - orassayag
- Or Assayag orassayag@gmail.com
- GitHub: https://github.com/orassayag
- StackOverflow: https://stackoverflow.com/users/4442606/or-assayag?tab=profile
- LinkedIn: https://linkedin.com/in/orassayag
This application has an MIT license - see the LICENSE file for details.
- Built for educational and research purposes
- Respects robots.txt and implements rate limiting
- Uses user-agent rotation to avoid detection
- Implements polite crawling practices