Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ todos.json
# python
venv/
__pycache__/
.venv/
.venv/
.adk
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,52 @@ pnpm install:agent
3. Set up environment variables for the ADK agent:

```bash
cp adk/cofacts-ai/.env.example adk/cofacts-ai/.env
cp adk/cofacts_ai/.env.example adk/cofacts_ai/.env
```

Edit `adk/cofacts-ai/.env` and fill in the required values (at minimum `GOOGLE_API_KEY`).
Edit `adk/cofacts_ai/.env` and fill in the required values (at minimum `GOOGLE_API_KEY`).

4. Start the development server:

```bash
pnpm dev
```

This will start both the UI and agent servers concurrently.
This will start both the UI and agent servers concurrently:

- http://localhost:3000 for UI
- http://localhost:8000 for ADK web
- http://localhost:8000/docs for ADK API docs

## Deployment

This project uses GitHub Actions for automated deployments to Google Cloud Run.

### Local Docker Testing

To build and test both Docker images locally (mirroring what the CI pipeline does):

1. Make sure `adk/cofacts_ai/.env` exists and is filled in (see [Getting Started](#getting-started) step 3).

2. Build and start the containers:

```bash
docker compose up --build
```

This will:
- Build the **frontend** image from the root `Dockerfile`
- Build the **backend** image from `adk/Dockerfile`
- Start both containers, with the frontend waiting for the backend to be healthy

3. Open http://localhost:3000 to test the application.

To stop:

```bash
docker compose down
```

### Staging Environment
- **Trigger**: Every push or merge to the `master` branch.
- **URL**: cofacts-ai-236494820908.asia-east1.run.app .
Comment thread
MrOrz marked this conversation as resolved.
Expand Down
13 changes: 13 additions & 0 deletions adk/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Python virtual environment (macOS binaries won't work inside Linux container)
.venv

# ADK local state / cache
.adk

# Python cache
__pycache__
*.pyc
*.pyo

# env files (injected at runtime)
cofacts_ai/.env
2 changes: 1 addition & 1 deletion adk/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ COPY --from=builder /app /app
COPY --from=builder /app/.venv /app/.venv
ENV PATH="/app/.venv/bin:$PATH"
EXPOSE 8000
CMD ["adk", "web", "--port", "8000", "--host", "0.0.0.0", "."]
CMD ["adk", "api_server", "--port", "8000", "--host", "0.0.0.0", "."]
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2,255 changes: 1,142 additions & 1,113 deletions adk/uv.lock

Large diffs are not rendered by default.

31 changes: 31 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
services:
frontend:
build:
context: .
dockerfile: Dockerfile
ports:
- "3000:3000"
environment:
- PORT=3000
- ADK_URL=http://backend:8000
depends_on:
backend:
condition: service_healthy

backend:
build:
context: ./adk
dockerfile: Dockerfile
ports:
- "8000:8000"
env_file:
- ./adk/cofacts_ai/.env
environment:
- PORT=8000
- LANGFUSE_BASE_URL=https://langfuse.cofacts.tw
healthcheck:
test: ["CMD", "python", "-c", "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"]
Comment thread
MrOrz marked this conversation as resolved.
interval: 10s
timeout: 5s
retries: 6
start_period: 10s
2 changes: 1 addition & 1 deletion src/lib/adk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

export const ADK_BASE_URL = 'http://localhost:8000'
export const ADK_APP_NAME = 'cofacts-ai'
export const ADK_APP_NAME = 'cofacts_ai'
export const ADK_USER_ID = 'anonymous'

// ── Types ──────────────────────────────────────────────────────────
Expand Down
2 changes: 1 addition & 1 deletion src/routes/api/sessions.$sessionId.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createFileRoute } from '@tanstack/react-router'
import type { AdkSession } from '@/lib/adk'

const ADK_INTERNAL_URL = process.env.ADK_URL || 'http://localhost:8000'
const APP_NAME = 'cofacts-ai'
const APP_NAME = 'cofacts_ai'
const USER_ID = 'anonymous'

export const Route = createFileRoute('/api/sessions/$sessionId')({
Expand Down
2 changes: 1 addition & 1 deletion src/routes/api/sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {
} from '@/lib/apiTypes'

const ADK_INTERNAL_URL = process.env.ADK_URL || 'http://localhost:8000'
const APP_NAME = 'cofacts-ai'
const APP_NAME = 'cofacts_ai'
const USER_ID = 'anonymous'

export const Route = createFileRoute('/api/sessions')({
Expand Down
Loading