Skip to content

Jay-keshav/blog-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

🚀 Blog API (FastAPI)

A production-ready Backend Blog API built using FastAPI with JWT authentication, role-based access control, and full CRUD functionality.


📌 Features

  • 🔐 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)

🛠️ Tech Stack

  • Backend: FastAPI (Python)
  • Database: SQLite
  • ORM: SQLAlchemy
  • Authentication: JWT (JSON Web Token)
  • Validation: Pydantic
  • Server: Uvicorn

📂 Project Structure

blog-api/
│── blog/
│── requirements.txt
│── README.md
│── .gitignore

⚙️ Installation & Setup

1. Clone the repository

git clone https://github.com/Jay-keshav/blog-api.git
cd blog-api

2. Create virtual environment

python -m venv venv
venv\Scripts\activate   # Windows

3. Install dependencies

pip install -r requirements.txt

4. Run the server

uvicorn blog.main:app --reload

🌐 API Documentation

Once server is running, open:


🔑 API Endpoints

Authentication

  • POST /register → Register new user
  • POST /login → Login & get JWT token

Blog Posts

  • GET /posts → Get all posts
  • GET /posts/{id} → Get single post
  • POST /posts → Create post (Auth required)
  • PUT /posts/{id} → Update post (Auth required)
  • DELETE /posts/{id} → Delete post (Auth required)

🔒 Authentication Flow

  1. Register user
  2. Login to get JWT token
  3. Use token in headers:
Authorization: Bearer <your_token>

📸 API Preview

👉 Visit /docs for interactive API testing (Swagger UI)


🚀 Future Improvements

  • Dockerize the application
  • Deploy on AWS / Render
  • Add PostgreSQL support
  • Add caching (Redis)
  • CI/CD pipeline integration

👨‍💻 Author

Jay Keshav Backend Developer | DevOps Enthusiast


About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages