This project provides a RESTful API for managing Frequently Asked Questions (FAQs) with multilingual support using Django and Django REST Framework. The FAQs are stored in a database and can be retrieved in different languages using Google Translate. The project also uses Redis for caching.
- Docker
- Docker Compose
- Multilingual Support: FAQs can be retrieved in different languages (English, Hindi, Bengali) using Google Translate.
- Caching: FAQs are cached in Redis for 15 minutes to improve performance.
- Admin Interface: Django admin interface is available for managing FAQs with rich text support using CKEditor.
The project uses the following technologies:
- Django: Web framework for building the FAQ API.
- Django REST Framework: Toolkit for building Web APIs.
- Docker: Containerization platform to package the application.
- Docker Compose: Tool for defining and running multi-container Docker applications.
- Redis: In-memory data structure store used for caching FAQs.
- Google Translate: Service for translating FAQs into different languages.
- CKEditor: Rich text editor for the Django admin interface.
- Python: Programming language used for the application logic.
-
Clone the repository:
git clone https://github.com/yourusername/faq-api.git cd faq-api
-
Build and start the Docker containers:
docker-compose up --build
-
Apply database migrations:
docker-compose exec web python manage.py migrate
-
Create a superuser to access the Django admin:
docker-compose exec web python manage.py createsuperuser
-
Access the application at
http://localhost:8000
.
- URL:
/api/faqs/
- Method: GET
- Query Parameters:(optional): The language code for translation (default is
en
).
curl -X GET "http://localhost:8000/api/faqs/"
[
{
"question": "What is your name?",
"answer": "My name is John Doe."
}
]
- URL:
/api/faqs/?lang=hi
- Method: GET
curl -X GET "http://localhost:8000/api/faqs/?lang=hi"
[
{
"question": "आपका नाम क्या है?",
"answer": "मेरा नाम जॉन डो है।"
}
]
- URL:
/api/faqs/?lang=bn
- Method: GET
curl -X GET "http://localhost:8000/api/faqs/?lang=bn"
[
{
"question": "তোমার নাম কি?",
"answer": "আমার নাম জন ডো।"
}
]
- The FAQs are cached in Redis for 15 minutes to improve performance.
- The project uses Google Translate for translating FAQs into different languages.
- The admin interface is available at
http://localhost:8000/admin/
for managing FAQs.