Giter Site home page Giter Site logo

csv_importer's Introduction

Requirements and answers

Remember: The task is to create a straightforward solution

Implement CLI commands for CRUD (Create, Read, Update, Delete) operations on products.

I would like to find a library for doing this kind of operation. Also, I'm unsure if CLI is the best way to maintain products. In this case, I want to create or find a library that will be aware of the fields used in the model. And there will be no need to update commands when the model changes.

For example, it will read the model (and types) straight from the Database. Is based on some schema for doctrine or something that describes and is a Single Source of Truth for the model.

Implement CRUD endpoints (API) for product management using REST and JSON. Apply pagination and the ability to filter products on collection endpoints.

For CRUD API, I would not use REST and JSON. This is a use case for using some GRAPHQL implementation, or SOAP stuff.

Emit events in JSON format to a RabbitMQ queue when adding a new product, updating an existing one, or deleting a product.

I would use Symfony Messenger to do that, providing only IDs or snapshots of the moments when an event occurred.

Develop unit and integration tests for the solution.

There are two approaches.

  • Let's bulletproof as much as possible.
    • This means I would like unit tests for every class and integration tests for every use case.
    • This is the best approach for code written when we have a matured business model
    • it takes time.
    • You will need to think about different edge cases
  • Use logging, metrics, and monitoring to determine what is happening.
    • This is a better approach for code written when we are still learning about the domain.
    • It is faster to write. (no tests to write/maintain)
    • It is easier to change. (no tests to change)
    • time to market is shorter.

And because the task is speaking about a straightforward solution, my solution for CSV import will be rather simple, so no unit tests, only logging. When another case appears, I can decide how I want to approach my following decisions.

Create API documentation in the OAS (Swagger) format using the NelmioApiDocBundle library.

There is no need for documentation if the REST approach was correctly used. And there is no need for the documentation if other strict standard was used, like GraphQL.

Prepare a development environment using docker-compose.

done.

Have a CLI command for data import from a local CSV file or a file from a remote location, depending on the URL provided by the user.

I would use the Symfony Console component for this. But I have 15 minutes left when writing this.

Second thoughts

ProductDTO in ProductManagement

In this project phase, where everything lives in a monolith application, I can update/change my model easily. Currently, it's 1 to 1 with data from the CSV file. But when I will learn more about the domain and wanted changes, I will be able to modify my code easily. There are no commands to maintain or events to "update" because there is nothing like this. Changes are easy to make.

csv_importer's People

Contributors

navycoat 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.