This is a social network built with Ruby on Rails, React, Docker, and PostgreSQL.
Matvii Butenov 💻🤔 |
Dmytro Ivashchenko 💻🤔🚇 |
Anastasiia Kupchenko 💻📖 |
- Docker + Docker Compose
- a package manager (apt/brew/winget)
If you just need to run the app, skip this part
- Setup hooks
./scripts/setup-hooks.sh
- Run the Docker project
docker compose up
- Create databases and run the migrations
docker exec -it coursework-rails rails db:create db:migrate
Access the services:
- db: http://localhost:5400
- backend: http://localhost:5401
- frontend: http://localhost:5402
Script | Description |
---|---|
rake rubocop |
Run RuboCop (show offenses) |
rake rubocop:autocorrect |
Autocorrect RuboCop offenses (only when it's safe) |
rake rubocop:autocorrect_all |
Autocorrect RuboCop offenses (safe and unsafe) |
Script | Description |
---|---|
npm run dev |
Run the application |
npm run build |
Get the build for a production |
npm run lint |
Run ESLint |
npm run style:fix |
Fix code style with Prettier |
npm run preview |
Run a live preview of a production build |
API swagger is available at the localhost:5401/api-docs.
Retrieves all users.
200
: Users found. Returns an array of User objects.
Updates a user.
200
: User updated.422
: Invalid request
email
(required, string)nickname
(string)city
(string)country
(string)full_name
(string)profile_photo
(string)
Retrieves a user.
id
(path, required, integer)
200
: User found. Returns an array of User objects.
Retrieves a user's posts.
id
(path, required, integer)
200
: Posts found. Returns an array of Post objects.
Retrieves all posts.
200
: Posts found. Returns an array of Post objects.
Creates a post.
content
(required, string)group_id
(optional, integer)reposted_post_id
(optional, integer)
201
: Post created. Returns an array of Post objects.422
: Invalid request
Retrieves a post.
id
(path, required, integer)
200
: Post found. Returns an array of Post objects.
Updates a post.
id
(path, required, integer)
content
(required, string)
200
: Post updated. Returns an array of Post objects.422
: Invalid request
Deletes a post.
id
(path, required, integer)
204
: Post deleted
Creates a comment.
post_id
(path, required, integer)
201
: Comment created. Returns an array of Comment objects.422
: Invalid request
text
(required, string)
Retrieves a post's comments.
post_id
(path, required, integer)
200
: Comments found. Returns an array of Comment objects.
Updates a comment.
post_id
(path, required, integer)id
(path, required, integer)
200
: Comment updated. Returns an array of Comment objects.422
: Invalid request
text
(required, string)
Gets a comment.
post_id
(path, required, integer)id
(path, required, integer)
200
: Comments found. Returns an array of Comment objects.404
: Comment not found
Deletes a comment.
post_id
(path, required, integer)id
(path, required, integer)
204
: Comment deleted
Add a friend.
user_id
(path, required, string)
201
: Friend added successfully422
: Can't add yourself as a friend404
: User not found
friend_id
(required, integer)
Remove a friend.
user_id
(path, required, string)id
(path, required, string)
200
: Friend removed successfully404
: User not found
List mutual friends.
user_id
(path, required, string)
200
: Mutual friends found. Returns an array of User objects.404
: User not found
List followers.
user_id
(path, required, string)
200
: Followers found. Returns an array of User objects.404
: User not found
List following.
user_id
(path, required, string)
200
: Following found. Returns an array of User objects.404
: User not found
Retrieves all groups.
200
: Groups found. Returns an array of Group objects.
Creates a group.
200
: Group created. Returns an array of Group objects.422
: Invalid request
name
(required, string)description
(required, string)
Retrieves a group.
id
(path, required, string)
200
: Group found. Returns an array of Group objects.404
: Group not found
Updates a group.
id
(path, required, string)
200
: Group updated. Returns an array of Group objects.422
: Invalid request
name
(required, string)description
(required, string)
Deletes a group.
id
(path, required, string)
200
: Group deleted404
: Group not found
Adds a member to the group.
id
(path, required, string)user_id
(query, string)
200
: Member added. Returns an array of User objects.422
: User is already a member of this group404
: Group or User not found
Lists members of the group.
id
(path, required, string)
200
: Members found. Returns an array of User objects.404
: Group not found
Removes a member from the group.
id
(path, required, string)user_id
(path, required, string)
200
: Member removed422
: User is not a member of this group404
: Group or User not found
Lists posts of the group.
id
(path, required, string)
200
: Posts found. Returns an array of Post objects.404
: Group not found
Like an item.
200
: Successful. Returns an object withlikeable
,likes_count
, anddislikes_count
.
likeable_type
(required, string, enum: Post, Comment): Type of the item to likelikeable_id
(required, integer): ID of the item to like
Dislike an item.
200
: Successful. Returns an object withlikeable
,likes_count
, anddislikes_count
.
likeable_type
(required, string, enum: Post, Comment): Type of the item to dislikelikeable_id
(required, integer): ID of the item to dislike
Retrieves all private chats.
200
: Private chats found. Returns an array of PrivateChat objects.
Creates a private chat.
user_1_id
(required, integer)user_2_id
(required, integer)
201
: Private chat created. Returns an array of PrivateChat objects.400
: Bad request
Retrieves a private chat.
id
(path, required, integer)
200
: Private chat found. Returns an array of PrivateChat objects.
Lists messages in a private chat.
private_chat_id
(path, required, string)
200
: Successful. Returns an array of Message objects.
Creates a message in a private chat.
private_chat_id
(path, required, string)
200
: Successful. Returns an array of Message objects.
Sends password recovery instructions.
email
(required, string)
200
: Instructions sent404
: Email not found
Endpoints /posts
, /users/:id/posts
and /groups/:id/posts
support querying and pagination.
Example of post querying:
/users/2/posts?sort_activity=asc&content=c&start_date=2024-05-28&end_date=2024-05-29&sort_date=desc
Example of post pagination:
/groups/2/posts?page=1&offset=2
These endpoint also support csv export available at /posts.csv
, /users/:id/posts.csv
and /groups/:id/posts.csv
{
"id": "0",
"email": "string",
"city": "string",
"country": "string",
"full_name": "string",
"nickname": "string",
"last_seen_at": "01-01-1970",
"created_at": "01-01-1970",
"updated_at": "01-01-1970",
"profile_photo": "url_to_picture"
}
{
"id": "0",
"content": "string",
"created_at": "01-01-1970",
"updated_at": "01-01-1970",
"likes_count": "0",
"dislikes_count": "0",
"user": {nested user},
"group": {nested group},
"repost": {nested post},
"liked": "false",
"disliked": "false"
}
{
"id": "0",
"name": "string",
"created_at": "01-01-1970",
"updated_at": "01-01-1970",
"post_id": "0",
"likes_count": "0",
"dislikes_count": "1",
"user": {nested user},
"liked": "false",
"disliked": "true"
}
{
"id": "0",
"name": "string",
"description": "string",
"user": {nested group},
"created_at": "01-01-1970",
"updated_at": "01-01-1970"
}
{
"id": "0",
"user_1": {nested user},
"user_2": {nested user},
"created_at": "01-01-1970",
"updated_at": "01-01-1970"
}
{
"id": "0",
"private_chat_id": "0",
"author_id": "0",
"message": "string",
"created_at": "01-01-1970",
"updated_at": "01-01-1970"
}
{
"likeable_type": {nested likeable},
"likes_count": 0,
"dislikes_count": 0
}