How protolabo/accord works
Project Type and Purpose
• Accord is a full-stack desktop application (Electron + React) with a Python/FastAPI backend and MongoDB.
• It functions as a “wrapper” around existing email platforms (Gmail, Outlook) to add AI-powered classification, contextual grouping, and intelligent status tracking.
High-Level Components
• Frontend
• Electron shell (main.js, preload.js, forge.config.js)
• React SPA (under frontend/react-app)
• IPC layer (preload.js exposes safe APIs to React)
• HTTP client in React services (authService, EmailService, MockDataService)
• Backend (FastAPI)
• API entrypoint (backend/main.py)
• Routes layer (backend/app/routes/*.py)
• Core/dependencies/security (config.py, dependencies.py, security.py)
• Services layer
– Email services (email_service.py, email_sync.py, outlookClient.py, gmail_service.py)
– AI services (pipeline.py, intentDetector.py, subClassifier.py)
– Mail graph builder (graph_builder.py, nodes/, relations/)
– Export/status tracking (export_status, exportmail route)
• Data and persistence
– MongoDB connection & models (db/connection.py, db/models.py)
– Local mock data (for dev) under app/data/mockdata
• Background tasks (app/tasks/email_processor.py)
• Utility modules (keyphraser, dataGenerator, delete_token_file, killer_process)
• Data Stores & External Services
• MongoDB (NoSQL document store)
• OAuth2 endpoints for Gmail and Outlook APIs
• BERT NLP model (local or hosted via HuggingFace)
Relationships & Data Flows
• User opens Electron app → React UI makes HTTP requests (or IPC calls) to FastAPI endpoints
• FastAPI
• Auth routes perform OAuth handshake with Gmail/Outlook → token stored via utils/delete_token_file
• Email routes call email_providers modules to fetch messages → data stored in MongoDB
• AI routes/processors apply BERT classifiers → annotate emails & build message/user graphs
• Export routes schedule background tasks (email_processor)
• Frontend polls or subscribes (via HTTP) to export status, classification results, thread/group data
• React renders grouped/filtered emails, status indicators, user availability
Architectural Patterns & Principles
• Layered architecture: routes → services → data/DB → external APIs
• Dependency injection via FastAPI’s dependencies module
• Modular service components (email providers, AI, graph builder) for extensibility
• Electron/React separation: UI runs in a sandboxed renderer, core logic in main process or backend
• Asynchronous tasks for long-running operations (bulk email processing)