This is a Django REST Framework (DRF) based API for managing FAQs with automatic translations and caching using Redis. The API allows users to retrieve FAQs in multiple languages efficiently.
- Rich Text Support: FAQs include formatted text (bullets, numbering, etc.).
- Automatic Translations: FAQs are automatically translated into multiple languages upon creation.
- Fast Retrieval with Caching: Translations are cached using Redis to improve performance.
- Admin Panel: Manage FAQs using Django Admin.
git clone https://github.com/Piyush-sri11/FAQ-Translation.git
python -m venv env
source env/bin/activate # On Windows use: env\Scripts\activate
pip install -r requirements.txt
python manage.py migrate
python manage.py createsuperuser
Ensure Redis is installed and running before starting the Django server.
sudo apt update
sudo apt install redis-server
sudo systemctl enable redis-server.service
sudo systemctl start redis-server.service
brew install redis
brew services start redis
- Download Redis from the official website.
- Extract the zip file and run
redis-server.exe
.
sudo apt update
sudo apt install redis-server
sudo service redis-server start
Ensure Redis is running by executing:
redis-cli ping
You should see PONG
as the response.
python manage.py runserver
GET /api/faqs/
Response:
[
{
"id": 1,
"question": "What is instgram",
"answer": "<p>its a social media platform</p>\r\n\r\n<p> </p>",
}
]
GET /api/faqs/?lang=fr
Response:
[
{
"id": 1,
"question": "Qu'est-ce qu'Instagram",
"answer": "<p>C'est une plate-forme de médias sociaux</p>\n<p> </p>"
}
]
POST /admin/faq/faq/add/
Admins can add new FAQs through the Django Admin Panel.
Translations are cached in Redis for faster retrieval.
We use pytest
for running tests. To run the tests, execute:
pytest --disable-warnings
We use flake8
for linting the code. To check for linting errors, execute:
flake8
- Test for FAQ Retrieval
- Test for Adding a New FAQ
- Test for Cached Translation Retrieval
To build the Docker images for your application, use the following command:
docker-compose build
To start the containers defined in your compose.yaml
file, use:
docker-compose up
This command will start all the services defined in the compose.yaml
file. You can add the -d
flag to run the containers in detached mode:
docker-compose up -d
To stop and remove the containers, networks, and volumes defined in your compose.yaml
file, use:
docker-compose down
This command will stop and remove all the resources created by docker-compose up
.
We welcome contributions! To contribute:
- Fork the repository.
- Create a new branch for your feature/fix.
- Commit your changes and push to your fork.
- Submit a pull request.
- Follow PEP8 for Python code.
- Use meaningful commit messages.
- Ensure tests pass before submitting a PR.
If you find a bug or have a feature request, please open an issue.
- Containerizing the application using Dockerfile and docker-compose.yml
- Deploying on AWS or Heroku
This project is licensed under the MIT License.