Skip to content

Commit 36ed09b

Browse files
NihalMouni29claude
andcommitted
TaxAssist: full working release - light UI, email-approval agent runs, Drive/Sheets artifacts, per-user Google OAuth, Cloud Run deploy
- React frontend (light institutional design): landing page, dashboard, profile workspace with live agent activity, transparency panel, Drive/Sheets quick access - Real human-in-the-loop: agent emails extracted figures, resumes on CONFIRM reply - Agent creates a real Drive folder + results Sheet per profile and links them - Per-user Google OAuth (web client) with encrypted tokens in the control plane - Single-container Dockerfile (frontend baked in), Cloud Run deploy script - Profile-created email notifications; cache and account-switch fixes Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
0 parents  commit 36ed09b

118 files changed

Lines changed: 14513 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
.git
2+
.github
3+
**/__pycache__
4+
*.pyc
5+
.pytest_cache
6+
.ruff_cache
7+
venv
8+
.venv
9+
.env
10+
env.txt
11+
credentials.json
12+
client_secret.json
13+
token.json
14+
docs
15+
*.md
16+
mongodb-mcp
17+
frontend/node_modules
18+
frontend/dist
19+
app/static
20+
*.db
21+
.backend.log
22+
.oauth.log

.env.example

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# ── TaxAssist environment ─────────────────────────────────────────────────────
2+
# Copy to .env (gitignored) and fill in. 🔑 = secret, never commit.
3+
# Generate secrets:
4+
# AGENT_SECRET_KEY : python -c "import secrets; print(secrets.token_hex(32))"
5+
# CONTROL_ENC_KEY : python -c "from cryptography.fernet import Fernet; print(Fernet.generate_key().decode())"
6+
# MONGODB_MCP_TOKEN : python -c "import secrets; print(secrets.token_hex(24))"
7+
8+
# ── Data plane (MongoDB Atlas + partner MCP server) ──
9+
MONGO_URI=mongodb+srv://USER:PASS@cluster0.xxxxx.mongodb.net/?retryWrites=true&w=majority # 🔑
10+
MONGODB_MCP_URL=http://mongodb-mcp:3000/mcp # http://127.0.0.1:3000/mcp for local
11+
MONGODB_MCP_TOKEN= # 🔑 static bearer (non-Cloud-Run)
12+
MONGODB_MCP_USE_IAM= # 1 on Cloud Run: use Google IAM ID tokens instead
13+
MONGODB_DB=tax_agent_db
14+
15+
# ── Control plane (Postgres) + queue (Redis) ──
16+
POSTGRES_URL=postgresql+psycopg://tax:PASS@postgres:5432/tax_control # 🔑 (omit -> SQLite dev)
17+
REDIS_URL=redis://redis:6379/0
18+
19+
# ── Gemini ──
20+
GOOGLE_API_KEY= # 🔑 Gemini API key (GEMINI_API_KEY also works)
21+
ORCHESTRATOR_MODEL=gemini-2.0-flash # optional
22+
23+
# ── Security ──
24+
AGENT_SECRET_KEY= # 🔑 gateway HMAC
25+
AGENT_REQUIRE_SIGNATURE=1 # 1 in prod (signed-request mode)
26+
CONTROL_ENC_KEY= # 🔑 Fernet key (encrypts OAuth tokens)
27+
POLL_TOKEN= # 🔑 guards /internal/poll (free-tier external cron)
28+
29+
# ── Frontend (React) + Firebase auth ──
30+
FRONTEND_ORIGINS=http://localhost:5173,https://your-app.web.app # CORS allow-list
31+
FIREBASE_PROJECT_ID= # verifies the frontend's Firebase ID token
32+
33+
# ── Google OAuth client file (per-user web flow in prod) ──
34+
GOOGLE_CREDENTIALS_FILE=/etc/secrets/credentials.json # Render Secret File path; defaults to ./credentials.json
35+
# GOOGLE_TOKEN_FILE=./token.json # single-user dev fallback only
36+
37+
# ── Agent Engine deploy (only for `python -m app.orchestrator.agent_engine`) ──
38+
GOOGLE_CLOUD_PROJECT=
39+
GOOGLE_CLOUD_LOCATION=us-central1
40+
AGENT_ENGINE_STAGING_BUCKET=gs://your-staging-bucket
41+
42+
# ── Deferred / dev-only ──
43+
# GWORKSPACE_MCP_URL= # leave unset (Phase 3b deferred)
44+
# USER_EMAIL= # single-operator dev fallback only
45+
# Note: per-profile Drive folder / Sheet IDs live in Postgres (profiles table), NOT here.

