Сколько времени займёт выполнение этого тестового задания: Необходимо разработать rest…
- User
Сколько времени займёт выполнение этого тестового задания: Необходимо разработать rest api которая будет иметь сущности:
- Товар - сущность имеет поля:
- id
- Заголовок
- поле slug - автогенерация значения на основе заголовка в ЧПУ (человеко-подобный урл)
- Описание
- Категория товара
- Категория - сущность имеет поля:
- id
- заголвок
- slug Связь Товар - Категории должна быть построена на основе Один ко многим (1 товар может быть связан с несколькими категориями) Необходимо реализовать базовые CRUD запросы, позволяющие создавать, обновлять, удалять, получать информацию о сущностях. при этом:
- Необходимо реализовать маршрут для получения информации о товаре по полю slug, который должен возвращать информацию о товаре и связанных с ним категориях
- Необходимо реализовать маршрут для получения информации о категории по полю slug, который должен возвращать информацию о категории и связанных с ним товары, товары должны разбиваться с учётом пагинации, маршрут должен принимать два квери параметра:
- page - текущая страница
- perPage - кол-во выводимых товаров
- Необходимо реализовать маршрут позволяющий искать товары по полю "Заголовок" с неточным вводом и возвращать все поля о товаре и поля о связанными с ней категориями
Маршрут для получения товара по slug должен кешироваться с применением redis.
Используемая бд: Postgresql
Стек: Nest.js/Express.js, Redis, Elasticsearch, Sequelize
Результат работ необходимо отправить в github и предоставить доступ по ссылке, так же необходимо написать базовый docker-compose файл для быстрого разворачивания и тестирования всех сервисов.
- Assistant
To estimate the time required to complete this test assignment, let's break down the tasks involved and provide time estimates for each. This will help you plan and allocate time effectively.
1. Understanding the Requirements
- Tasks:
- Carefully read and comprehend all the assignment requirements.
- Clarify any ambiguities or uncertainties.
- Time Estimate: 0.5 hours
2. Setting Up the Development Environment
- Tasks:
- Initialize a new project with Nest.js or Express.js.
- Install and configure Sequelize for PostgreSQL.
- Set up connections to Redis and Elasticsearch.
- Create a basic project structure with proper modules and dependencies.
- Time Estimate: 1.5 to 2 hours
3. Database Design and Modeling
- Tasks:
- Define the database schemas for
ProductandCategoryentities. - Implement the many-to-many relationship between
ProductandCategoryusing a junction table (since a product can belong to multiple categories).- Note: Although the requirement mentions "Один ко многим" (one-to-many), the description specifies that one product can be associated with multiple categories, which is a many-to-many relationship.
- Set up models and associations in Sequelize.
- Implement slug generation logic based on the title for both
ProductandCategory.
- Define the database schemas for
- Time Estimate: 1.5 to 2 hours
4. Implementing CRUD Operations
- Tasks:
- Develop Create, Read, Update, and Delete endpoints for both
ProductandCategory. - Implement input validation and error handling.
- Test each endpoint using a tool like Postman.
- Develop Create, Read, Update, and Delete endpoints for both
- Time Estimate: 2 to 3 hours
5. Implementing Specific Routes
- Tasks:
- Get Product by Slug:
- Create a route to retrieve a product based on its slug.
- Include associated categories in the response.
- Implement caching with Redis for this route.
- Get Category by Slug with Pagination:
- Create a route to retrieve a category based on its slug.
- Include associated products, paginated according to
pageandperPagequery parameters. - Implement pagination logic.
- Search Products by Title:
- Implement a search functionality to find products by partial title matches.
- Return products along with their associated categories.
- Use Elasticsearch for efficient and scalable searching.
- Get Product by Slug:
- Time Estimate: 4 to 5 hours
6. Integrating Redis Caching
- Tasks:
- Install and configure a Redis client (e.g.,
redisorioredis). - Implement caching logic for the "Get Product by Slug" route.
- Handle cache invalidation on product updates or deletions.
- Install and configure a Redis client (e.g.,
- Time Estimate: 1 to 1.5 hours
7. Integrating Elasticsearch for Search Functionality
- Tasks:
- Install and configure the Elasticsearch client library.
- Set up indexing for products in Elasticsearch.
- Implement synchronization between PostgreSQL and Elasticsearch (e.g., update indices on product creation, update, or deletion).
- Handle search queries and parse results.
- Time Estimate: 2 to 3 hours
8. Writing Docker Compose Configuration
- Tasks:
- Create a
docker-compose.ymlfile to set up:- The Node.js application.
- PostgreSQL database.
- Redis server.
- Elasticsearch server.
- Ensure all services are networked correctly and environment variables are set.
- Test the setup to ensure it works seamlessly.
- Create a
- Time Estimate: 1.5 to 2 hours
9. Testing and Debugging
- Tasks:
- Thoroughly test all endpoints and functionalities.
- Fix any bugs or issues that arise.
- Ensure that edge cases and error conditions are handled gracefully.
- Time Estimate: 2 hours
10. Documentation and Repository Setup
- Tasks:
- Write clear and concise documentation, including:
- Setup instructions.
- API endpoint descriptions.
- Any prerequisites or dependencies.
- Push the code to GitHub and ensure all files are included.
- Verify that the repository is accessible and the instructions are sufficient for someone else to run the project.
- Write clear and concise documentation, including:
- Time Estimate: 1 hour
Total Estimated Time
Adding up the time estimates:
- Minimum: 14.5 hours
- Maximum: 19 hours
Approximate Total Time: 15 to 19 hours
Additional Considerations
-
Experience Level: If you're already experienced with the required technologies (Nest.js/Express.js, Sequelize, Redis, Elasticsearch, Docker), you might complete tasks faster. If not, allocate extra time for learning.
-
Complexity of Features:
- Elasticsearch Integration: If you are not familiar with Elasticsearch, setting it up and integrating it could take more time.
- Redis Caching: Implementing caching logic requires careful handling to ensure data consistency.
-
Testing:
- Proper testing is crucial. Allocate sufficient time to write tests and ensure all features work as expected.
- Consider writing automated tests if time allows.
-
Code Quality:
- Writing clean, maintainable code with comments and adhering to best practices may take additional time but is valuable.
-
Potential Challenges:
- Data Synchronization: Keeping Elasticsearch indices in sync with the PostgreSQL database.
- Docker Networking: Ensuring all services communicate correctly within Docker.
-
Buffer Time:
- It's wise to include some buffer time for unforeseen issues or delays. Adding an extra 1 to 2 hours can help accommodate this.
Recommendations
-
Clarify Requirements Early: Ensure you fully understand the relationship between entities and any ambiguous instructions.
-
Plan Before Coding: Spend time designing your application architecture and data models before diving into code.
-
Incremental Development:
- Start with the core functionalities.
- Integrate Redis and Elasticsearch after ensuring basic operations work.
-
Utilize Resources:
- Refer to official documentation for Redis, Elasticsearch, and Docker.
- Leverage community examples or tutorials if you get stuck.
-
Time Management:
- Break down tasks into smaller sub-tasks.
- Set milestones to track your progress.
By following this breakdown and considering the additional points, you should be able to complete the test assignment in approximately 15 to 19 hours. Adjust the estimates based on your confidence with each technology and personal working pace.
- Tasks: