API for managing posts and comments with AI moderation and auto-reply.
- User registration;
- User login;
- API for managing posts;
- API for managing comments;
- Checking posts or comments at the time of creation for the presence of obscene language, insults, etc., and blocking such posts or comments.
- Analytics on the number of comments that have been added to posts for a certain period. Example URL: /api/v1/posts/1/comments_analytics?date_from=2020-02-02&date_to=2022-02-15. The API returns analytics aggregated by days for each day, the number of comments created and the number of blocked comments.
- The function of automatic reply to comments if the user has enabled it for his posts. The automatic response doesn't occur immediately, but after a period of time set by the user. Also, the answer relevant to the post and comment to which the answer is being made.
The project utilizes the following technologies and tools:
Backend:
- Python programming language (OOP);
- Django framework for building the application;
- Django REST Framework for creating RESTful APIs;
- Djoser for user authentication;
- Django CORS Headers for handling Cross-Origin Resource Sharing (CORS);
- Django Celery Beat for periodic tasks;
- Django Celery Results for storing Celery task results;
- DRF Spectacular for generating API documentation;
- PostgreSQL database (Django ORM);
- Celery for asynchronous task processing;
- Redis as a message broker for Celery;
- Flower for monitoring Celery tasks and workers;
- Google GenerativeAI for generating comments;
- python-dotenv for managing environment variables.
Version Control:
- Git for version control and collaboration.
To run this project, you will need to add the following environment variables:
SECRET_KEY
DB_PORT
DB_HOST
DB_NAME
DB_USER
DB_PASSWORD
CENSORED_WORDS
GEMINI_API_KEY
Look at the .env.sample
To get started with the project, follow these steps:
-
Clone the repository:
git clone https://github.com/Gubchik123/Starnavi-test-task.git
-
Go to the project directory:
cd Starnavi-test-task
-
Install the required dependencies:
pip install -r requirements.txt
-
Set up the database connection and configurations according to the selected database engine. Apply migrations
python manage.py migrate
-
Run the Django development server:
python manage.py runserver
Note: Don't forget about environment variables
-
Access the API Swagger documentation at:
http://127.0.0.1:8000/api/schema/swagger/
-
Build the Docker image:
docker-compose build
-
Run the Docker container:
docker-compose up -d
-
Apply migrations:
docker-compose run backend python manage.py migrate
-
Access the API Swagger documentation at:
http://127.0.0.1:8000/api/schema/swagger/
To run the tests, run the following command:
python manage.py test