A modern, high-performance blog API built with Django Ninja, featuring user authentication, posts, comments, and real-time interactions.
This project is part of the book "Django Ninja In Action" - a comprehensive guide to building modern APIs with Django Ninja.
- User registration with email verification
- JWT-based authentication (access & refresh tokens)
- Google OAuth integration
- Password reset with OTP verification
- Profile management with avatar upload
- Multi-device logout support
- Create, read, update, delete posts
- Image upload for posts
- Auto-generated slugs for SEO-friendly URLs
- Post filtering and pagination
- Hierarchical comments (replies to comments)
- Like/dislike system for posts and comments
- Real-time engagement tracking
- Pagination for comments and replies
- Django Ninja for fast, modern API development
- Async/await support for better performance
- PostgreSQL database with optimized queries
- Cloudinary integration for media storage
- Docker containerization
- Comprehensive test suite with pytest
- Python 3.12+
- PostgreSQL
- Docker (optional)
-
Clone the repository
git clone https://github.com/kayprogrammer/quickpost.git cd quickpost -
Install dependencies
pip install -r requirements.txt # OR using make make req -
Environment Setup Create a
.envfile with the necessary values as stated in .env.example:DJANGO_SETTINGS_MODULE=quickpost.settings.dev ...
-
Database Setup
python manage.py migrate # OR using make make mig python manage.py createsuperuser # OR using make make suser
-
Run the development server
python manage.py runserver # OR using uvicorn with make make run
docker-compose up -d
# OR using make
make up
# Build and run (first time)
docker-compose up --build -d
# OR using make
make buildThis project includes convenient Make commands for common tasks:
make req # Install requirements
make mig # Run migrations
make mmig # Make migrations (add app='app_name' for specific app)
make suser # Create superuser
make run # Run development server with uvicorn
make shell # Django shell
make test # Run tests
make up # Start Docker containers
make build # Build and start Docker containers
make down # Stop Docker containers
make show-logs # Show Docker logsOnce running, visit:
- Interactive API Docs:
http://localhost:8000/ - Admin Interface:
http://localhost:8000/admin/
quickpost/
├── apps/
│ ├── accounts/ # User authentication & profiles
│ ├── blog/ # Posts, comments, likes
│ ├── common/ # Shared utilities & base models
│ └── api.py # Main API router configuration
├── quickpost/
│ ├── settings/ # Environment-specific settings
│ └── urls.py # URL configuration
├── templates/ # Email templates
├── static/ # Static files
└── docker-compose.yml # Docker configuration
Run the test suite:
pytest
# OR using make
make testRun with coverage:
pytest --cov=appsPOST /api/v1/auth/register- User registrationPOST /api/v1/auth/login- User loginPOST /api/v1/auth/google-login- Google OAuthPOST /api/v1/auth/refresh- Refresh tokensGET /api/v1/auth/logout- Logout current deviceGET /api/v1/auth/logout-all- Logout all devices
GET /api/v1/profiles- Get user profilePUT /api/v1/profiles- Update profile
GET /api/v1/blog/posts- List posts (with pagination & filters)POST /api/v1/blog/posts- Create postGET /api/v1/blog/posts/{slug}- Get single postPUT /api/v1/blog/posts/{slug}- Update postDELETE /api/v1/blog/posts/{slug}- Delete post
GET /api/v1/blog/posts/{slug}/comments- Get commentsPOST /api/v1/blog/posts/{slug}/comments- Create commentGET /api/v1/blog/comments/{id}/replies- Get repliesPOST /api/v1/blog/comments/{id}/replies- Create reply
GET /api/v1/blog/likes/{obj_id}/toggle- Toggle like/dislike
- Backend: Django 5.2, Django Ninja 1.4
- Database: PostgreSQL with async support
- Authentication: JWT tokens, Google OAuth
- Media Storage: Cloudinary
- Email: SMTP with HTML templates
- Testing: pytest, pytest-django
- Containerization: Docker & Docker Compose
- Code Quality: Black formatting, Type hints
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is open source and available under the MIT License.
This project demonstrates the concepts covered in "Django Ninja In Action". The book provides detailed explanations of:
- Building high-performance APIs with Django Ninja
- Implementing async/await patterns in Django
- JWT authentication strategies
- API design best practices
- Testing modern Django applications
- Production deployment techniques
If you have questions about this project or the book, feel free to:
- Open an issue in this repository
- Contact the author through the book's website
Happy coding! 🚀