.github/workflows/ci.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: CI/CD
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
release:
8+
types: [published]
9+
workflow_dispatch:
10+
11+
jobs:
12+
# (1) PRs + any push: lint + tool-schema gate + fully-mocked tests. NEVER deploys.
13+
test:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- uses: actions/checkout@v4
17+
- uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
cache: pip
21+
- run: pip install -r requirements.txt
22+
- run: pip install ruff pytest
23+
- name: Lint
24+
run: ruff check app
25+
- name: Tool-schema compatibility gate (blocks breaking tool-contract changes)
26+
run: python scripts/check_tool_schema.py
27+
- name: Tests (all MongoDB + Google calls mocked)
28+
run: pytest app/tests -q
29+
30+
# (2) Merge to main -> auto-deploy to Staging.
31+
deploy-staging:
32+
needs: test
33+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
34+
runs-on: ubuntu-latest
35+
environment: staging
36+
steps:
37+
- uses: actions/checkout@v4
38+
- name: Build & deploy to staging
39+
run: |
40+
echo "Build images, push to registry, deploy to Cloud Run (staging),"
41+
echo "and update the Vertex AI Agent Engine staging agent."
42+
# gcloud auth + builds submit + run deploy + python -m app.orchestrator.agent_engine
43+
44+
# (3) GitHub Release OR manual dispatch -> Production, behind manual approval.
45+
deploy-production:
46+
needs: test
47+
if: github.event_name == 'release' || github.event_name == 'workflow_dispatch'
48+
runs-on: ubuntu-latest
49+
environment: production # configure a required-reviewers protection rule on this env
50+
steps:
51+
- uses: actions/checkout@v4
52+
- name: Build & deploy to production
53+
run: |
54+
echo "Deploy to Cloud Run (prod) + Vertex AI Agent Engine (prod)."
55+
# gcloud builds submit + run deploy + agent_engine deploy

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
.env
2+
env.txt
3+
venv/
4+
uploads/
5+
__pycache__/
6+
**/__pycache__/
7+
*.pyc
8+
*.pyo
9+
# Google OAuth secrets — never commit these
10+
credentials.json
11+
client_secret.json
12+
token.json
13+
*.zip
14+
*.db
15+
mock_drive/
16+
**/mock_drive/
17+
temp/
18+
**/temp/
19+
*.png
20+
*.pdf
21+
*.docx
22+
structure.txt
23+
**/.adk/
24+
.pytest_cache/
25+
*.egg-info/
26+
dist/
27+
build/
28+
29+
# Runtime artifacts
30+
.ocr_findings.json
31+
demo_run.log
32+
*.log
33+
.oauth.log
34+
app/static/

