A Django REST API for scheduling and managing social media posts across multiple platforms (Instagram, Twitter, LinkedIn, YouTube).
- 🔐 JWT Authentication - Secure token-based authentication
- 📅 Post Scheduling - Schedule posts for future publication
- 🔍 Filtering & Search - Filter posts by platform, status, and search content
- 📊 Statistics - Get insights on your posts
- 🚫 Post Management - Cancel or edit pending posts
- 📚 API Documentation - Interactive Swagger/OpenAPI documentation
- 🔄 Celery Integration - Asynchronous task processing with Redis
- Backend: Django 5.2.7, Django REST Framework
- Authentication: JWT (djangorestframework-simplejwt)
- Task Queue: Celery with Redis
- Database: SQLite (default, easily configurable for PostgreSQL)
- API Docs: drf-yasg (Swagger/OpenAPI)
- Python 3.8+
- Redis (for Celery)
- pip
-
Clone the repository
git clone <repository-url> cd Auto_post
-
Create a virtual environment
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies
cd backend/postAutomation_backend pip install -r ../../requirements.txt -
Set up environment variables
Create a
.envfile in the project root (or use defaults):SECRET_KEY=your-secret-key-here DEBUG=True ALLOWED_HOSTS=localhost,127.0.0.1 CELERY_BROKER_URL=redis://localhost:6379/0 CELERY_RESULT_BACKEND=redis://localhost:6379/0 CORS_ALLOWED_ORIGINS=http://localhost:3000,http://localhost:8000
-
Run migrations
python manage.py migrate
-
Create a superuser (optional)
python manage.py createsuperuser
-
Start Redis (required for Celery)
redis-server
-
Start Celery worker (in a separate terminal)
cd backend/postAutomation_backend celery -A core worker --loglevel=info -
Start the development server
python manage.py runserver
POST /api/auth/register/- Register a new userPOST /api/auth/login/- Login and get JWT tokensPOST /api/auth/token/refresh/- Refresh access tokenGET /api/auth/profile/- Get user profilePUT /api/auth/profile/- Update user profile
GET /api/posts/- List all posts (filtered by user)POST /api/posts/- Create a new postGET /api/posts/{id}/- Get post detailsPUT /api/posts/{id}/- Update a postPATCH /api/posts/{id}/- Partially update a postDELETE /api/posts/{id}/- Delete a postPOST /api/posts/{id}/cancel/- Cancel a scheduled postGET /api/posts/stats/- Get post statistics
?platform=instagram- Filter by platform?status=pending- Filter by status?search=keyword- Search in content?ordering=-scheduled_time- Order by field?page=1- Pagination
Once the server is running, visit:
- Swagger UI: http://localhost:8000/swagger/
- ReDoc: http://localhost:8000/redoc/
curl -X POST http://localhost:8000/api/auth/register/ \
-H "Content-Type: application/json" \
-d '{
"username": "johndoe",
"email": "john@example.com",
"password": "securepassword123",
"password2": "securepassword123"
}'curl -X POST http://localhost:8000/api/auth/login/ \
-H "Content-Type: application/json" \
-d '{
"username": "johndoe",
"password": "securepassword123"
}'curl -X POST http://localhost:8000/api/posts/ \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"platform": "twitter",
"content": "Hello, world!",
"scheduled_time": "2024-12-31T12:00:00Z"
}'curl -X GET http://localhost:8000/api/posts/stats/ \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"Auto_post/
├── backend/
│ └── postAutomation_backend/
│ ├── core/ # Django project settings
│ ├── posts/ # Posts app
│ ├── users/ # Users app
│ └── manage.py
├── frontend/ # Frontend (to be implemented)
├── requirements.txt
└── README.md
python manage.py testpython manage.py makemigrations
python manage.py migrate- Frontend application (React/Vue)
- Actual platform API integrations
- Media file upload handling
- Post templates
- Recurring posts
- Analytics dashboard
- Email notifications
- Docker configuration
- CI/CD pipeline
cd backend/postAutomation_backend
python manage.py makemigrations
python manage.py migratepip install -r ../../requirements.txt- Start Redis:
redis-server - Start Celery worker:
celery -A core worker --loglevel=info - Start Django server:
python manage.py runserver - Visit Swagger docs: http://localhost:8000/swagger/
python manage.py createsuperuser
# OR use the registration endpoint- Improve Celery task error handling
- Add retry logic for failed posts
- Store task IDs to allow cancellation
- Add proper logging
- Write unit tests for models
- Write API endpoint tests
- Write Celery task tests
- Add file upload support for images/videos
- Integrate with cloud storage (AWS S3, Cloudinary)
- Add media validation
- Choose framework (React/Next.js/Vue)
- Authentication UI
- Post creation/scheduling interface
- Post management dashboard
- Calendar view for scheduled posts
- Analytics dashboard
- Twitter/X API integration
- LinkedIn API integration
- Instagram API integration
- YouTube API integration
- OAuth flow for each platform
- Post templates
- Bulk post operations
- Recurring posts
- Post preview
- Content suggestions
- Analytics & insights
- A/B testing for posts
- Best time to post recommendations
- Content calendar
- Team collaboration
- Multi-account support per platform
- Docker & Docker Compose
- CI/CD pipeline
- Production deployment guide
- Monitoring & alerting
- Database migration to PostgreSQL
- Caching with Redis
- Email notifications
- Webhook support
- API rate limiting
- Subscription plans
- Usage analytics
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.