TeaElephantMemory

module
v1.4.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2026 License: Apache-2.0

README

TeaElephantMemory

A Go service powering Tea Elephant Memory: store tea collections, tags, and notifications, generate printable QR codes, and expose a GraphQL API. Includes integrations for Apple Push Notifications and OpenWeather.

Features

  • GraphQL API (gqlgen) for collections, teas, tags, and notifications
  • FoundationDB-backed storage (via lightweight client in pkg/fdbclient)
  • QR code generation utilities (printqr)
  • APNs notification sender
  • OpenWeather integration for weather-aware features
  • Docker and docker-compose support

Prerequisites

  • Go 1.22+
  • Docker and Docker Compose (optional but recommended)
  • FoundationDB (local dev cluster) or access to a running FDB

Quick Start (Docker Compose)

  1. Copy or verify FDB cluster config in config/fdb.cluster.
  2. Start services:
    • docker compose up -d
  3. Server listens on default port (see flags/env below). GraphQL schema is under pkg/api/v2/graphql.

To stop:

  • docker compose down

Build From Source

  1. Ensure Go toolchain is installed (1.22+).
  2. Download modules and build:
    • go mod download
    • go build ./...
Run the server
  • go run ./cmd/server

Common flags/env (examples):

  • FDB_CLUSTER_FILE: path to FoundationDB cluster file (default: config/fdb.cluster)
  • PORT: server port (default may be 8080)
Generate QR codes (CLI)
  • go run ./cmd/qr_gen Outputs printable QR codes using logic from printqr package.

Tests

  • Run unit tests:
    • go test ./...

Some packages have dedicated tests, e.g.:

  • internal/openweather
  • internal/adviser
  • common packages

Linting

A local golangci-lint binary exists under bin/golangci-lint. If desired:

  • bin/golangci-lint run

Project Layout Highlights

  • cmd/server: HTTP server entrypoint
  • cmd/qr_gen: CLI QR generator
  • pkg/api/v2/graphql: GraphQL schema and generated code
  • pkg/fdb, pkg/fdbclient: FoundationDB access layers
  • internal/*: domain services and managers (adviser, descrgen, openweather, managers for tags/tea/collection)
  • printqr: QR image creation
  • static/: static assets, including apple-app-site-association

Configuration Notes

  • FoundationDB cluster file: config/fdb.cluster (ensure it matches your environment)
  • APNs requires credentials (e.g., AuthKey_*.p8). Place and configure securely for production.
  • Environment variables and flags may be introduced/used by individual components; check respective packages for details.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Directories

Path Synopsis
cmd
qr_gen command
server command
Package common contains shared domain models used across the application.
Package common contains shared domain models used across the application.
db
internal
adviser
Package adviser contains AI-driven tea recommendation helpers and models.
Package adviser contains AI-driven tea recommendation helpers and models.
apns
Package apns provides Apple Push Notification sending.
Package apns provides Apple Push Notification sending.
auth
Package auth provides JWT and Apple Sign In authentication, along with GraphQL middleware.
Package auth provides JWT and Apple Sign In authentication, along with GraphQL middleware.
consumption
Package consumption contains storage backends for recent tea consumption events.
Package consumption contains storage backends for recent tea consumption events.
server
Package server wires HTTP server, GraphQL transports, routes, and middlewares.
Package server wires HTTP server, GraphQL transports, routes, and middlewares.
pkg
api/v2/common
Package common provides shared GraphQL scalar types and helpers.
Package common provides shared GraphQL scalar types and helpers.
api/v2/graphql
Package graphql contains GraphQL schema-related helpers and error handling utilities.
Package graphql contains GraphQL schema-related helpers and error handling utilities.
api/v2/models
Package model contains GraphQL models and helpers for API v2.
Package model contains GraphQL models and helpers for API v2.
pg
Package pg contains the Postgres-backed storage adapter used by managers.
Package pg contains the Postgres-backed storage adapter used by managers.
pgstore
Package pgstore contains query helpers generated from db/queries/* using sqlc.
Package pgstore contains query helpers generated from db/queries/* using sqlc.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL