Giter Site home page Giter Site logo

ysads / nukr Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 84 KB

๐Ÿ‘ฉ๐Ÿฝโ€๐Ÿฆณ๐Ÿ‘จ๐Ÿปโ€๐Ÿฆณ๐Ÿ‘ฑ๐Ÿฝโ€โ™€๏ธ๐Ÿง‘๐Ÿฟ A REST-based prototype of social network

License: Eclipse Public License 2.0

Clojure 100.00%

nukr's Introduction

nukr

A prototype of social network built using functional programming techniques and features.

Running

To run the server, just execute:

$ lein run [port]

The argument port is optional. If you don't provide one, the system will be bound to port 4000 by default.

Note that currently the system uses an in-memory storage adapter, which means there isn't any kind of persistence. Every data eventually inserted into the system will be vanished by the time its execution is stopped.

Schemas

Below are described in structural and semantical ways the problem main entities.

Profile

Param Spec
:profile :name string
The person's name.
:profile :email string
The profile email address of the format [email protected][.br]
:profile :gender string
The profile gender. It may be: "male", "female" or "other".
:profile :password-hash string
The profile's password encrypted. Note passwords, when not encrypted, must be:
  • between 6 and 32 characters long
  • contain at least one uppercase character
  • include at include at least one of the following: !@#$%&*;?<>\
:profile :private boolean
Whether a profile has opt-out to be hidden from suggestions or not.
Here, true means a profile must be hidden.
:profile :connections array(string)
A list of UUIDs, representing the profiles to which a given profile is connected.

Suggestion

Param Spec
:suggestion :profile Profile
The profile identified as suggestion.
:suggestion :relevance int
How many connections this profile recomendation has in common with requested profile.

Using

The application features some API endpoints that can be used to interact with it. The following interactions are available.

Note that all requests must contains the header: "content-type": "application/json"

Creating a new profile

Request

POST /profiles

The request must also include the body as according:

{
  "profile" : {
    "name" : "string",
    "email" : "string",
    "password" : "string",
    "gender" : "male|female|other",
  }
}

Response

Status Description
201 Profile created successfully. This response also includes a body containing the just-created profile, according to the aforementioned schema.
400 No profile was created, because one of the request body params are not following the schema.
405 The request method used is not POST.

Opting a profile in/out of the suggestions engine

Request

POST /profiles/:uuid/opt/:private
Param Value
uuid string. The UUID of the profile to opt.
private boolean
Note that true here stands for a profile being out of the suggestions engine.

Response

Status Description
200 The profile's privacy was set to match private param.
This status also features a body with the updated profile serialized.
404 The uuid param provided doesn't correspond to a profile in the database.

Tag two profiles as connected

Request

POST /profiles/connect/:uuid-a/:uuid-b
Param Value
uuid-a string
The UUID of the first profile
uuid-b string
The UUID of the second profile

Response

Status Description
200 Both profiles are now connected. No further body is returned.
404 Either uuid-a or uuid-b params provided doesn't correspond to a profile in the database.

Get a list of profiles suggestions

Request

GET /profiles/:uuid/suggestions[?count]
Param Value
uuid string
The UUID of the profile to which the suggestions must be made.
count int
Optional. The number of recommendations that must be returned.

Response

Status Description
200 An array of suggestions objects - according its related schema - is returned in the body of the response.
If count param is provided, this array will have at most count items.
404 The uuid param provided doesn't correspond to a profile in the database.

Testing

To execute the test suite provided with the application, just run:

$ lein test

nukr's People

Contributors

ysads avatar

nukr's Issues

Turn connections into directional edges

This is intended to make connections more versatile, by allowing them to be directional and assymetric. That is, if A is connected to B, not necessarely B is connected to A - sort of like how Twitter works.

Create type of connection

This would make connections more qualified, since they can have their own attributes, and maybe be qualitatively described. This allows, for example, a user to have connections which describe friends, family, people they know and etc.

This would also include a new namespace nukr.entities.connection which would hold a Connection record.

Also, a new route would be necessary: GET /profiles/:uuid/connections, which would respond with a collection of connection objects a given profile has, grouped by their type attribute.

Namespace entities within InMemoryStorage component

I think of handling the storage records much like Datomic do: user must specify under which entity a given record will be inserted.

This makes possible for the component to handle different entities under the same storage adapter - for example, connections and profiles -, which makes it behave like a normal database.

Two approaches may be considered when implementing this:

  • Insert the records under a second-level-deep key, in such a way that the first-level key is the entity name.
  • Insert into a custom entity key into the record map, containing the entity name. This doesn't allow a constant-time finding if we want to restrict our search to a given entity, but rather makes it trivial finding to which entity a record belongs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.