Simple social media API to share information thought post and comment belongs to user. The application also count hashtags based on posts and comments. Trending hashtags is hashtags order by counter in last 24 hours.
- As a user, I want to save my username, email, and bio description.
- Authentication and authorization is out of scope of this story and you don’t need to implement them
- As a user, I want to post a text that might contain hashtag(s).
- Maximum limit of a text is 1000 characters
- A hashtag is a text that is followed by # symbol and case-insensitive, for instance: #generasigigih == #GenerasiGigih
- As a user, I want to see all posts that contain a certain hashtag.
- A user can only filter by one hashtag at a time
- As a user, I want to see the list of trending hashtags.
- Trending hashtags are the top 5 most posted hashtags in the past 24 hours
- A post containing multiple instances of a hashtag only counts as 1 occurrence for trending hashtags calculation
- As a user, I want to comment on a post
- A comment can contain hashtag(s)
- A hashtag occurrence in a comment is counted in trending hashtags calculation
- As a user, I want to attach things to a post and comment
- Three kinds of attachment are allowed: pictures (jpg, png, gif), video (mp4), and file (any other extensions outside of pictures and videos)
- Users
- Posts
- Comments
- Hashtags counted with posts and comments
- Trending hashtags
- Gem
- Ruby
- Mysql
- RSpec (testing purposes)
Clone the project
git clone https://github.com/ilhamsyahids/socialize-gigih
Go to the project directory
cd socialize-gigih
Install dependencies
bundle install
Add socialize_db
database name and edit mysql config db/db_connector.rb
. Then:
mysql --password=[your_password] -u [your_username] socialize_db < socialize_db.sql
Start the server
ruby main.rb
To run tests, run the following command
rspec -f d spec/run_test.rb
GET /users
GET /users/${id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of user to fetch |
GET /users/id/${id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of user to fetch |
GET /users/username/${username}
Parameter | Type | Description |
---|---|---|
username |
string |
Required. Username of user to fetch |
POST /users
Parameter | Type | Description |
---|---|---|
email |
string |
Required. Email of user |
username |
string |
Required. Username of user |
bio |
string |
Bio of user |
GET /posts
GET /posts/${id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of post to fetch |
GET /posts/id/${id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of post to fetch |
GET /posts/user_id/${user_id}
Parameter | Type | Description |
---|---|---|
user_id |
string |
Required. user_id of post to fetch |
GET /posts/hashtag/${hashtag}
Parameter | Type | Description |
---|---|---|
hashtag |
string |
Required. hashtag of post to fetch |
POST /posts
Parameter | Type | Description |
---|---|---|
user_id |
string |
Required. User Id of post |
content |
string |
Required. Content of post (limit 1000) |
file |
file |
Attached file |
GET /comments
GET /comments/id/${id}
Parameter | Type | Description |
---|---|---|
id |
string |
Required. Id of comment to fetch |
GET /comments/hashtag/${hashtag}
Parameter | Type | Description |
---|---|---|
hashtag |
string |
Required. hashtag of comment to fetch |
GET /comments/post_id/${post_id}
Parameter | Type | Description |
---|---|---|
post_id |
string |
Required. Post Id of comment to fetch |
POST /comments
Parameter | Type | Description |
---|---|---|
user_id |
string |
Required. User Id of comment |
post_id |
string |
Required. Post Id of comment |
content |
string |
Required. Content of comment (limit 1000) |
file |
file |
Attached file |
- Ruby
- Mysql
Change desired host in inventory.yml
Review and edit to the desired configuration in playbook.yml
To run deployment :
ansible-playbook -i inventory.yml playbook.yml --user [user] --private-key [your_private_key]
Example:
ansible-playbook -i inventory.yml playbook.yml --user ilham --private-key ~/.ssh/id_edxxxx
- Generasi Gigih
- YABB
- Gojek