Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mborsten/recommender
Recommendation library for Vapor
https://github.com/mborsten/recommender
swift vapor vapor-service
Last synced: about 14 hours ago
JSON representation
Recommendation library for Vapor
- Host: GitHub
- URL: https://github.com/mborsten/recommender
- Owner: mborsten
- License: mit
- Created: 2020-06-20T11:19:21.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-06-23T20:44:11.000Z (over 4 years ago)
- Last Synced: 2024-04-23T13:06:11.832Z (7 months ago)
- Topics: swift, vapor, vapor-service
- Language: Swift
- Homepage:
- Size: 26.4 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Recommender for Vapor
A recommender service for Vapor, using the [gorse](https://gorse.io) recommender system# Getting started
Added Recommender to your `Package.swift`
```swift
.package(url: "https://github.com/mborsten/recommender.git", from: "0.0.1-alpha1"),
```# Usage
Recommender uses `gorse` to recommend items based on `User`s ratings. The default config expects the gorse service to be available at
http://0.0.0.0:5050.You can use the example `docker-compose.yml` file:
```bash
cd docker
docker-compose build
docker-compose up
```Extend you Item's model:
```swift
extension Item: RecommendableItem { }
```Now you can add ratings (in the context of an authenticated user)
```swift
let protected = routes.grouped(User.authenticator())
protected.post("items", ":itemId", "like") {
let user = try request.auth.require(User.self)
return request
.recommend
.insertFeedback(userId: try user.requireID().uuidString, itemId: request.parameters.get("itemId")!, rating: 5)
.map { .ok }
}
```To retrieve a list of recommended items
```swift
let protected = routes.grouped(User.authenticator())
protected.get("items", "recommended") {
let user = try request.auth.require(User.self)
return Item.recommended(req: request, userId: try user.requireID())
}
```Retrieve a list of popular items
```swift
routes.get("items", "popular") {
return Item.popular(req: Request, number: 10)
}
```# Todo
Add the following queries:
* Latest items
* Random items
* Similar items