Skip to content

Commit 71fda30

Browse files
davidgrldoclaude
andcommitted
feat!: promote bible, local, and scrape to importable packages
Move the engine and both adapters out of internal/ so the project is usable as a library: import github.com/davidgrldo/alkitab-api/{bible, local,scrape}. The HTTP server stays internal — it is the app, not the API. Adds package docs and a README "Use as a library" section with a verified example. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 93d90ef commit 71fda30

17 files changed

Lines changed: 58 additions & 12 deletions

File tree

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,40 @@ docker build -t alkitab-api . && docker run -p 3000:3000 alkitab-api
6666
`GET /healthz` answers `ok` for liveness probes; the server shuts down
6767
gracefully on SIGINT/SIGTERM.
6868

69+
## Use as a library
70+
71+
The engine and adapters are importable — the HTTP server is just one consumer:
72+
73+
```bash
74+
go get github.com/davidgrldo/alkitab-api
75+
```
76+
77+
```go
78+
package main
79+
80+
import (
81+
"fmt"
82+
83+
"github.com/davidgrldo/alkitab-api/bible"
84+
"github.com/davidgrldo/alkitab-api/local"
85+
)
86+
87+
func main() {
88+
src, err := local.New("") // "" = embedded public-domain sample; or your ALKITAB_DATA_DIR
89+
if err != nil {
90+
panic(err)
91+
}
92+
eng := bible.New(src)
93+
94+
ch, _ := eng.Chapter("kjv", "3john", 1)
95+
fmt.Println(ch.Verses[3].Content) // I have no greater joy…
96+
}
97+
```
98+
99+
Compose sources with `bible.NewChain(local, scrape)` — the engine checks the
100+
`bible.Corpus` capability by type assertion, so search/daily/random work
101+
exactly when the active source can support them.
102+
69103
## Endpoints
70104

71105
| Method | Path | Description |
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ package bible_test
33
import (
44
"testing"
55

6-
"github.com/davidgrldo/alkitab-api/internal/bible"
7-
"github.com/davidgrldo/alkitab-api/internal/local"
6+
"github.com/davidgrldo/alkitab-api/bible"
7+
"github.com/davidgrldo/alkitab-api/local"
88
)
99

1010
// fakeScrape is a minimal bible.Source standing in for the scrape adapter.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// Package bible is the core of alkitab-api: domain types, the Source and
2+
// Corpus contracts, a caching Engine, and a fallback Chain for composing
3+
// sources. Pair it with an adapter such as local (embedded/BYOD JSON) or
4+
// scrape (runtime proxy) — dependencies always point inward.
15
package bible
26

37
import "errors"

cmd/alkitab-api/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ import (
1111
"syscall"
1212
"time"
1313

14-
"github.com/davidgrldo/alkitab-api/internal/bible"
15-
"github.com/davidgrldo/alkitab-api/internal/local"
16-
"github.com/davidgrldo/alkitab-api/internal/scrape"
14+
"github.com/davidgrldo/alkitab-api/bible"
15+
"github.com/davidgrldo/alkitab-api/local"
16+
"github.com/davidgrldo/alkitab-api/scrape"
1717
"github.com/davidgrldo/alkitab-api/internal/server"
1818
)
1919

internal/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99
"strings"
1010
"time"
1111

12-
"github.com/davidgrldo/alkitab-api/internal/bible"
12+
"github.com/davidgrldo/alkitab-api/bible"
1313
)
1414

1515
type Server struct {

0 commit comments

Comments
 (0)