A production-ready Backend Blog API built using FastAPI with JWT authentication, role-based access control, and full CRUD functionality.
- 🔐 JWT Authentication (Login/Register)
- 👤 Role-Based Access Control (Admin/User)
- 📝 CRUD Operations for Blog Posts
- ✅ Input Validation using Pydantic
- 🗄️ Database Integration using SQLAlchemy + SQLite
- ⚡ FastAPI auto-generated docs (Swagger UI)
- Backend: FastAPI (Python)
- Database: SQLite
- ORM: SQLAlchemy
- Authentication: JWT (JSON Web Token)
- Validation: Pydantic
- Server: Uvicorn
blog-api/
│── blog/
│── requirements.txt
│── README.md
│── .gitignore
git clone https://github.com/Jay-keshav/blog-api.git
cd blog-api
python -m venv venv
venv\Scripts\activate # Windows
pip install -r requirements.txt
uvicorn blog.main:app --reload
Once server is running, open:
- Swagger UI: http://127.0.0.1:8000/docs
- ReDoc: http://127.0.0.1:8000/redoc
POST /register→ Register new userPOST /login→ Login & get JWT token
GET /posts→ Get all postsGET /posts/{id}→ Get single postPOST /posts→ Create post (Auth required)PUT /posts/{id}→ Update post (Auth required)DELETE /posts/{id}→ Delete post (Auth required)
- Register user
- Login to get JWT token
- Use token in headers:
Authorization: Bearer <your_token>
👉 Visit /docs for interactive API testing (Swagger UI)
- Dockerize the application
- Deploy on AWS / Render
- Add PostgreSQL support
- Add caching (Redis)
- CI/CD pipeline integration
Jay Keshav Backend Developer | DevOps Enthusiast