Linkedin: https://www.linkedin.com/in/cleitongangi
This application is for study purposes only, it is not a production applicatio
- Visual Studio 2022
- .Net 6
- Docker
- Responsibility separation concerns, SOLID, YAGNI and Clean Code
- DDD - Domain Driven Design (Layers and Domain Model Pattern)
- Repository
- IoC
- .Net 6
- Docker
- Dapper
- Entity Framework Core 6
- SQL Server 2019
- Full-text search
- AutoMapper
- FluentValidation
- Swagger
- XUnit
- Unit Test
- Integration Test
- Visual Studio 2022
- .Net 6
- Docker
Run through Visual Studio selecting Docker-compose. or Execute the following command in powershell inside the "Cleiton-Gangi-2-5-web-back-end\docker" folder:
docker-compose -f "docker-compose.yml" -f "docker-compose.override.yml" -p dockercompose-posterr-cg --ansi never up -d --force-recreate --remove-orphans Access the API using the URL: http://localhost:54904/swagger/index.html
If you need down the environment, you can use the following comand:
docker-compose -f "docker-compose.yml" -f "docker-compose.override.yml" -p dockercompose-posterr-cg down
- I hard-coded userId in method "AppControllerBase.GetAuthenticatedUserId", to test is possible changed it. But if you change it to 2, Integration Tests will fail because integration tests is prepared to use the user 1 and interact with user 2. This could be improved by making a mock of this class, but I didn't think it was necessary for this assessment.
Stores the post type, like Post, Repost or Quote. Posts has FK to PostTypes.
Stores the posts, quote posts and reposts. When is quote or a repost, the ParentId column store the reference to related Post.
Stores the users informations and stores the user metrics (FollowersCount, FollowingCount and PostsCount). It would be better if these metrics were in a separate table, I commented this in self-critique section.
Stores the record of followings.
Endpoints are accessible through swagger for easy testing and understanding. The names and parameters are pretty clear, but follow a brief about each endpoint.
To use in home page feed to return all posts.
To use in home page feed to return just posts by those you follow.
Allows create a new post or quote a post. To quote a post, is required fill the optional parameter "quotePostId" with parent post id.
Allows repost a post.
To use in profile page to get the user informations.
Allows follow a new user.
Allows unfollow a user.
To use in profile page to get the posts from a user.
To search a post or a quote post.
- Set a better standard for returning API errors. For example, NotFound return a json in a differente way that BadRequest. They could return errors in the same json structure.
- In pagination returns, could returning the url to fetch the next and previous pages.
- In this project it would be better to use mongoDB or cosmoDB as database.
- Run Integration Tests in a docker image to allow test the search with Full-text Search. As I'm using the localDb, was not possible write tests for Search funcionality because localDb don't support Full-text Search.
- I could have used specifications pattern to reuse validation rules without duplicating them in different Validations.
- I stored the user metrics (number of posts, number of folling and number of folowers in Users table). I decided do this way, because as the count of this information will be constant, it is more performatic to get this from a table than count this informations every time from Posts and UserFollowing table, because these tables will increase a lot with time. But the improvement that can be made is to separate these quantity columns in another metric table called UserMetrics. It is better to separate to don't generate concurrency in the readings of Users table with updates of these metrics, since the updates lock the table exclusively.
The main bottleneck will be the database. A better aproach is use mongoDB as Database or Azure CosmoDB. The advantage of CosmoDB over SQL server is that it is easier to scale, CosmoDB allow easily replicate the Database around de World and Azure assure a SLA of single-digit millisecond response time. If wanted continues using SQL Server, is possible setup High Availability to create other read-only copies of Database, and change application to implement CQRS technique, to write in main Database and read from copies. To scale up the API and front-end, is possible create a load balance to increase the performance. Is possible do this using for example Azure Application Gateway.