Hosted API: Hack the North Backend Challenge.
This application is designed with MongoDB, Express, Node, and PineconeDB to address the challenges of managing users and skills, with an additional focus on group formation and management during the hackathon.
To begin interacting with the API, follow these steps:
Accessing the API:
npm start to start the server with Nodemon on your localhost.Running Unit Tests:
npm install in your terminal.npm test. This will initiate the test suite, allowing you to verify that the API operates as expected.One of the challenges that I wanted to tackle in my API is the problem of finding compatible team members in hackathons, particularly for newcomers who may have limited skillsets and want to work with others that have similar skills as them. This was the inspiration for the development of a system that facilitates the formation of groups based on similarities in skills and interests! By leveraging a vector database, this system significantly improves the efficiency of matching participants. Although currently focused on finding teammates for the hackathon, this feature is easily extendible to matching mentors, sponsors and friends. 🙂
Vector Representation
Insertion into Pinecone
/new-user endpoint, their skills vector is inserted into Pinecone which stores their user ID and a vector (like [0, 1, 1, 0, ...]). The assumption for this is that there are a set number of skills which we deem as key metrics to match users together. This is done using Pinecone's upsert method, which either inserts a new vector or updates an existing one.Similarity Search
query method, which returns the IDs of the most similar vectors in the database.Group Formation
/groups/create-group endpoint, which creates a new group with the given users.One of the decisions I had to make when designing the API was how to separate the skills from the users. Originally, I had the skills as part of the user model but I ultimately decided to create a separate model for the flexibility of querying the skills. This was eventually helpful with the group formation portion of the project because I was able to query the number of skills and form the vector accordingly. Additionally, by creating a separate table for the skills, additional metrics are able to be tracked such as the number of users with certain skills. In the context of a hackathon, I thought that this would be helpful for event planning and narrowing down what workshops would be most relevant to the participants!
Another design choice I made was to use MongoDB instead of a traditional SQL database and using REST instead of GraphQL. The database decision was primarily influenced by the flexibility and development speed that MongoDB provides. For a hackathon backend I thought that this was the best decision because of the constantly evolving data requirements, importance of streamlined development process and because the data requirement is limited to a relatively small size (number of entries is limited by the number of attendees). This thought process was also the reason why I decided against using a GraphQL backend, as I didn't deem the number of user properties to be enough to require efficient data retrieval for specific properties.
index.js: Main application entry point. Initializes the Express server and MongoDB connection.scripts/addUsers.js: Script to add users from a JSON file to the database via the /new-user endpoint.models/:user.js: Defines the User and Skill Mongoose schema.group.js: Defines the Group Mongoose schema.config/key.js: Contains the MongoDB connection string.data.json: Mock User data in JSON format.vercel.json: Configuration for Vercel deployment.routes/:users.js: Routes for user-related operations.groups.js: Routes for group-related operations.skills.js: Routes for skill-related operations.test/api.test.js: API endpoint tests./users: Fetch all users, sorted by creation date (descending)./users/id/:id: Fetch a user by ID./users/username/:username: Fetch a user by username./users/insert/:id: Insert a user based on their ID into the vector database./users/insertAll: Insert all users into the vector database./users/:id: Delete a user by ID./users/:id: Update a user by ID./new-user: Add a new user./groups/: Fetch all groups./groups/:id: Fetch a group by ID./groups/:groupName: Fetch a group by their group name./groups/groupIndividual/:id: Create a group for a particular user./groups/group-ungrouped-users: Create groups for all users that don't have a group yet./groups/ungrouped-users: Fetch all users that don't have a group yet./groups: Create a new group./skills: Fetch all skills, with optional filtering by frequency./skills/count/:skill: Fetch the number of users with a specific skill.DB_URI_PASSWORD: MongoDB database password.PORT: The port that the server is running on.PINECONE_API_KEY: The API key for PineconeDB.