This is a complete refactor of the Outlook Task Webhook service with improved organization and modularity.
refactored-app/
├── server.js # Main entry point
├── package.json # Dependencies and scripts
├── CLAUDE.md # Project instructions for Claude Code
├── OAUTH_GUIDE.md # OAuth setup guide
├── README.md # This file
├── config/
│ └── index.js # Configuration management
├── data/ # Data files (logs, cache, mappings)
│ ├── event-mappings.json # Google/Outlook event mappings
│ ├── subscription-cache.json # Webhook subscription cache
│ ├── google-token.json # Google tokens cache
│ └── task-service.log # Application logs
└── src/
├── auth/ # Authentication modules
│ ├── graph-auth.js # Microsoft Graph authentication
│ └── google-auth.js # Google OAuth authentication
├── managers/ # Business logic managers
│ └── subscription-manager.js # Webhook subscription management
├── middleware/ # Express middleware
│ └── logging.js # Request logging and error handling
├── routes/ # Express route handlers
│ ├── home.js # Homepage routes
│ ├── webhook.js # Webhook endpoints
│ ├── google-auth.js # Google authentication routes
│ ├── status.js # Status and health endpoints
│ ├── test.js # Testing endpoints
│ └── subscriptions.js # Subscription management routes
├── services/ # Core business services
│ ├── graph-client.js # Microsoft Graph API client
│ ├── event-processor.js # Task identification and processing
│ └── google-calendar-sync.js # Google Calendar synchronization
└── utils/ # Utility modules
└── logger.js # Logging utility
- Separated concerns into logical modules
- Clear separation between routes, services, auth, and utilities
- Easy to maintain and extend
- Home routes (
/): Main UI and navigation - Webhook routes (
/webhook): Microsoft Graph webhook handling - Google Auth routes (
/google-auth/*): Google authentication flows - Status routes (
/status): Service health and monitoring - Test routes (
/test/*): Testing and debugging endpoints - Subscription routes (
/subscriptions/*): Webhook subscription management
- Graph Client: Centralized Microsoft Graph API access
- Event Processor: Task identification and calendar operations
- Google Calendar Sync: Google Calendar integration
- Graph Auth: Microsoft Graph token management
- Google Auth: Google OAuth flow handling
- Centralized configuration in
config/index.js - Environment variable validation
- Clear separation of settings
- All data files organized in
data/folder - Event mappings, caches, and logs in one location
- Easy backup and migration
-
Install dependencies:
cd refactored-app npm install -
Configure environment: Copy your
.envfile to the refactored-app directory with all required variables. -
Run the application:
npm start
All original functionality has been preserved:
- ✅ Webhook-based event processing
- ✅ Task identification and calendar migration
- ✅ Google Calendar synchronization
- ✅ Authentication management
- ✅ Subscription auto-renewal
- ✅ Error handling and logging
- ✅ All existing endpoints and UI
- Maintainability: Code is organized by responsibility
- Scalability: Easy to add new features or modify existing ones
- Testability: Isolated modules can be tested independently
- Debugging: Clear separation makes issue tracking easier
- Documentation: Self-documenting structure
- Team Collaboration: Multiple developers can work on different modules
- The refactored version is completely self-contained
- No changes needed to existing
.envconfiguration - All data files are preserved and migrated
- Same port and endpoint structure maintained
- Backward compatible with existing webhooks and configurations
To add new features:
- New routes: Add to appropriate route file in
src/routes/ - New services: Create in
src/services/ - New auth providers: Add to
src/auth/ - New utilities: Add to
src/utils/
The modular structure makes it easy to understand where new code should go and how it should integrate with existing functionality.