Skip to content

Commit 542f18a

Browse files
authored
Update README.md
1 parent 2ffb451 commit 542f18a

1 file changed

Lines changed: 32 additions & 32 deletions

File tree

README.md

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Semantic Book Search with Go, pgvector, and Gemini API
22

33
[![Release with GoReleaser](https://github.com/nmdra/Semantic-Search/actions/workflows/release.yaml/badge.svg)](https://github.com/nmdra/Semantic-Search/actions/workflows/release.yaml)
4+
[![golangci-lint](https://github.com/nmdra/Semantic-Search/actions/workflows/golangci-lint.yaml/badge.svg)](https://github.com/nmdra/Semantic-Search/actions/workflows/golangci-lint.yaml)
45
[![Go Version](https://img.shields.io/badge/go-1.24-blue.svg)](https://golang.org/dl/)
56
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
67
[![Docker Image](https://img.shields.io/badge/docker-ghcr.io%2Fnmdra%2Fsemantic--search-blue?logo=docker)](https://ghcr.io/nmdra/semantic-search)
@@ -28,9 +29,9 @@ C4Context
2829
UpdateRelStyle(gemini, api, $offsetY="0", $offsetX="80")
2930
UpdateRelStyle(db, api, $offsetY="40", $offsetX="50")
3031
UpdateLayoutConfig($c4ShapeInRow="3", $c4BoundaryInRow="1")
31-
```
32+
````
3233
33-
> [!CAUTION]
34+
> \[!CAUTION]
3435
> This project is intended for learning and demonstration purposes only.
3536
> While it tries to follow best and security practices, it may contain errors or incomplete implementations.
3637
@@ -39,39 +40,29 @@ C4Context
3940
* **Semantic Search** — Search books by semantic similarity using vector embeddings
4041
* **Gemini API Integration** — Generates high-quality embeddings via Google's Gemini API
4142
* **PostgreSQL + pgvector** — Efficient storage and approximate nearest neighbor search
43+
* **Redis-powered Cache** — Speeds up repeated search queries with vector caching
44+
* **Run Migrations via CLI** — Run `-migrate` to apply database schema changes at startup
4245
* **Multi-Platform Support** — Build and release for Linux, macOS, Windows, amd64, and arm64
4346
* **Docker & GitHub Container Registry** — Easy deployment with multi-arch Docker images
4447
* **Clean Architecture** — Modular codebase with separate API, service, repository layers
4548
* **Automated Releases** — GitHub Actions + GoReleaser for continuous delivery
4649
47-
## Architecture & Directory Structure
48-
49-
```
50-
.
51-
├── api # HTTP handlers (Echo framework)
52-
├── cmd # Main application entrypoint
53-
├── internal # Core business logic, embedder, repository implementations
54-
│ ├── embed # Gemini embedding client
55-
│ └── repository # Database access layer (sqlc generated)
56-
├── db # SQL migration files & schema
57-
├── Dockerfile # Multi-stage Docker build for scratch image
58-
├── .goreleaser.yml # Release automation configuration
59-
├── go.mod # Go modules dependencies
60-
├── Makefile # Helper commands (build, migrate, test)
61-
└── README.md # Project documentation (this file)
62-
```
63-
64-
For detailed project layout, see [Go Project Directory Structure](https://gist.github.com/ayoubzulfiqar/9f1a34049332711fddd4d4b2bfd46096).
65-
6650
## Getting Started
6751
6852
### Prerequisites
6953
7054
* Go 1.24+
7155
* PostgreSQL with `pgvector` extension installed
7256
* Gemini API Key ([Get API Key Here](https://aistudio.google.com/app/apikey))
57+
* Redis (for vector caching)
7358
* Docker (optional, for containerized deployment)
7459
60+
### API Endpoints
61+
62+
* `POST /books` — Add a book with title and description; stores embedding in DB
63+
* `GET /search?q=your+query` — Search books semantically by query text
64+
* `GET /ping` — Health check endpoint
65+
7566
### Setup PostgreSQL
7667
7768
1. Create your database:
@@ -82,13 +73,17 @@ Run migrations:
8273
make migrate-up
8374
```
8475

85-
### Environment Variables
76+
Or via the binary:
8677

87-
Create a `.env` file with the following:
78+
```bash
79+
semantic-search-api -migrate=true
80+
```
81+
### Environment Variables
8882

8983
```
9084
DATABASE_URL=postgres://user:password@localhost:5432/semantic_search?sslmode=disable
9185
GEMINI_API_KEY=your_gemini_api_key_here
86+
REDIS_URL=localhost:6379
9287
```
9388

9489
### Running Locally
@@ -99,22 +94,27 @@ go run ./cmd/main.go
9994

10095
API will be available at `http://localhost:8080`.
10196

102-
### API Endpoints
103-
104-
* `POST /books` — Add a book with title and description; stores embedding in DB
105-
* `GET /search?q=your+query` — Search books semantically by query text
106-
* `GET /ping` — Health check endpoint
107-
10897
### Docker
10998

110-
Build multi-arch images with GoReleaser or manually:
99+
Run Database migrations:
111100

112101
```bash
113-
docker buildx build --platform linux/amd64,linux/arm64 -t ghcr.io/nmdra/semantic-search:latest .
102+
docker run --rm \
103+
--network=host \
104+
ghcr.io/nmdra/semantic-search:latest \
105+
-apikey="$GEMINI_API_KEY" \
106+
-db-dsn="$DATABASE_URL" \
107+
-migrate
114108
```
115109

116110
Run container:
117111

118112
```bash
119-
docker run -p 8080:8080 ghcr.io/nmdra/semantic-search:latest
113+
docker run --rm \
114+
--network=host \
115+
ghcr.io/nmdra/semantic-search:latest \
116+
-apikey="$GEMINI_API_KEY" \
117+
-db-dsn="$DATABASE_URL" \
118+
-redis="localhost:6379" \
119+
-loglevel="warn"
120120
```

0 commit comments

Comments
 (0)