CLAUDE.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# CLAUDE.md - Tax Automation Agent (Gemini / Google Cloud Agent Builder)
2+
3+
## Project Overview
4+
This repository contains a functional, multi-step autonomous agent powered by Gemini and Google Cloud Agent Builder. The agent streamlines personal tax workflows by integrating State Management, Google Workspace (Gmail, Calendar, Drive, Sheets), and a deterministic tax calculator supporting ITR-1 and ITR-2 forms.
5+
6+
---
7+
8+
## System Workflow & Tool Execution
9+
10+
### 1. State Management (Mandatory First Step)
11+
- **Rule:** Before initiating *any* task, the agent must query the State Management MCP server to check current task flags, execution history, and unmet dependencies.
12+
- **Rule:** The agent state is strictly isolated. State transitions must be written immediately back to the State Management MCP upon step completion.
13+
14+
### 2. Communication & Document Pipeline
15+
- **Google Drive:** Used as the primary shared medium for all file tasks (e.g., document uploads, PDFs).
16+
- **Google Sheets:** Acts as the interaction UI for unvouched transaction values (real estate amounts, gold deals, etc.).
17+
- **Gmail & Calendar:** Used strictly for sending verification requests, action reminders, and file upload prompts to the user.
18+
19+
### 3. Deterministic Tax Calculator (ITR-1 & ITR-2)
20+
- **Constraint:** The tax calculator tool must only be executed after the agent confirms via the State Management MCP that all user inputs and documentation requirements are fully met.
21+
- **Data Grounding:** For all tax-related logic, parameters, and computations, the system must strictly rely on the official government data source: https://www.incometaxindia.gov.in/ (it should be deterministic and should not use an ai agent)
22+
23+
---
24+
25+
## Security & Data Protection Guardrails
26+
27+
### 1. PII Anonymization (Gateway Pattern)
28+
- **Data Isolation:** The agent must never ingest raw personally identifiable information (PII).
29+
- **Inbound Data:** All data coming from Google Sheets/Drive must pass through the local gateway logic to replace names, PANs, and tracking info with synthetic tokens.
30+
- **Outbound Data:** The agent generates outputs using synthetic tokens. The local execution layer reconstructs the personal data immediately prior to final Google Sheet/Gmail updates.
31+
32+
### 2. Authorization Limits
33+
- **Strict Scope:** The agent is forbidden from executing tasks outside the predefined State Management workflow.
34+
- **Zero Drift:** If an ambiguous step is encountered, the agent must halt execution and issue a clarification request via Gmail.
35+
36+
---
37+
38+
## Development Environment & Resources
39+
- **Tech Stack:** Gemini API, Google Cloud Agent Builder, Node.js/Python, MongoDB.
40+
- **Credentials:** All runtime configurations, MongoDB connection uris, and Google OAuth keys are read strictly from the root `.env` file. Never commit these keys.
41+
- **License:** Distributed under an open-source license. Ensure the license file remains visible in the repository's About section.

Dockerfile

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# syntax=docker/dockerfile:1
2+
# Single-container TaxAssist: builds the React frontend, then serves it from FastAPI
3+
# alongside the API. One image, one Cloud Run / Render service.
4+
5+
# ── 1. Build the React frontend ──────────────────────────────────────────────
6+
FROM node:20-slim AS frontend
7+
WORKDIR /frontend
8+
COPY frontend/package*.json ./
9+
RUN npm ci
10+
COPY frontend/ ./
11+
# Same-origin API in production (BASE defaults to "" → calls go to "/me" on this server).
12+
RUN npm run build
13+
14+
# ── 2. Install Python deps ───────────────────────────────────────────────────
15+
FROM python:3.12-slim AS builder
16+
WORKDIR /app
17+
COPY requirements.txt .
18+
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
19+
20+
# ── 3. Runtime ───────────────────────────────────────────────────────────────
21+
FROM python:3.12-slim
22+
WORKDIR /app
23+
ENV PYTHONUNBUFFERED=1 PYTHONDONTWRITEBYTECODE=1
24+
COPY --from=builder /install /usr/local
25+
COPY app ./app
26+
# Bundle the built SPA so FastAPI can serve it at "/".
27+
COPY --from=frontend /frontend/dist ./app/static
28+
EXPOSE 8080
29+
# Honors Cloud Run's injected $PORT (defaults to 8080).
30+
CMD uvicorn app.main:app --host 0.0.0.0 --port ${PORT:-8080} --proxy-headers --forwarded-allow-ips=*

0 commit comments

Comments
 (0)