Giter Site home page Giter Site logo

prescriber-movies-api's Introduction

User Stories

  • As a user, I want to be able to see a list of all the available movies and filter by title, year of release or both.
  • As a user, I want to be able to see the details of a movie.
  • As a user, I want to be able to see the list of all the movies and search for a movie by its name or director
  • As a admin user, I want to be able to add a new movie to the list of movies.
  • As a admin user, I want to be able to update the details of a movie.
  • As a admin user, I want to be able to delete a movie from the list of movies.

Work log:

  1. I started by creating the user stories, new repository on GitHub and and the project structure following clean architecture principles
  2. I created the models, validators and services. I will structure the layers by feature folders in the domain and application layer
  3. I started the implementation of the Services and repositories
  4. I Created the implementation of the repositories I decided to use SQL Server, but since we can't use dapper or entity framework and went and use ADO.NET directly.
  5. I was thinking on changing the db to mongoDB, but it is to late already spent a lot of time implementing the repositories (with ado.net :( ). Maybe when I finish everything I will switch
  6. I will now continue with the API endpoints. I will leave the tests at the end because I have limited time. I know normally the test should go first but unfortunatly I had an emergency situation that took a lot of the allocated time I had for this challenge. I think is better to push on with delivering a working software and then go back and add the tests.
  7. I also decided to use exception handling middleware to handle bussiness rules. I would have use the result pattern but I think it would be overkill for this small project.
  8. Created a database initializer to seed to database and create database. I decided to use fluent migrator for this. I just easier and super light weight.
  9. I will start implementing the authentication and users. I Decided to use BCrypt to hash the password cause the follow the latest hashing standards and is very secure.
  10. Add JWT Authentication
  11. Created the docker file and docker-compose file to run the application in a container
  12. Add some unit tests

Running the Application with Docker Compose

  1. Install Docker and Docker Compose on your machine.
  2. Navigate to the root directory of the project where the docker-compose.yml file is located.
  3. Run the command docker-compose up --build. This command will build the Docker images and start the containers.
  4. The application will be available at http://localhost:8080.

Note on Database Initialization with Docker

When running the application with Docker Compose, sometimes the API service might start before the database service is fully initialized. This can cause errors when the API tries to connect to the database. If you encounter this issue, you can try the following steps:

  1. Stop all Docker services by running the command docker-compose down in your terminal.
  2. Wait for a few seconds to ensure that the database container has fully stopped.
  3. Start all Docker services again by running the command docker-compose up --build in your terminal.

The --build option ensures that Docker Compose rebuilds the images, which can help if the database initialization issue is due to an outdated image.

Remember that the database initialization can take a while, especially the first time you run the application. So, if you encounter any issues, it's a good idea to wait for a bit and then try again.

Running the Application with LocalDB on Windows

  1. Install .NET 5.0 SDK on your machine.
  2. Install SQL Server Express LocalDB on your machine.
  3. Navigate to the root directory of the project where the .csproj file is located.
  4. Update the ConnectionStrings__DefaultConnection and ConnectionStrings__MasterConnection in the appsettings.json file to use your LocalDB instance. The connection strings should look something like this:
"ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=MoviesDb;Trusted_Connection=True;MultipleActiveResultSets=true",
    "MasterConnection": "Server=(localdb)\\mssqllocaldb;Database=master;Trusted_Connection=True;MultipleActiveResultSets=true"
}

#Important: Do not change the "MoviesDb" database name. The application uses this name to seed the database.

Admin User

The application includes an admin user that is created when the database is seeded. The admin user has the following credentials:

This user has administrative privileges and can add, update, and delete movies.

Authenticating with the User/Login Endpoint

To authenticate and get a token, you can use the user/login endpoint. Send a POST request

{
  "email": "[email protected]",
  "password": "superadmin"
}

prescriber-movies-api's People

Contributors

rafar55 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.