https://github.com/persteenolsen/fastapi-jwt-auth-render-one
FastAPI with JWT Auth ready for be hosted at Render
https://github.com/persteenolsen/fastapi-jwt-auth-render-one
fastapi jwt postgresql python render
Last synced: 9 days ago
JSON representation
FastAPI with JWT Auth ready for be hosted at Render
- Host: GitHub
- URL: https://github.com/persteenolsen/fastapi-jwt-auth-render-one
- Owner: persteenolsen
- Created: 2026-05-13T18:21:04.000Z (about 1 month ago)
- Default Branch: main
- Last Pushed: 2026-05-28T16:00:58.000Z (29 days ago)
- Last Synced: 2026-05-28T18:04:09.502Z (29 days ago)
- Topics: fastapi, jwt, postgresql, python, render
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 🚀 FastAPI + Render + Neon PostgreSQL + JWT Authentication (Alembic Ready)
Last updated
- 03-06-2026
# Version
At Render I use the PYTHON_VERSION environment variable to tell Render to use Python version 3.11. Locally I am using Python 3.12
A production-ready backend built with FastAPI, PostgreSQL (Neon), JWT authentication, bcrypt password hashing, and Alembic migrations hosted at Render
---
## 🧱 Tech Stack
- FastAPI
- Hosted at Render
- PostgreSQL (Neon)
- SQLAlchemy ORM
- Alembic (migrations)
- JWT Authentication (python-jose)
- bcrypt
- Uvicorn
---
## ✨ Features
- User registration
- Secure password hashing (bcrypt)
- JWT login system
- Protected routes
- PostgreSQL cloud database (Neon)
- Alembic migrations
- Swagger UI testing
---
## 📦 Setup & Installation
### Clone repository
git clone https://github.com/your-username/your-repo.git
cd your-repo
### Create virtual environment
python -m venv .venv
### Activate virtual environment
Windows:
.venv\Scripts\activate
Mac/Linux:
source .venv/bin/activate
### Install dependencies
pip install -r requirements.txt
---
## ⚙️ Environment Variables
Create a `.env` file:
DATABASE_URL=postgresql://USER:PASSWORD@ep-xxx.neon.tech/neondb?sslmode=require&channel_binding=require
SECRET_KEY=your-secret-key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
---
## 🗄️ Database (Alembic)
Initialize Alembic:
alembic init alembic
Create migration:
alembic revision --autogenerate -m "create users table"
Apply migration:
alembic upgrade head
---
## 🚀 Run the server
uvicorn app:app --reload
---
## 🌐 API Endpoints
Register user:
POST /register
{
"email": "user@example.com",
"password": "12345678"
}
---
Login:
POST /token
username = email
password = password
---
Protected route:
GET /protected
Authorization: Bearer YOUR_TOKEN
---
## 📚 Swagger UI
http://127.0.0.1:8000/docs
---
## 🧠 Architecture
FastAPI → SQLAlchemy → PostgreSQL (Neon)
→ Alembic migrations
→ bcrypt + JWT authentication
---
## 🔐 Security
- bcrypt password hashing
- JWT authentication
- Environment variables
- No hardcoded secrets
---
## ☁️ Deployment Notes
Run before deploy:
alembic upgrade head
Set env vars in Render / production.
---
## 📌 Important
- Do NOT use create_all()
- Always use Alembic migrations
- Neon requires SSL in DATABASE_URL
---
## 📜 License
MIT