Skip to content

vipulnayak/Faq

Repository files navigation

FAQ System

A multilingual FAQ management system built with Node.js, Express, MongoDB, and Redis.

Features

  • RESTful API for FAQ management
  • Multi-language support with automatic translation
  • Redis caching for improved performance
  • MongoDB for data persistence
  • Swagger API documentation
  • Docker support
  • Comprehensive test coverage
  • Loading indicators for create, update, and delete operations
  • Improved frontend performance with React.memo and staleTime
  • Form validation for question and answer fields

Prerequisites

  • Node.js 18 or higher
  • MongoDB
  • Redis
  • Google Cloud Translation API credentials

Installation

  1. Clone the repository:
git clone <repository-url>
cd faq-system
  1. Install dependencies:
npm install
  1. Create a .env file in the root directory:
PORT=3000
MONGODB_URI=mongodb://localhost:27017/faq-system
REDIS_URL=redis://localhost:6379
GOOGLE_PROJECT_ID=your-project-id
GOOGLE_TRANSLATE_API_KEY=your-api-key

Running the Application

Development

npm run dev

Production

npm run build
npm start

Docker

docker-compose up

API Documentation

Once the application is running, visit http://localhost:3000/api-docs for the Swagger documentation.

API Endpoints

  • GET /api/faqs - Get all FAQs (supports language parameter)
  • POST /api/faqs - Create a new FAQ
    • Request body:
      {
        "question": "string",
        "answer": "string"
      }
  • PUT /api/faqs/:id - Update an FAQ
    • Request body:
      {
        "question": "string",
        "answer": "string"
      }
  • DELETE /api/faqs/:id - Delete an FAQ

Example Usage

Get FAQs in English (default):

curl http://localhost:3000/api/faqs

Get FAQs in Hindi:

curl http://localhost:3000/api/faqs?lang=hi

Create a new FAQ:

curl -X POST http://localhost:3000/api/faqs \
  -H "Content-Type: application/json" \
  -d '{"question":"What is this?","answer":"This is a FAQ system."}'

Testing

Run the test suite:

npm test

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'feat: Add amazing feature')
    • Use the following format for commit messages: type: message
      • feat: A new feature
      • fix: A bug fix
      • docs: Documentation changes
      • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
      • refactor: A code change that neither adds a feature nor fixes a bug
      • perf: A code change that improves performance
      • test: Adding missing tests or correcting existing tests
      • build: Changes that affect the build system or external dependencies
      • ci: Changes to our CI configuration files and scripts
      • chore: Other changes that don't modify src or test files
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published