Skip to content

NodeJS, ExpressJS and MongoDB based FAQ manager with multilingual support

Notifications You must be signed in to change notification settings

sahil19-19/FAQ_Manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

32 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FAQ_Manager: MERN Stack Multilingual FAQ Manager

πŸš€ Overview

This is a NodeJS/Express-based FAQ management system with multilingual support and Redis caching for improved performance.

Key Features

βœ… Multilingual Support (English, Hindi, Bengali)
βœ… REST API with Caching (Redis for caching)
βœ… Dockerized (Easily run using Docker)
βœ… Unit Testing & Linting (chai/mocha, ESlint)


πŸ”Ž Directory Structure

FAQ_Manager/
β”œβ”€β”€ Backend/
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ mongoDB.js       # MongoDB connection
β”‚   β”‚   └── redis.js         # Redis connection
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   └── createFaq.js     # FAQ CRUD operations
β”‚   β”‚   └── deleteFaq.js
β”‚   β”‚   └── getFaq.js
β”‚   β”‚   └── getOneFaq.js
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── faq.js          # FAQ MongoDB model
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── faqRouter.js    # API routes
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── getId.js        # Middleware to get FAQ by Id
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── translate.js    # Translation of question and answer
β”‚   β”œβ”€β”€ app.js              # Express app setup
β”‚   β”œβ”€β”€ tests/
β”‚   β”‚   └── faq.test.js     # Unit tests
β”‚   β”œβ”€β”€ .env                # Environment variables
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ eslint.config.mjs
β”‚   β”œβ”€β”€ package-lock.json
β”‚   └── package.json
β”œβ”€β”€ .gitignore
β”œβ”€β”€ .dockerignore
└── docker-compose.yml

πŸ“Œ Technologies Used

  • Node.js
  • Express.js
  • MongoDB
  • Redis
  • Docker

πŸ“Œ Prerequisites

Before you begin, ensure you have the following installed:

πŸ“Œ Installation Steps

1️⃣ Clone the Repository

git clone https://github.com/sahil19-19/FAQ_Manager.git
cd FAQ_Manager

2️⃣ Install Dependencies

npm install

3️⃣ Create .env file:

MONGO_URL="mongodb://localhost/faqdb"
PORT=3000
REDIS_URL="redis://localhost:6379"

4️⃣ Start MongoDB and Redis (Optional)

If you are not using Docker, you would need to start Redis-server and MongoDB-server in your machine

  • Redis
# To start redis-server in mac/ Linux
redis-server  
# For Windows users need to install WSL and install redis, and then run the above command
  • MongoDB MongoDB is run as a service in Windows and doesn't need to be stated/stopped manually For linux (eg arch)
systemctl start mongodb.service

5️⃣ Start the server

npm run dev  # To run using nodemon

node app.js  # To run simply

6️⃣ Running Using Docker

If you prefer to use Docker, run:

docker-compose up 

in FAQ_Manager folder

πŸ“Œ API Usage Examples

Access the application at http://localhost:3000.

Get all FAQs

# Get FAQs in English (default)
GET /api/faqs/

getFaqsen

# Get FAQs in Hindi
GET /api/faqs/?lang=hi

getFaqshi

# Get FAQs in Bengali
GET /api/faqs/?lang=bn

getFaqsbn

Get a single FAQ

# Get FAQ in English (default)
GET /api/faqs/:id

getOneen

# Get FAQs in Hindi
GET /api/faqs/:id?lang=hi

getOnehi

# Get FAQs in Bengali
GET /api/faqs/:id?lang=bn

getOnebn

Create FAQ

POST /api/faqs/
Content-Type: application/json

{
  "question": "What is your name?",
  "answer": "John"
}

getFaq

Delete FAQ

DELETE /api/faqs/:id

delFaq

πŸ“Œ Testing and Linting

To run unit tests for the application, use:

npm test

To run ESlint, use:

npm run lint

πŸ“Œ Contribution Guidelines

To contribute please follow these steps:

  1. Fork the repository and clone it locally.

  2. Create a new branch for your feature:

    git checkout -b new-feature
  3. Commit your changes with meaningful messages:

    git commit -m "feat: Add support for German translations"
  4. Run tests before pushing:

    npm test
  5. Push your branch and create a Pull Request:

    git push origin new-feature

About

NodeJS, ExpressJS and MongoDB based FAQ manager with multilingual support

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published