You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I collaborated with Hani Abdel Ghani on this API. We followed the clean architecture from this site to complete the APIs. The steps we took:
Created a solution for the Domain layer including our entities (Users.cs, Posts.cs, Notifications.cs, Comments.cs, Categories.cs, Votes.cs)
Created a solution for the Application layer which includes the interfaces for our entities, as well as the services.
Created a solution for the Infrastructure layer, applying the interfaces for our repositories.
Created an ASP.NET Core Web API project for our application layer. Implementing the necessary controllers and configuring the program.cs.
We tested our CRUD functions on swagger insuring everything works as intended.
The following is a detailed description of what the APIs are capable of doing:
The CRUD Functions for Users consist of:
Post Sign in: lets Users Sign in
Post Sign up: lets Users Sign up to a new account(Username should be unique)
Get Users: lets you return a user by there ID
Delete User: Signed in Users with their token activated can delete their account by providing their password
Get Username: Returns the Username of the user signed in
Get Email: Returns the Email of the user signed in
Get Posts: Returns the posts of the user signed in
Get Bio: Returns the bio of the user signed in
Post Bio: lets Users create or update their Bio
Get Profile Picture: Returns signed in user's profile picture
Post Profile Picture: Lets Users upload or update their Profile picture
Get profile picture {id}: Returns a profile picture by its id
Get activity: Returns user's activity by providing the user Id
Patch username: Updates the username of a signed in user (User should provide their new Username)
patch email: Update the email of a signed in user (User should provide their new email)
patch password: Updates the passowrd of a signed in user (User should provide their current password, new password, and confirm password fields)
The CRUD Functions for Posts consist of:
Post Posts: where Users can create a post by providing a Title, Description, Tags, and a Category Name
Get Posts: Returns a post by providing its ID
Delete Posts: Users can delete their posts if they are signed in
Put Posts: Users can update their already existing post by providing their fields.
Get Post images: gets the post images by providing the post ID
Post Posts Images: lets Users to upload images to their posts
Get Top Posts: Returns Posts according to how many upvotes they have
Get Latest Posts: Returns Posts according to how recent they are (Takes input number of posts you want to return and offset(used for pagination))
Get Posts Count: Returns the number of posts present in the Database
Get Posts by Category: Returns posts that are present in a specific Category (Takes input Category ID)
Get Posts Search: Users can Query a post by providing the author name, the post title or the desciption
The CRUD Functions for Notifications consist of:
Post Notification: Notifications can be created and sent to the user that is signed in, it takes Notification Type, Message, and isRead, PostId, and receiverId.
Get User Notification: Returns all the Notifications to the user that is signed in.
Patch Notification: Updates the notification to be read or unread by providing its ID
Delete: deletes a Notification by providing its ID
The CRUD Functions for Comments consist of:
Post: Users can create a Comment by providing Post ID and the content of the comment
Get: Returns Comments that the user signed in did to a specific post by providing the Post ID
Put: Changes a comment's content by providing the Comment ID
Delete: Deletes a comment by providing its Comment ID
Get Comments by Post ID: Returns comments specific to a post by providing the postID
The CRUD Functions for Categories consist of:
Post: Users can create a category by providing its Name
Get: Returns all available Categories or you can get a specific one by its Category ID
Delete: Deletes a Category by providing its Category ID
The CRUD Functions for Votes consist of:
Post: A User can vote on a post by providing PostID and Vote Type (Note: A vote gets deleted if a user Upvotes/Downvotes and then proceed to do the same action again on the same posts)
Delete: Deletes the Vote By providing its ID
Get: All Votes can be returned by Providing the Post ID or you can return one vote by providing the Vote ID
Security Measures:
JWT along with Microsoft.AspNetCore.Authorization Libraries were implemented to generate a Token for each signed in user, and from this Token users get the privlige to use the features of some of the APIs(such as creating post, voting, commenting....)
As well BCrypt was implemented to Hash passwords being sent to the database.