Skip to content

jaredzwick/sync

Repository files navigation

Sync

A Go API service that connects to Google Calendar, detects scheduling intent from natural language messages, and finds available meeting slots.

What It Does

  • Ingests messages from email, text, Slack, etc. via a REST endpoint
  • Parses natural language for scheduling intent ("let's sync Tuesday", "schedule a call this week")
  • Queries Google Calendar free/busy data to find open slots within work hours
  • OAuth2 flow for Google account linking with token persistence in Postgres

Architecture

                  ┌──────────────┐
  POST /v1/message│              │
  ───────────────►│   Huma API   │
                  │   (chi)      │
                  └──────┬───────┘
                         │
              ┌──────────┴──────────┐
              │                     │
     ┌────────▼────────┐  ┌────────▼────────┐
     │    Schedule      │  │    Google        │
     │    Intent NLP    │  │    Calendar API  │
     │                  │  │    (Free/Busy)   │
     └─────────────────┘  └────────┬─────────┘
                                   │
                          ┌────────▼────────┐
                          │   Postgres       │
                          │   (users/tokens) │
                          └─────────────────┘

Stack

  • Go with Cobra CLI, Chi router, Huma API framework
  • Postgres via pgx connection pool
  • Google Calendar API with OAuth2
  • Redis for caching
  • Docker Compose for local dev with hot reload (CompileDaemon)

Getting Started

Prerequisites

  • Go 1.20+
  • Docker & Docker Compose
  • Google OAuth credentials (GOOGLE_CLIENT_ID, GOOGLE_CLIENT_SECRET)

Run Locally

# Set required env vars
export GOOGLE_CLIENT_ID=your-client-id
export GOOGLE_CLIENT_SECRET=your-client-secret

# Start Postgres, Redis, and the API
docker compose up

The API starts on http://localhost:8888.

Build From Source

# Build for your platform
make native

# Build for all platforms (linux/darwin, amd64/arm64)
make all

# Run
./bin/syncron serve

API

Method Endpoint Description
POST /v1/message Send a message, get scheduling analysis back
GET /v1/greeting/{name} Health check / greeting
GET /login-here Start Google OAuth flow
GET /callback OAuth callback (stores tokens)

Example

curl -X POST http://localhost:8888/v1/message \
  -H "Content-Type: application/json" \
  -d '{"message": "let'\''s schedule a sync on Thursday"}'
{"message": "The meeting is scheduled 2 days from now."}

Project Structure

├── main.go              # CLI entrypoint (Cobra)
├── server/
│   ├── server.go        # HTTP server, routes, OAuth handlers
│   └── db.go            # Postgres connection pool
├── schedule/
│   ├── schedule.go      # Intent detection & day parsing
│   └── google.go        # Google Calendar OAuth & free/busy queries
├── migrations/
│   └── 001_init.up.sql  # Users table with OAuth token storage
├── Dockerfile
├── docker-compose.yaml
└── Makefile             # Cross-platform build targets

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors