The project was developed to study about techs news, see below the steps to run project and time budget used.
- Study, analysis and construction of the infrastructure strategy -> 6 hours
- Develop to back-end in Laravel(php) -> 5 hours
- Develop to back-end in Loopback(nodejs) -> 3,5 hours
- Document to api -> 1,5 hours
To run project you just need install docker and docker-compose. After install docker, you need to guarantee that the user docker has permission to execute the project.
Remember to check if the ports of services is available.
- 8080 -> back-end laravel
- 3000 -> back-end loopback
- 6379 -> cache redis
- 3306 -> database mysql
- 9200/9300 -> database elasticsearch
- 5601 -> view elasticsearch kibana
- 5672 -> queue rabbitmq
- 15672 -> manager rabbitmq
Open terminal/cmd in project root folder and execute:
docker-compose up -d --build
Check is all services is runing with command:
docker ps
Should return:
Service Name | Image | Port |
---|---|---|
postter-laravel-api | postter-laravel-api | 9000/tcp |
postter-posts-api | posterr-api_postter-posts-api | 3000/tcp |
postter-cache | redis:latest | 6379/tcp |
kibana_posterr | docker.elastic.co/kibana/kibana:7.9.3 | 5601/tcp |
es_data_posterr | docker.elastic.co/elasticsearch/elasticsearch:7.9.3 | 9200/tcp, 9300/tcp |
postter-database | mysql:5.7 | 3306/tcp |
posterr-rabbitmq | rabbitmq:3.8-management-alpine | 4369/tcp, 5671/tcp, |
postter-nginx | postter-nginx | 8080/tcp |
If not run all services run separate:
docker-compose up -d {{service_name}}
The laravel was used to manager every application, but at the same time it synchronizes the database mysql with elasticsearh. The justify is that a database Nosql has better performace in searchs/queries.
Responsible by manager app, it run schedule/job to capture likes of posts e save in mysql database. The redis was used in much endpoints to relieve direct requests to the database.
Roadmap:
- Make tests
- Abstract service of posts by cache-redis
- Authenticate User to list posts, followins, followers, likes and all resources
Database Nosql has better performace to queries.
Synergy with elasticsearch and skilled to work with API/microservices.
Roadmap:
- Make tests
- Sync follows
- Configure follows relationship with resource of posts
Queue architecture, was used to synchronize events the laravel with loopback
- Install libs composer:
docker exec postter-laravel-api composer install
docker exec postter-laravel-api php artisan config:clear
docker exec postter-laravel-api php artisan key:generate
docker exec postter-laravel-api php artisan migrate
docker exec postter-laravel-api php artisan db:seed
- Run watch Jobs:
docker exec postter-laravel-api php artisan schedule:work
All routes have prefix "localhost:8080/api/"
Routes of posts
List all posts
List posts base params in url
Store post
"url" => "required",
"type" => "required",
"user_id" => "required",
"content" => "required"
Get one post base uuid
Update one post base uuid
Delete one post base uuid
####### GET /api/posts/follows/'uuid' Get all posts from users I follow
Get all posts from users who follow me
Get all my posts
Like in post
Deslike in post
Routes of profile
Get all users
Get one user by uuid
Get all profiles I follow
Get all profiles that follow me
Follow profile
Unfollow profile
Access localhost:3000,you can see /openapi.json and /explorer to document api.
Basically the intention is centralize the searchs of posts this service, becou