Skip to content

BharatFD company assignment (create site to manage Frequently Asked Questions with caching) tech: node.js redis mongodb react.js WYSIWYG editor

Notifications You must be signed in to change notification settings

sujaylande/BharatFD_assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

BharatFD_assignment

Project Setup and Installation Guide

Prerequisites

Make sure you have the following installed:

Installation Steps

1. Clone the Repository

git clone https://github.com/sujaylande/BharatFD_assignment
cd project

2. Setup the Backend (Server)

cd server
npm install
npm run dev  # Starts the server

3. Setup the Frontend (Client)

cd ../client
npm install
npm start  # Opens the website

Environment Variables (.env file)

Create a .env file in the root of the server directory and add the following:

PORT=5000
MONGODB_URI=your_mongodb_connection_string
REDIS_HOST=localhost
REDIS_PORT=6379
REDIS_PASSWORD=your_redis_password

Running the Application

  • Server will be running on http://localhost:5000
  • Client will be running on http://localhost:3000

Additional Notes

  • Ensure MongoDB and Redis services are running before starting the server.
  • Modify .env variables according to your setup.
  • If any dependencies are missing, reinstall using npm install.

Happy Coding! 🚀

API Documentation

Add FAQ

  • URL: /api/faqs
  • Method: POST
  • Input:
    • question (String, required): The question to be added.
    • answer (String, required): The answer to the question.
  • Status Codes:
    • 201 Created: FAQ added successfully with translations.
    • 500 Internal Server Error: Error occurred while adding the FAQ.
  • Response:
    • Success:
      {
        "message": "FAQ added successfully with translations!",
        "faq": {
          "_id": "faq_id",
          "question": "What is your name?",
          "answer": "My name is Sujay.",
          "translations": {
            "hi": { "question": "आपका नाम क्या है?", "answer": "मेरा नाम सुजय है।" },
            "bn": { "question": "তোমার নাম কি?", "answer": "আমার নাম সুজয়।" }
          },
          "createdAt": "timestamp"
        }
      }
    • Error:
      {
        "error": "Error message"
      }

Get FAQs

  • URL: /api/faqs
  • Method: GET
  • Query Parameters:
    • [lang](String, optional): The language code for translations (default is en). Supported values are:
      • en: English
      • hi: Hindi
      • bn: Bengali
  • Status Codes:
    • 200 OK: FAQs retrieved successfully.
    • 500 Internal Server Error: Error occurred while retrieving the FAQs.
  • Response:
    • Success (Cached):
      {
        "error": "Returning cached FAQs",
        "cachedFaqs": [
          {
            "question": "What is your name?",
            "answer": "My name is Sujay.",
          },
        ]
      }
    • Success (From DB):
      {
        "error": "Returning FAQs from db",
        "translatedFaqs": [
          {
            "question": "What is your name?",
            "answer": "My name is Sujay.",
          },
        ]
      }
    • Error:
      {
        "error": "Error message"
      }

Happy Coding! 🚀

Contribution Guidelines

We welcome contributions from the community! To contribute, follow these steps:

  1. Fork the repository on GitHub.
  2. Clone your forked repository:
    git clone https://github.com/sujaylande/BharatFD_assignment
    cd project
  3. Create a new branch for your feature or bugfix:
    git checkout -b feature-branch
  4. Make your changes and commit:
    git add .
    git commit -m "Add new feature"
  5. Push your changes to your fork:
    git push origin feature-branch
  6. Open a Pull Request to merge your changes into the main repository.

Contribution Guidelines:

  • Follow coding best practices and maintain code readability.
  • Write clear commit messages.
  • Ensure your changes do not break existing functionality.
  • Add documentation/comments where necessary.
  • If adding a new feature, include relevant tests.

Happy Coding! 🚀

About

BharatFD company assignment (create site to manage Frequently Asked Questions with caching) tech: node.js redis mongodb react.js WYSIWYG editor

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published