Make sure you have the following installed:
git clone https://github.com/sujaylande/BharatFD_assignment
cd project
cd server
npm install
npm run dev # Starts the server
cd ../client
npm install
npm start # Opens the website
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
- Server will be running on
http://localhost:5000
- Client will be running on
http://localhost:3000
- 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
.
- 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" }
- Success:
- URL:
/api/faqs
- Method:
GET
- Query Parameters:
- 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" }
- Success (Cached):
We welcome contributions from the community! To contribute, follow these steps:
- Fork the repository on GitHub.
- Clone your forked repository:
git clone https://github.com/sujaylande/BharatFD_assignment cd project
- Create a new branch for your feature or bugfix:
git checkout -b feature-branch
- Make your changes and commit:
git add . git commit -m "Add new feature"
- Push your changes to your fork:
git push origin feature-branch
- Open a Pull Request to merge your changes into the main repository.
- 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.