diff --git a/.github/workflows/build-and-release.yml b/.github/workflows/build-and-release.yml index 0045078..2d25218 100644 --- a/.github/workflows/build-and-release.yml +++ b/.github/workflows/build-and-release.yml @@ -21,13 +21,13 @@ jobs: - name: Build run: | mkdir -p build - GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o build/xcontrol-api-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/api - GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o build/xcontrol-cli-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/cli - - name: Upload API artifact + GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o build/xcontrol-server-${{ matrix.goos }}-${{ matrix.goarch }} ./cmd/xcontrol-server + GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o build/xcontrol-cli-${{ matrix.goos }}-${{ matrix.goarch }} ./client + - name: Upload server artifact uses: actions/upload-artifact@v4 with: - name: xcontrol-api-${{ matrix.goos }}-${{ matrix.goarch }} - path: build/xcontrol-api-${{ matrix.goos }}-${{ matrix.goarch }} + name: xcontrol-server-${{ matrix.goos }}-${{ matrix.goarch }} + path: build/xcontrol-server-${{ matrix.goos }}-${{ matrix.goarch }} - name: Upload CLI artifact uses: actions/upload-artifact@v4 with: diff --git a/.github/workflows/deploy-xcontrol-server.yml b/.github/workflows/deploy-xcontrol-server.yml index 995f861..0cc5bb6 100644 --- a/.github/workflows/deploy-xcontrol-server.yml +++ b/.github/workflows/deploy-xcontrol-server.yml @@ -17,7 +17,7 @@ jobs: go-version: '1.21' - name: ๐Ÿ—๏ธ Build server - run: go build ./cmd/api + run: go build ./cmd/xcontrol-server - name: ๐Ÿš€ Deploy server run: | diff --git a/Makefile b/Makefile index 2daa87e..0031ded 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,7 @@ init-db: build: build-cli build-server build-homepage build-panel build-cli: - $(MAKE) -C cmd/cli build +$(MAKE) -C client build build-server: $(MAKE) -C server build diff --git a/cmd/cli/Makefile b/client/Makefile similarity index 100% rename from cmd/cli/Makefile rename to client/Makefile diff --git a/cmd/cli/main.go b/client/main.go similarity index 95% rename from cmd/cli/main.go rename to client/main.go index cb03d1f..ab13f32 100644 --- a/cmd/cli/main.go +++ b/client/main.go @@ -12,12 +12,12 @@ import ( "strings" "time" + rconfig "xcontrol/internal/rag/config" + "xcontrol/internal/rag/embed" + "xcontrol/internal/rag/ingest" + "xcontrol/internal/rag/store" + rsync "xcontrol/internal/rag/sync" "xcontrol/server/proxy" - rconfig "xcontrol/server/rag/config" - "xcontrol/server/rag/embed" - "xcontrol/server/rag/ingest" - "xcontrol/server/rag/store" - rsync "xcontrol/server/rag/sync" ) // main loads server RAG configuration and triggers a manual sync by diff --git a/cmd/ingest/main.go b/cmd/ingest/main.go index 551df64..1ee18f8 100644 --- a/cmd/ingest/main.go +++ b/cmd/ingest/main.go @@ -6,9 +6,9 @@ import ( "log" "runtime" + cfgpkg "xcontrol/internal/rag/config" + "xcontrol/internal/rag/ingest" "xcontrol/server/proxy" - cfgpkg "xcontrol/server/rag/config" - "xcontrol/server/rag/ingest" ) func main() { diff --git a/cmd/api/main.go b/cmd/xcontrol-server/main.go similarity index 100% rename from cmd/api/main.go rename to cmd/xcontrol-server/main.go diff --git a/docs/architecture/ai-kb-design.md b/docs/architecture/ai-kb-design.md index b368315..76cb726 100644 --- a/docs/architecture/ai-kb-design.md +++ b/docs/architecture/ai-kb-design.md @@ -78,7 +78,7 @@ func Embed(text string) ([]float32, error) { /* ่ฐƒ็”จ Embedding ๆจกๅž‹ */ } ## 5. ้กน็›ฎไปฃ็ ่ง„ๅˆ’ ``` - server/rag/ + internal/rag/ โ”œโ”€โ”€ sync/ # Git ๅ…‹้š†/ๆ›ดๆ–ฐ โ”œโ”€โ”€ ingest/ # ๆ–‡ๆกฃ่ฝฌๆขไธŽๅˆ†ๅ— โ”œโ”€โ”€ embed/ # ๅ‘้‡ๅŒ– diff --git a/docs/rag-system-design.md b/docs/rag-system-design.md index c9742ee..92618fb 100644 --- a/docs/rag-system-design.md +++ b/docs/rag-system-design.md @@ -64,7 +64,7 @@ ## 6. Go ไปฃ็ ๆจกๅ—ๅˆ’ๅˆ† ``` -server/rag/ +internal/rag/ โ”œโ”€โ”€ config/ # ไป“ๅบ“ไธŽๆจกๅž‹้…็ฝฎ โ”œโ”€โ”€ sync/ # GitHub ๅŒๆญฅ้€ป่พ‘ โ”œโ”€โ”€ ingest/ # Markdown ่งฃๆžไธŽๅˆ†ๅ— diff --git a/server/rag/Dockerfile b/internal/rag/Dockerfile similarity index 93% rename from server/rag/Dockerfile rename to internal/rag/Dockerfile index 25fd541..c3a7126 100644 --- a/server/rag/Dockerfile +++ b/internal/rag/Dockerfile @@ -4,7 +4,7 @@ WORKDIR /src COPY go.mod go.sum ./ RUN go mod download COPY . . -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /xcontrol ./cmd/api +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o /xcontrol ./cmd/xcontrol-server FROM gcr.io/distroless/base-debian12 WORKDIR / diff --git a/server/rag/config/config.go b/internal/rag/config/config.go similarity index 100% rename from server/rag/config/config.go rename to internal/rag/config/config.go diff --git a/server/rag/config/repos.yaml b/internal/rag/config/repos.yaml similarity index 100% rename from server/rag/config/repos.yaml rename to internal/rag/config/repos.yaml diff --git a/server/rag/config/runtime.go b/internal/rag/config/runtime.go similarity index 100% rename from server/rag/config/runtime.go rename to internal/rag/config/runtime.go diff --git a/server/rag/config/runtime_test.go b/internal/rag/config/runtime_test.go similarity index 100% rename from server/rag/config/runtime_test.go rename to internal/rag/config/runtime_test.go diff --git a/server/rag/embed/bge.go b/internal/rag/embed/bge.go similarity index 100% rename from server/rag/embed/bge.go rename to internal/rag/embed/bge.go diff --git a/server/rag/embed/embed.go b/internal/rag/embed/embed.go similarity index 100% rename from server/rag/embed/embed.go rename to internal/rag/embed/embed.go diff --git a/server/rag/embed/openai.go b/internal/rag/embed/openai.go similarity index 100% rename from server/rag/embed/openai.go rename to internal/rag/embed/openai.go diff --git a/server/rag/ingest/chunk.go b/internal/rag/ingest/chunk.go similarity index 97% rename from server/rag/ingest/chunk.go rename to internal/rag/ingest/chunk.go index 8d13fae..f4a1944 100644 --- a/server/rag/ingest/chunk.go +++ b/internal/rag/ingest/chunk.go @@ -3,7 +3,7 @@ package ingest import ( "strings" - cfgpkg "xcontrol/server/rag/config" + cfgpkg "xcontrol/internal/rag/config" ) // Chunk represents a piece of text prepared for embedding. diff --git a/server/rag/ingest/chunk_test.go b/internal/rag/ingest/chunk_test.go similarity index 97% rename from server/rag/ingest/chunk_test.go rename to internal/rag/ingest/chunk_test.go index 24ea9e1..ca3d616 100644 --- a/server/rag/ingest/chunk_test.go +++ b/internal/rag/ingest/chunk_test.go @@ -4,7 +4,7 @@ import ( "strings" "testing" - cfgpkg "xcontrol/server/rag/config" + cfgpkg "xcontrol/internal/rag/config" ) func TestBuildChunksHeading(t *testing.T) { diff --git a/server/rag/ingest/hash.go b/internal/rag/ingest/hash.go similarity index 100% rename from server/rag/ingest/hash.go rename to internal/rag/ingest/hash.go diff --git a/server/rag/ingest/hash_test.go b/internal/rag/ingest/hash_test.go similarity index 100% rename from server/rag/ingest/hash_test.go rename to internal/rag/ingest/hash_test.go diff --git a/server/rag/ingest/ingest.go b/internal/rag/ingest/ingest.go similarity index 93% rename from server/rag/ingest/ingest.go rename to internal/rag/ingest/ingest.go index 82d0b33..e8d8115 100644 --- a/server/rag/ingest/ingest.go +++ b/internal/rag/ingest/ingest.go @@ -8,10 +8,10 @@ import ( "github.com/jackc/pgx/v5" - cfgpkg "xcontrol/server/rag/config" - "xcontrol/server/rag/embed" - "xcontrol/server/rag/store" - rsync "xcontrol/server/rag/sync" + cfgpkg "xcontrol/internal/rag/config" + "xcontrol/internal/rag/embed" + "xcontrol/internal/rag/store" + rsync "xcontrol/internal/rag/sync" ) // Options control ingestion behaviour. @@ -41,7 +41,7 @@ func IngestRepo(ctx context.Context, cfg *cfgpkg.Config, ds cfgpkg.DataSource, o chunkCfg := cfg.ResolveChunking() embCfg := cfg.ResolveEmbedding() - workdir := filepath.Join("server", "rag", ds.Name) + workdir := filepath.Join("internal", "rag", ds.Name) if _, err := rsync.SyncRepo(ctx, ds.Repo, workdir); err != nil { st.Errors = append(st.Errors, err) return st, err diff --git a/server/rag/ingest/markdown.go b/internal/rag/ingest/markdown.go similarity index 100% rename from server/rag/ingest/markdown.go rename to internal/rag/ingest/markdown.go diff --git a/server/rag/ingest/walk.go b/internal/rag/ingest/walk.go similarity index 100% rename from server/rag/ingest/walk.go rename to internal/rag/ingest/walk.go diff --git a/server/rag/rag.go b/internal/rag/rag.go similarity index 100% rename from server/rag/rag.go rename to internal/rag/rag.go diff --git a/server/rag/service.go b/internal/rag/service.go similarity index 95% rename from server/rag/service.go rename to internal/rag/service.go index fe40f11..b276995 100644 --- a/server/rag/service.go +++ b/internal/rag/service.go @@ -7,9 +7,9 @@ import ( "github.com/jackc/pgx/v5" pgvector "github.com/pgvector/pgvector-go" - "xcontrol/server/rag/config" - "xcontrol/server/rag/embed" - "xcontrol/server/rag/store" + "xcontrol/internal/rag/config" + "xcontrol/internal/rag/embed" + "xcontrol/internal/rag/store" ) type Service struct { diff --git a/server/rag/store/store.go b/internal/rag/store/store.go similarity index 100% rename from server/rag/store/store.go rename to internal/rag/store/store.go diff --git a/server/rag/sync/sync.go b/internal/rag/sync/sync.go similarity index 100% rename from server/rag/sync/sync.go rename to internal/rag/sync/sync.go diff --git a/server/Makefile b/server/Makefile index ef453b1..453f721 100644 --- a/server/Makefile +++ b/server/Makefile @@ -1,5 +1,5 @@ APP_NAME := xcontrol-server -MAIN_FILE := ../cmd/api/main.go +MAIN_FILE := ../cmd/xcontrol-server/main.go MODULE := xcontrol PORT := 8080 OS := $(shell uname -s) diff --git a/server/api/knowledge.go b/server/api/knowledge.go index 54049e9..34de631 100644 --- a/server/api/knowledge.go +++ b/server/api/knowledge.go @@ -6,7 +6,7 @@ import ( "github.com/gin-gonic/gin" "github.com/jackc/pgx/v5" - rsync "xcontrol/server/rag/sync" + rsync "xcontrol/internal/rag/sync" ) // registerKnowledgeRoutes sets up knowledge base endpoints. diff --git a/server/api/rag.go b/server/api/rag.go index b701672..25fe79f 100644 --- a/server/api/rag.go +++ b/server/api/rag.go @@ -5,10 +5,10 @@ import ( "github.com/gin-gonic/gin" + "xcontrol/internal/rag" + rconfig "xcontrol/internal/rag/config" + "xcontrol/internal/rag/store" "xcontrol/server/proxy" - "xcontrol/server/rag" - rconfig "xcontrol/server/rag/config" - "xcontrol/server/rag/store" ) // ragSvc handles RAG document storage and retrieval.