Skip to content

[Feature]: Java Client Example for PowerMem HTTP API Server #180

@Teingi

Description

@Teingi

Describe your use case

Java developers need a simple, practical client example to integrate PowerMem's intelligent memory capabilities into their Java applications. This example will demonstrate how to interact with the PowerMem HTTP API Server using Java's standard HTTP libraries or popular HTTP clients, enabling Java applications to leverage PowerMem's memory management features.

Describe the solution you'd like

Create a simple Java client example that demonstrates:

  1. Basic HTTP client setup:

    • Configuration for API base URL and API key
    • HTTP client initialization (using java.net.http.HttpClient or similar)
    • Request/response handling with proper JSON serialization/deserialization
  2. Core memory operations:

    • Create memory (POST /api/v1/memories)
    • Search memories (POST /api/v1/memories/search)
    • List memories (GET /api/v1/memories)
    • Update memory (PUT /api/v1/memories/{memory_id})
    • Delete memory (DELETE /api/v1/memories/{memory_id})
  3. Project structure:

    • Maven or Gradle project structure
    • Main class with example usage
    • PowerMem client class
    • Request/response model classes (POJOs)
    • Configuration management
    • Error handling examples
  4. Deliverables:

    • examples/java/ directory with:
      • src/main/java/com/powermem/example/ - Main example classes
      • PowerMemClient.java - Client wrapper class
      • PowerMemExample.java - Main example demonstrating all operations
      • models/ - Request/response model classes
      • pom.xml or build.gradle - Build configuration
      • README.md - Usage instructions and examples
    • Basic error handling
    • Example output showing successful operations

The solution should:

  • Use Java 11+ (LTS versions)
  • Minimize dependencies (prefer standard library, optionally Jackson/Gson for JSON)
  • Follow Java best practices and conventions
  • Include clear comments and JavaDoc
  • Handle 64-bit integer IDs properly (memory_id as String to avoid precision loss)
  • Support both JSON request/response handling
  • Include example usage in README

Describe alternatives you've considered

  • Using Spring Boot or other frameworks - but we want to keep it simple and demonstrate core concepts
  • Creating a complete SDK - but that's too complex for a 2-hour coding session

Additional context

  • The PowerMem HTTP API Server is already available and documented at docs/api/0005-api_server.md
  • Base URL: http://localhost:8000/api/v1
  • API Key authentication via X-API-Key header
  • All endpoints return JSON responses
  • Memory IDs are 64-bit integers that should be handled as strings in JSON to avoid precision loss

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions