A production-ready AI assistant for financial advisors that integrates with Gmail, Google Calendar, and HubSpot CRM. The assistant provides intelligent responses using RAG (Retrieval-Augmented Generation) and can perform actions through tool calling.
- Authentication: Google OAuth (Gmail + Calendar) and HubSpot OAuth
- RAG Pipeline: Vector embeddings of emails and CRM data for intelligent responses
- Tool Calling: Automated actions across Gmail, Calendar, and HubSpot
- Proactive Agent: Memory-based instructions and event-driven actions
- Chat Interface: ChatGPT-like streaming interface with responsive design
- Frontend: React + TailwindCSS
- Backend: Python + FastAPI
- Database: PostgreSQL + pgvector
- AI: OpenAI API with embeddings and tool calling
- Auth: OAuth 2.0 (Google, HubSpot)
- Deployment: Docker + Docker Compose
advisor-ai/
├── frontend/ # React frontend
├── backend/ # FastAPI backend
├── database/ # Database migrations and schemas
├── docker-compose.yml # Local development setup
├── Dockerfile # Production Docker configuration
└── README.md # This file
- Docker and Docker Compose
- Google Cloud Console project with OAuth credentials
- HubSpot developer account
- OpenAI API key
Create .env files in both frontend/ and backend/ directories:
Backend .env:
DATABASE_URL=postgresql://user:password@localhost:5432/advisor_ai
OPENAI_API_KEY=your_openai_api_key
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
HUBSPOT_CLIENT_ID=your_hubspot_client_id
HUBSPOT_CLIENT_SECRET=your_hubspot_client_secret
SECRET_KEY=your_secret_key_for_jwtFrontend .env:
REACT_APP_API_URL=http://localhost:8000
REACT_APP_GOOGLE_CLIENT_ID=your_google_client_id
REACT_APP_HUBSPOT_CLIENT_ID=your_hubspot_client_id- Clone the repository
- Set up environment variables
- Start the development environment:
docker-compose up -d- Access the application:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
The application is configured for deployment on Render or Fly.io with Docker support.
- Data Ingestion: Gmail emails + HubSpot contacts/notes → embeddings → pgvector
- Query Processing: User question → embedding → similarity search → context retrieval
- Response Generation: Context + question → LLM → answer or action JSON
- Action Parsing: LLM outputs structured JSON
- Validation: Check contact existence, time availability, etc.
- Execution: Call Gmail, Calendar, HubSpot APIs
- Memory: Store tasks with status for continuation
- Memory System: Persistent storage of ongoing instructions
- Event Triggers: Webhooks/polling from Gmail, Calendar, HubSpot
- Action Execution: Automatic responses to events based on instructions
POST /auth/google- Google OAuth callbackPOST /auth/hubspot- HubSpot OAuth callbackGET /auth/me- Get current user info
POST /chat/message- Send message to AI assistantGET /chat/history- Get chat historyPOST /chat/stream- Streaming chat endpoint
POST /actions/execute- Execute tool calling actionGET /actions/tasks- Get pending tasksPUT /actions/tasks/{task_id}- Update task status
POST /rag/ingest- Ingest new data (emails, contacts)GET /rag/search- Search vector databasePOST /rag/query- Query with context retrieval
- Code Quality: TypeScript for frontend, Python + Pydantic for backend
- Error Handling: Graceful error handling with structured logging
- Testing: Unit and integration tests where appropriate
- Security: OAuth 2.0, JWT tokens, secure credential storage
- Performance: Async/await, connection pooling, efficient queries
- Follow the established code style and patterns
- Write tests for new features
- Update documentation as needed
- Ensure all CI/CD checks pass
Private - All rights reserved