This is a production-ready backend API designed to power modern blogging platforms. Built with FastAPI, it’s high-performance, easy to scale, and comes packed with features like JWT authentication, nested commenting, and even an AI-driven recommendation engine.
- User Register & Login (JWT)
- Password hashing (bcrypt)
- Protected routes
- Create / Read / Update / Delete posts
- User-based authorization
- Add comments on posts
- Nested replies
- Delete own comments
- Like / Unlike posts
- Bookmark posts
- Search posts by title
- Filter by user
- Total posts count
- Upload blog images
- Recommend similar posts using TF-IDF + cosine similarity
- FastAPI
- PostgreSQL
- SQLAlchemy
- JWT Authentication
- Scikit-learn (AI feature)
cd blog-api
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtCreate .env file:
DATABASE_URL=postgresql://blog_user:1234@localhost/blog_db
SECRET_KEY=your_secret_key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
uvicorn app.main:app --reloadSwagger UI: http://127.0.0.1:8000/docs
app/
├── models/ # Database tables (SQLAlchemy)
├── schemas/ # Data validation (Pydantic)
├── routes/ # API Endpoints (Auth, Posts, Comments)
├── core/ # Security & Config settings
├── db/ # Database connection & session
- Redis caching
- Docker support
- AWS S3 file upload
- Advanced analytics dashboard