Skip to content

A simple dating app that fetches user profiles based on location using h3 geospatial index (IN PROGRESS)

Notifications You must be signed in to change notification settings

Uncensored-Developer/buzz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BUZZ

This is a mini API for a simple dating app that fetches potential user profiles based on location using h3 geospatial index

All that's needed to setup and run this app is Golang and Docker installed locally.


Run Tests

go test -v ./...

Run API

docker compose up

Shutdown

docker compose down


A few users would be added to the database on startup, you can login with email [email protected] and password password123. It already has a few users located within a 100km distance.

APIs

On start up the app would run on http://localhost:8003

Create user:

This creates a random user with a default password of password123

URL: /user/create

Method: POST

Body: NONE

RESPONSE

{
	"result": {
		"id": 25,
		"email": "[email protected]",
		"password": "77546b6a714655717144705547696e414a71485acbfdac6008f9cab4083784cbd1874f76618d2a97",
		"name": "Asha Streich",
		"gender": "M",
		"age": 19,
		"lat": 0,
		"long": 0
	}
}

===================================

Login:

URL: /login

Method: POST

Body:

{
    "email": "[email protected]",
    "password": "password123"
}

RESPONSE

{
	"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOjh9.pJgdc2DQjtWvHA2rP5_WMzD2Z0Ldd4PPtWWw4ocfGkM"
}

===================================

Update Location:

URL: /user/update

HEADERS: Content-Type: application/json, Authorization: Bearer <Token>

Method: PUT

Body:

{
  "Latitude": 41.089097,
  "Longitude": -81.349288
}

RESPONSE

{
  "result": {
    "id": 8,
    "email": "[email protected]",
    "password": "77546b6a714655717144705547696e414a71485acbfdac6008f9cab4083784cbd1874f76618d2a97",
    "name": "Olga Goodwin",
    "gender": "F",
    "age": 0,
    "longitude": -81.349288,
    "latitude": 41.089097,
    "h3_index": 617744365936443391
  }
}

===================================

Swipe:

Use to respond to a user's profile (either YES or NO)

URL: /swipe

HEADERS: Content-Type: application/json, Authorization: Bearer <Token>

Method: POST

Body:

{
  "userId": 1,
  "action": "YES" // or NO
}

RESPONSE

{
  "results": {
    "matched": true,
    "matchedID": 1
  }
}

===================================

Discover:

Use to fetch potential matches based on age range, gender and radius

URL: /discover

HEADERS: Content-Type: application/json, Authorization: Bearer <Token>

Method: GET

QUERY PARAMS: age_range, gender, distance_from

age_range should follow the `{minimum age}-{maximum age}` e.g 18-30. Defaults to 18-60

gender should be either M, F or 0 for male, female and others respectively.

distance_from should be an integer representing the distance from user in Kilometers. Defaults to 50

RESPONSE

{
  "results": [
    {
      "id": 12,
      "name": "Lottie Ledner",
      "gender": "M",
      "age": 33,
      "distanceFromMe": 60
    },
    {
      "id": 13,
      "name": "Vern King",
      "gender": "M",
      "age": 23,
      "distanceFromMe": 20
    },
    {
      "id": 16,
      "name": "Clifton Hodkiewicz",
      "gender": "M",
      "age": 38,
      "distanceFromMe": 40
    }
  ]
}

ASSUMPTIONS

  • Minimum age for creating a profile is 18 years.
  • Maximum age is 60 years.
  • User location is stored as longitude and latitude.
  • The distance from users is a distance between 2 point on earth.
  • For a dating app we need to find users within a few kilometers radius, hence I used a resolution of 9 for H3 indexing which is a good balance between performance and precision.
  • Attractiveness is calculated by number of YES swipes on a user's profile.

GOING FORWARD

  • More refactors to be done (probably introduce a dependency injection framework to properly handle dependencies).
  • More extensive tests and test coverage.
  • Refactor tests setup process across most tests. Currently similar setup logic is repeated in several places. (FIX THAT).
  • Handle NO swipes on user profiles, Probably store them to exclude the involved profiles from being shown to the user in future.
  • Build separate service that regularly aggregates potential matches for active users based on more profile info, activities and other statistics (might include some ML).
  • Add Super Like Feature that ranks profile to the top of the list of potential matches.
  • What happens after match????

About

A simple dating app that fetches user profiles based on location using h3 geospatial index (IN PROGRESS)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published