Skip to content

Commit d04d64b

Browse files
authored
Dev environment
2 parents 73080a5 + 5a39086 commit d04d64b

8 files changed

Lines changed: 152 additions & 83 deletions

File tree

.devcontainer/Dockerfile

Lines changed: 0 additions & 7 deletions
This file was deleted.

.devcontainer/devcontainer.json

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
{
22
"name": "xmpp-llm-bridge",
3-
"dockerComposeFile": "docker-compose.yml",
4-
"service": "app",
3+
"image": "mcr.microsoft.com/devcontainers/go:1-1.23-bookworm",
54
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
65
"forwardPorts": [
7-
// "db:5432",
86
8080
97
],
108
"containerEnv": {
119
"ENV": "dev"
1210
},
13-
// "postCreateCommand": "go mod tidy",
14-
"features": {
15-
"ghcr.io/devcontainers/features/common-utils:2": {
16-
"installZsh": "true",
17-
"username": "vscode",
18-
"userUid": "1000",
19-
"userGid": "1000",
20-
"upgradePackages": "true"
21-
},
22-
"ghcr.io/devcontainers/features/go:1": {
23-
"version": "none"
24-
}
25-
},
11+
"postCreateCommand": "cd ${containerWorkspaceFolder}; /usr/bin/env sh .devcontainer/postCreateCommand.sh",
12+
"features": {},
2613
"customizations": {
2714
"vscode": {
2815
"settings": {
@@ -36,6 +23,5 @@
3623
]
3724
}
3825
},
39-
// Set `remoteUser` to `root` to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
4026
"remoteUser": "vscode"
4127
}

.devcontainer/docker-compose.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

.devcontainer/postCreateCommand.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env sh
2+
3+
echo "[ ! -f ${PWD}/.env ] || export \$(grep -v '^#' ${PWD}/.env | xargs)" >>/home/vscode/.bashrc
4+
go install github.com/joerdav/xc/cmd/xc@latest && xc -complete
5+
go mod tidy

.github/dependabot.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
open-pull-requests-limit: 4

CHANGELOG.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Changelog
2+
<!-- markdownlint-configure-file { "MD024": { "siblings_only": true } } -->
3+
4+
All notable changes to this project will be documented in this file.
5+
6+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
7+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8+
9+
## [0.1.2] - 2025-08-29
10+
11+
### Added
12+
13+
- Added project description in README.md
14+
- Added CHANGELOG.md file
15+
- devcontainer config
16+
- Dependabot config
17+
18+
## [0.1.1] - 2025-08-19
19+
20+
### Changed
21+
22+
- Major refactoring of project structure to implement hexagonal architecture
23+
- Moved from `api/` structure to `internal/app/`, `internal/ports/`, and `internal/adapters/` pattern
24+
- Relocated handlers from `api/client/handlers/` to `internal/app/client/handlers/`
25+
- Moved server components from `api/server/` to `internal/app/server/`
26+
- Restructured main application logic into `internal/app/app.go` with proper dependency injection
27+
- Enhanced XMPP handling with new `pkg/xmpp/` utilities and message multiplexing
28+
- Improved configuration structure and expanded default configuration options
29+
- Added new port interfaces for better abstraction (`xmppSession.go`)
30+
- Refined entity models and adapter implementations for better separation of concerns
31+
32+
## [0.1.0] - 2025-08-19
33+
34+
### Added
35+
36+
- Initial release of XMPP-LLM Bridge service
37+
- XMPP client implementation with SASL authentication using mellium.im/xmpp
38+
- OpenAI LLM integration for processing chat messages
39+
- Basic XMPP message handlers:
40+
- Debug handler for logging incoming stanzas
41+
- Echo message handler for testing
42+
- LLM message handler for AI-powered responses
43+
- Configuration management with YAML config files and environment variable overrides
44+
- Support for loading secrets from files using `_FILE` suffix environment variables
45+
- Docker containerization with multi-stage builds
46+
- HTTP server with health check endpoint on port 8080
47+
- Development container configuration with VS Code devcontainer
48+
- Basic project structure with hexagonal architecture foundations
49+
- GitHub Actions workflow for automated release builds and Docker image publishing
50+
51+
[unreleased]: https://github.com/MykolaBilyi/xmpp-llm-bridge/compare/v0.1.2...HEAD
52+
[0.1.2]: https://github.com/MykolaBilyi/xmpp-llm-bridge/compare/v0.1.1...v0.1.2
53+
[0.1.1]: https://github.com/MykolaBilyi/xmpp-llm-bridge/compare/v0.1.0...v0.1.1
54+
[0.1.0]: https://github.com/MykolaBilyi/xmpp-llm-bridge/releases/tag/v0.1.0

README.md

Lines changed: 78 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,102 @@
11
# XMPP LLM Bridge
22

