piyush2630h-pixel /
dev-blog-api
A production-ready Blog REST API built with FastAPI, PostgreSQL, SQLAlchemy, JWT Authentication, Docker, and Alembic.
73/100 healthLoading repository data…
navneet-nitin / repository
A production-ready Blog REST API built with FastAPI & PostgreSQL — JWT auth, role-based access, pagination, likes, comments, and admin control. Deployed on Render.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
A production-ready RESTful backend API built with FastAPI and PostgreSQL — supporting user authentication, blog post management, comments, likes, and role-based admin control.
🔗 Live API: https://blog-api-9n0c.onrender.com/docs
| Layer | Technology |
|---|---|
| Framework | FastAPI |
| Database | PostgreSQL (Neon) |
| ORM | SQLAlchemy |
| Migrations | Alembic |
| Validation | Pydantic v2 |
| Authentication | JWT (PyJWT) |
| Password Hashing | pwdlib (Argon2) |
| Deployment | Render |
post.author, post.comments, user.posts)Blog-API/
├── main.py
├── requirements.txt
├── alembic.ini
├── migrations/
└── src/
├── user/
│ ├── model.py
│ ├── dtos.py
│ ├── controller.py
│ └── router.py
├── posts/
│ ├── model.py
│ ├── dtos.py
│ ├── controller.py
│ └── router.py
├── comments/
│ ├── model.py
│ ├── dtos.py
│ ├── controller.py
│ └── router.py
├── likes/
│ ├── model.py
│ ├── dtos.py
│ ├── controller.py
│ └── router.py
├── admin/
│ ├── controller.py
│ └── router.py
└── utils/
├── db.py
├── helper.py
└── settings.py
1. Clone the repository
git clone https://github.com/navneet-nitin/Blog-API.git
cd Blog-API
2. Create and activate virtual environment
python -m venv env
# Windows
env\Scripts\activate
# Mac/Linux
source env/bin/activate
3. Install dependencies
pip install -r requirements.txt
4. Create .env file in root directory
DB_CONNECTION=your_postgresql_connection_string
SECRET_KEY=your_secret_key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
5. Run database migrations
alembic upgrade head
6. Start the server
uvicorn main:app --reload
7. Open Swagger UI
http://localhost:8000/docs
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /user/register | ❌ | Register a new user |
| GET | /user/login | ❌ | Login and receive JWT token |
| GET | /user/profile | ✅ | View your profile |
| PUT | /user/update | ✅ | Update your details |
| DELETE | /user/delete | ✅ | Delete your account |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /post/create | ✅ | Create a new post (saved as draft) |
| PUT | /post/publish/{post_id} | ✅ | Publish a draft post |
| GET | /post/all | ✅ | Get all published posts (paginated) |
| GET | /post/get_post/{post_id} | ✅ | Get a single post by ID |
| GET | /post/get_my_posts | ✅ | Get all your posts including drafts |
| PUT | /post/update/{post_id} | ✅ | Update your post |
| DELETE | /post/delete/{post_id} | ✅ | Delete your post |
Pagination & Filtering:
GET /post/all?limit=10&offset=0
GET /post/all?category=tech
GET /post/all?username=navneet_nitin
GET /post/all?category=tech&username=navneet_nitin
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /comment/create/{post_id} | ✅ | Comment on a post |
| PUT | /comment/edit/{comment_id} | ✅ | Edit your comment |
| DELETE | /comment/delete/{comment_id} | ✅ | Delete your comment |
| GET | /comment/all/{post_id} | ✅ | Get all comments on a post |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| POST | /like/create/{post_id} | ✅ | Like a post (once only) |
| DELETE | /like/unlike/{post_id} | ✅ | Unlike a post |
| GET | /like/total/{post_id} | ✅ | Get total likes on a post |
| Method | Endpoint | Auth | Description |
|---|---|---|---|
| DELETE | /admin/delete_post/{post_id} | ✅ Admin | Delete any post |
| DELETE | /admin/delete_comment/{comment_id} | ✅ Admin | Delete any comment |
| GET | /admin/all_users | ✅ Admin | View all registered users |
All protected routes require a Bearer token in the request header:
Authorization: Bearer <your_jwt_token>
Get your token by calling /user/login with your credentials.
| Variable | Description |
|---|---|
DB_CONNECTION | PostgreSQL connection string |
SECRET_KEY | Secret key for JWT signing |
ALGORITHM | JWT algorithm (e.g. HS256) |
ACCESS_TOKEN_EXPIRE_MINUTES | Token expiry duration in minutes |
⚠️ Never commit your
.envfile to GitHub. It is already added to.gitignore.
This project is licensed under the MIT License.
Selected from shared topics, language and repository description—not editorial ratings.
piyush2630h-pixel /
A production-ready Blog REST API built with FastAPI, PostgreSQL, SQLAlchemy, JWT Authentication, Docker, and Alembic.
73/100 health