How mouadbra/ai-agent works
This is a chat-based executive assistant: users connect Google, ask for calendar or email actions, and receive an AI-generated reply. The frontend loads and resets conversation history and sends chat and OAuth-token requests to the FastAPI backend. The chat handler invokes the agent loop, which loads and saves the thread, calls Azure OpenAI, and dispatches any requested tool to Google Calendar or Gmail functions. OAuth credentials and conversation threads persist in SQLite on a Modal volume. The README documents all five tools; sampled backend code confirms their dispatch and integrations.
Main entry points: main.py HTTP endpoints · App.tsx Chat and OAuth UI · agent.py Agent loop · functions.py Calendar and Gmail tools
Components 11
Chat frontend
- Chat and OAuth UI
frontend_service/src/App.tsx
Backend API
- HTTP endpoints
backend_service/src/modal_app/main.py
Agent orchestration
- Agent loop
backend_service/src/modal_app/agent.py - Azure OpenAI
- Tool dispatcher
backend_service/src/modal_app/functions.py
Integrations and state
- Calendar and Gmail tools
backend_service/src/modal_app/functions.py - Google Calendar and Gmail
- Google OAuth
- SQLite database
backend_service/src/modal_app/main.py - Modal volume
backend_service/src/modal_app/common.py
Other components
- User
Connections 15
- User → Chat and OAuth UI: sends requests
- Chat and OAuth UI → HTTP endpoints: calls chat/history/reset
- Chat and OAuth UI → Google OAuth: requests access token
- Google OAuth → Chat and OAuth UI: returns token
- Chat and OAuth UI → HTTP endpoints: posts token
- HTTP endpoints → Agent loop: processes chat
- Agent loop → Azure OpenAI: requests completion
- Agent loop → Tool dispatcher: dispatches tool call
- Tool dispatcher → Calendar and Gmail tools: calls selected tool
- Calendar and Gmail tools → SQLite database: reads credentials
- Calendar and Gmail tools → Google Calendar and Gmail: calls Calendar/Gmail
- Agent loop → SQLite database: loads and saves thread
- HTTP endpoints → SQLite database: reads history; stores token
- HTTP endpoints → SQLite database: deletes thread
- HTTP endpoints → Modal volume: reloads and commits