BlogCMS

Information:

Name: Anthony Del Rosario

Email: adelrosarioh@gmail.com

Project commit history shows dates from Feb 7 to Feb 13, about 7 days, working from 2 to 6 uncontinuos hours between them. I would say it took close to 30 hours to get this project to the state it is, which is functional, but can be improved in a lot of areas.

Table of Contents

Installation

  1. Install Docker (you can download docker from here)
  2. Download zip or clone this repository using git (you can download git from here)
  3. Open repository folder into terminal
  4. Execute the setup.sh for creating an https certificate needed for the API
> sh setup.sh

or if you are on windows

C:\> setup.cmd
  1. Execute docker-compose up -d to start the services in detached mode
    • or execute docker-compose up to see the logs

The installation process should take about 5 minutes depending on your internet connection and computer specs.

How to Use

The BlogCMS UI is deployed in Azure and can be accessed using the following URL

and the API is deployed at

You can use one of the following users or create your own:

  • Public:

    • username: public_user
    • password: Test123*
  • Writer:

    • username: writer_user
    • password: Test123*
  • Editor:

    • username: editor_user
    • password: Test123*

This repo also includes a Postman collection with tests. You can download and install Postman from here.

You can have multiple user sessions login in from a different browser window (not browser tab).

Make sure you are using one of the following supported browsers:

  • Chrome latest
  • Safari latest
  • Firefox latest and extended support release (ESR)
  • Edge latest

Management Tools

To connect to MSSQL Server using SQL Management Studio or other tool use the following connection parameters:

  • Server: localhost,1433 or localhost,14331 if ran with the docker command specified below at the dependencies section
  • User: SA
  • Password: Password123*

Shutting down app

You can shutdown all services at once executing docker-compose down or Ctrl + C in your terminal.

Technologies used

Back-End

  • .NET 6
  • ASP.NET Core 6 Minimal API
  • NodeJS v19.4.0
  • MSSQL Server 2019
  • NGINX
  • Docker

Front-End

  • Angular 15

Libraries

  • Bootstrap 5
  • ngx-markdown
  • Entity Framework Core
  • xUnit
  • Moq
  • FluentAssertions
  • AutoMapper

Project Architecture

The project is separated in two application packages. The FrontEnd web application developed using the Angular Framework and The BackEnd ASP.NET Core RESTful API Web API.

The BackEnd solution structure is divided into the following projects:

  • BlogCMS.Infrastructure: includes database entities configuraiton, interfaces, constants, helpers, and services that support the business logic.
  • BlogCMS.WebAPI: fulfill frontend requests like user signup, signin, post listing and creation, reviews and comments.

The FrontEnd web application is dockerized and served by NGINX which is also used as a reverse proxy, forwarding requests to the Web API.

Overview

Build a minimal Blog Engine / CMS backend API, that allows to create, edit and publish text- based posts, with an approval flow where two different user types may interact.

Requirements

  • Build a RESTful API for a blog engine using .NET. The API should use some authentication mechanism to identify valid users and authorize actions based on the user’s role.

  • The roles for the application are: “Public”, “Writer” and “Editor”.

  • Retrieve a list of all published posts (all roles)

  • Add comments to a published post (all roles)

  • Get own posts, create and edit posts (Writer)

    • Writers should be able to create new posts and retrieve the posts they have written.
    • Writers should be able to edit existing posts that haven't been published or submitted.
  • Submit posts (Writer)

    • When a Writer submits a post, the post should move to a “pending approval” status where it’s locked and cannot be updated.
  • Get, Approve or Reject pending posts (Editor)

    • Editors should be able to query for “pending” posts and approve or reject their publishing. Once an Editor approves a post, it will be published and visible to all roles. If the post is rejected, it will be unlocked and editable again by Writers.
  • Editor should be able to include a comment when rejecting a post, and this comment should be visible to the Writer only.

  • Each post must include a title, some text content, the date of publishing and its author.

Bonuses

  • Build a UI web application to interact with the API. The UI should, as a minimum, display a list of all published posts, and the full contents (including comments) of any particular post when selected.
  • Postman collections OR curl commands to test the API operations.
  • Swagger definition for the API.
  • Relevant Unit Tests covering the business logic in the API.
  • If you have experience and access to Cloud Platforms, deploy the solution to it so it can be tested without local install. You can deploy to Azure/AWS/GCP, etc.

Development

Design Rules

  • You can use the API framework of your choice (ASP.NET, Serverless Functions, ServiceStack, etc.)
    • API was build using .NET 6 and ASP.NET Core WebAPI.
  • You can use the Storage solution of your choice (SQL database with EF or other ORM, NoSQL data stores, flat files, etc.)
    • MSSQL with Entity Framework Core was used as storage solution.
  • You must use a Dependency Injection/IoC container of your choice.
    • The Dependency Injection/IoC container used was the default provided by .NET framework.
  • Login storage can be as simple as hardcoded users/passwords, but the api must use an authentication mechanism to secure its operations.
    • For user management ASP.NET Identity Core was used.
  • All requests and responses must be in JSON format.

Runtime and SDKs

Dependencies

  • Start MSSQL Server docker container:
     docker run -d --hostname mssqldb --name mssqldb_dev -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Password123*" -p 14331:1433 mcr.microsoft.com/mssql/server

Front-End - WebApp

  • Open this repository folder in the terminal and change directory to BlogCMS.UI/BlogCMS

  • Install project dependencies by running command:

     npm install
  • Start development server by running command:

     ng serve
  • Go to http://localhost:4200/

Back-End - WebAPI

  • Open this repository folder in the terminal and change directory to BlogCMS/BlogCMS.WebAPI

  • Install project dependencies by running command:

     dotnet restore "BlogCMS.WebAPI.csproj"
  • Start project by running command:

     dotnet run 
  • Web API server is running on http://localhost:7173