3+
[![GitHub Release](https://img.shields.io/github/v/release/mykolabilyi/xmpp-llm-bridge)](https://github.com/mykolabilyi/xmpp-llm-bridge/releases) [![xc compatible](https://xcfile.dev/badge.svg)](https://xcfile.dev)
4+
5+
## Description
6+
7+
XMPP LLM Bridge is a Go service that connects XMPP chat networks with OpenAI's Large Language Models, enabling AI-powered conversations through XMPP clients. The service acts as an intelligent bot that can participate in XMPP conversations by processing incoming messages through OpenAI's API and responding with contextually relevant replies.
8+
9+
### Key Features
10+
11+
- **XMPP Integration**: Full XMPP client implementation using mellium.im/xmpp library with SASL authentication
12+
- **OpenAI LLM Integration**: Seamlessly forwards chat messages to OpenAI's API and returns responses
13+
- **Configurable**: YAML-based configuration with environment variable overrides
14+
- **Docker Ready**: Containerized deployment with multi-stage builds
15+
16+
## Usage
17+
18+
The XMPP LLM Bridge can be deployed in several ways. All methods require three essential environment variables:
19+
20+
- `XMPP_JID`: Your bot's XMPP account (e.g., `bot@example.com`)
21+
- `XMPP_PASSWORD`: Password for the XMPP account
22+
- `OPENAI_API_KEY`: Your OpenAI API key
23+
24+
### Quick Start with Docker
25+
26+
Pull and run the latest image:
27+
28+
```bash
29+
docker run \
30+
-e XMPP_JID=bot@example.com \
31+
-e XMPP_PASSWORD=your_password \
32+
-e OPENAI_API_KEY=sk-your-openai-key \
33+
ghcr.io/mykolabilyi/xmpp-llm-bridge:latest
34+
```
35+
36+
### Docker Compose (Recommended)
37+
38+
Use this `docker-compose.yml`:
39+
40+
```yaml
41+
services:
42+
bridge:
43+
image: ghcr.io/mykolabilyi/xmpp-llm-bridge:latest
44+
environment:
45+
- XMPP_JID=bot@example.com
46+
- XMPP_PASSWORD=your_password
47+
- OPENAI_API_KEY=sk-your-openai-key
48+
restart: unless-stopped
49+
```
50+
51+
Start the service:
52+
53+
```bash
54+
docker compose up -d
55+
```
56+
57+
## Development
58+
59+
### Architecture
60+
61+
The service implements a hexagonal architecture pattern:
62+
63+
- **Core Business Logic**: Located in `/internal/app/` with dependency injection via context-based providers
64+
- **Ports**: Interfaces in `/internal/ports/` define contracts for external services
65+
- **Adapters**: External integrations in `/internal/adapters/` handle XMPP, OpenAI, and HTTP communications
66+
- **Entities**: Domain models in `/internal/entities/` represent core data structures
67+
68+
The application runs two concurrent services:
69+
70+
1. **XMPP Client**: Handles incoming chat messages and processes them through the LLM
71+
2. **HTTP Server**: Provides health check endpoint on port 8080 for monitoring
72+
373
## Tasks
474

75+
[xc] is recommended to simplify running tasks
76+
577
### run
678

779
```sh
880
go run cmd/app/main.go
981
```
1082

11-
### build-image
83+
### image-build
1284

1385
run: once
1486
Inputs: TAG
1587
Environment: TAG=dev
1688

1789
```sh
18-
docker build -t ghcr.io/mykolabilyi/xmpp-llm-bridge:$TAG .
90+
docker compose build
1991
```
2092

21-
### run-image
93+
### image-run
2294

2395
Inputs: TAG
2496
Environment: TAG=dev
25-
Requires: build-image
2697

2798
```sh
28-
docker run --rm --name xmpp-llm-bridge-dev \
29-
-e XMPP_JID=$XMPP_JID \
30-
-e XMPP_PASSWORD=$XMPP_PASSWORD \
31-
-p 8080:8080 \
32-
ghcr.io/mykolabilyi/xmpp-llm-bridge:$TAG
99+
docker compose up
33100
```
101+
102+
[xc]: https://xcfile.dev/

docker-compose.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
1-
version: '3.9'
21
services:
32
bridge:
3+
image: ghcr.io/mykolabilyi/xmpp-llm-bridge:${TAG:-dev}
44
build:
55
context: .
66
dockerfile: Dockerfile
77
args:
88
DOCKER_BUILDKIT: 1
9-
PORT: 8080
9+
environment:
10+
- XMPP_JID=${XMPP_JID:?}
11+
- XMPP_PASSWORD=${XMPP_PASSWORD:?}
12+
- OPENAI_API_KEY=${OPENAI_API_KEY:?}
1013
ports:
1114
- 8080:8080

0 commit comments

Comments
 (0)