
- Removed unused imports in deps.py, routes/auth.py, and models/user.py - Code is now lint-free and follows best practices - Complete FastAPI user authentication service with JWT token support generated with BackendIM... (backend.im)
User Authentication Service
A FastAPI-based user authentication service with JWT authentication.
Features
- User registration and login
- JWT authentication
- User profile management
- SQLite database with SQLAlchemy ORM
- Alembic migrations
- Health check endpoint
Requirements
- Python 3.8+
- FastAPI
- SQLAlchemy
- Alembic
- Pydantic
- Python-jose (JWT)
- Passlib (Password hashing)
Project Structure
.
├── alembic/ # Database migrations
├── app/ # Application code
│ ├── api/ # API endpoints
│ │ ├── deps.py # Dependencies
│ │ └── routes/ # API route handlers
│ ├── core/ # Core functionality
│ │ ├── config.py # Configuration settings
│ │ └── security.py # Security utilities
│ ├── db/ # Database
│ │ ├── crud.py # CRUD operations
│ │ └── session.py # DB session
│ ├── models/ # SQLAlchemy models
│ └── schemas/ # Pydantic schemas
├── alembic.ini # Alembic configuration
├── main.py # FastAPI application
└── requirements.txt # Dependencies
Setup
- Clone the repository
- Install dependencies:
pip install -r requirements.txt
- Run the migrations:
alembic upgrade head
- Start the application:
uvicorn main:app --reload
API Endpoints
Authentication
POST /api/v1/auth/register
- Register a new userPOST /api/v1/auth/login
- Login and get JWT tokenGET /api/v1/auth/me
- Get current user info (requires authentication)
Health Check
GET /health
- Check service health
API Documentation
- Swagger UI:
/docs
- ReDoc:
/redoc
Development
To run the application in development mode:
uvicorn main:app --reload
This application was bootstrapped by BackendIM, the AI-powered backend generation platform.
Description
Languages
Python
96.7%
Mako
3.3%