Skip to content

Latest commit

 

History

History
167 lines (135 loc) · 4.99 KB

File metadata and controls

167 lines (135 loc) · 4.99 KB

📌 Detailed Workflow for Implementing the Hiring Test for Backend Developers

This workflow outlines a step-by-step implementation plan for developing the FAQ Management System using Django, ensuring compliance with best practices and evaluation criteria.


1️⃣ Setup the Django Project & Dependencies

Objectives

  • Initialize a Django project.
  • Install required dependencies.
  • Configure project settings.

Steps

  1. Install Django and essential libraries globally:
    pip install Django==5.0.1 djangorestframework==3.14.0 django-ckeditor==6.7.0 django-js-asset==2.2.0 django-redis==5.4.0 redis==5.0.1 Pillow==11.1.0 pytest==7.4.4 pytest-django==4.7.0
  2. Create a new Django project and app:
    django-admin startproject faqmaster
    cd faqmaster
    python manage.py startapp faq
  3. Configure the project settings:
    • Add installed apps (including rest_framework, ckeditor, faq app).
    • Set up the database connection.
    • Configure MEDIA_URL and MEDIA_ROOT for handling CKEditor images.

2️⃣ Design the FAQ Model

Objectives

  • Define a Django model to store FAQs.
  • Support multi-language fields.
  • Enable WYSIWYG formatting for answers.

Steps

  1. Create a FAQ model with the following fields:
    • question (TextField)
    • answer (RichTextField with CKEditor support)
    • question_hi, question_bn, etc., for translated questions.
  2. Implement a model method to dynamically fetch the translated question.
  3. Add __str__ representation for better readability.
  4. Apply migrations to create the database schema.

3️⃣ Integrate WYSIWYG Editor (CKEditor)

Objectives

  • Enable WYSIWYG formatting for FAQ answers.
  • Ensure CKEditor supports rich text and image uploads.

Steps

  1. Configure django-ckeditor in settings.
  2. Set up CKEditor configurations to allow rich text editing.
  3. Enable file upload and image support in CKEditor.
  4. Apply the RichTextField to the FAQ model's answer field.

4️⃣ Develop a REST API for FAQs

Objectives

  • Implement an API for CRUD operations.
  • Support language selection using query parameters.

Steps

  1. Create a Django REST Framework (DRF) serializer for the FAQ model.
  2. Define API views with:
    • List and retrieve FAQs.
    • Support filtering by ?lang= query parameter.
  3. Use Django REST Framework's ViewSet for modular API development.
  4. Register API routes in urls.py.

5️⃣ Implement Multi-language Support

Objectives

  • Support manual translations for FAQs.
  • Provide a fallback to English if translations are not available.

Steps

  1. Create fields for storing translations manually.
  2. Modify the API to:
    • Fetch the translated version of the question if ?lang= is provided.
    • Return the English question as a fallback.

6️⃣ Optimize Performance with Caching

Objectives

  • Reduce redundant database queries.
  • Improve API response times with caching.

Steps

  1. Configure Django's local memory cache backend.
  2. Implement caching for:
    • FAQ lists to avoid repetitive database queries.
    • API responses to minimize database load.
  3. Use Django's cache framework to store results.

7️⃣ Admin Panel & Testing

Objectives

  • Create an intuitive admin interface.
  • Write comprehensive tests.

Steps

  1. Register the FAQ model in Django admin.
  2. Customize the admin interface for better usability.
  3. Write unit tests for:
    • Model methods
    • API endpoints
    • Caching functionality
  4. Run tests using pytest:
    pytest

8️⃣ Documentation & Deployment

Objectives

  • Document the project setup and API usage.
  • Prepare for deployment.

Steps

  1. Create a comprehensive README.md with:
    • Installation instructions
    • API documentation
    • Testing procedures
  2. Document the API endpoints and their usage.
  3. Prepare deployment files:
    • Dockerfile
    • docker-compose.yml
    • Requirements file

9️⃣ Git Best Practices

Objectives

  • Maintain clean commit history.
  • Follow Git best practices.

Steps

  1. Initialize Git repository.
  2. Follow conventional commit messages:
    • feat: Add multilingual FAQ model
    • fix: Improve caching mechanism
    • docs: Update API documentation
  3. Create meaningful branches for features.
  4. Review code before merging.

✅ Evaluation Criteria

Your implementation will be evaluated on:

  • Code Quality: PEP8 compliance, modularity, and readability.
  • Functionality: API correctness, multilingual support, caching efficiency.
  • Documentation: Clear README and API documentation.
  • Testing: Proper unit tests with sufficient coverage.
  • Git Best Practices: Clear commit messages and version control.

🚀 Conclusion

Following this workflow ensures a well-structured Django-based FAQ Management System with multilingual support, caching, an admin panel, and unit testing.