Skip to content

Commit e24d8cc

Browse files
committed
📝 doc: Update README.md
1 parent 2ffb451 commit e24d8cc

File tree

1 file changed

+32
-33
lines changed

1 file changed

+32
-33
lines changed

README.md

Lines changed: 32 additions & 33 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,28 @@ 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
44-
* **Clean Architecture** — Modular codebase with separate API, service, repository layers
4547
* **Automated Releases** — GitHub Actions + GoReleaser for continuous delivery
4648
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-
6649
## Getting Started
6750
6851
### Prerequisites
6952
7053
* Go 1.24+
7154
* PostgreSQL with `pgvector` extension installed
7255
* Gemini API Key ([Get API Key Here](https://aistudio.google.com/app/apikey))
56+
* Redis (for vector caching)
7357
* Docker (optional, for containerized deployment)
7458
59+
### API Endpoints
60+
61+
* `POST /books` — Add a book with title and description; stores embedding in DB
62+
* `GET /search?q=your+query` — Search books semantically by query text
63+
* `GET /ping` — Health check endpoint
64+
7565
### Setup PostgreSQL
7666
7767
1. Create your database:
@@ -82,13 +72,17 @@ Run migrations:
8272
make migrate-up
8373
```
8474

85-
### Environment Variables
75+
Or via the binary:
8676

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

8982
```
9083
DATABASE_URL=postgres://user:password@localhost:5432/semantic_search?sslmode=disable
9184
GEMINI_API_KEY=your_gemini_api_key_here
85+
REDIS_URL=localhost:6379
9286
```
9387

9488
### Running Locally
@@ -99,22 +93,27 @@ go run ./cmd/main.go
9993

10094
API will be available at `http://localhost:8080`.
10195

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-
10896
### Docker
10997

110-
Build multi-arch images with GoReleaser or manually:
98+
Run Database migrations:
11199

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

116109
Run container:
117110

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

0 commit comments

Comments
 (0)