
- Added missing pydantic-settings to requirements.txt
- Fixed database path inconsistency between config.py and session.py
- Updated alembic.ini to use proper SQLite URL format
- Updated migrations/env.py to use config settings
🤖 Generated with BackendIM... (backend.im)
Co-Authored-By: Claude <noreply@anthropic.com>
User Authentication Flow Service
A FastAPI service that provides a complete user authentication flow with JWT tokens.
Features
- User registration with email and username
- User login with JWT token generation
- Password hashing with bcrypt
- Authentication middleware and dependencies
- User data retrieval
- Health check endpoint
- SQLite database with SQLAlchemy ORM
Project Structure
.
├── app/
│ ├── api/
│ │ ├── deps.py # Dependency injection
│ │ ├── endpoints/ # API endpoints
│ │ └── api.py # API router
│ ├── core/
│ │ ├── config.py # Application configuration
│ │ └── security.py # Security utilities
│ ├── db/
│ │ └── session.py # Database session
│ ├── models/
│ │ └── user.py # SQLAlchemy models
│ ├── schemas/
│ │ ├── auth.py # Auth-related schemas
│ │ ├── token.py # Token schemas
│ │ └── user.py # User schemas
│ └── services/
│ └── user.py # User service
├── migrations/ # Alembic migrations
├── storage/
│ └── db/ # SQLite database
├── alembic.ini # Alembic configuration
├── main.py # Application entry point
└── requirements.txt # Python dependencies
Getting Started
Prerequisites
- Python 3.8 or higher
Installation
- Clone the repository:
git clone <repository-url>
cd userauthenticationflowservice
- Install dependencies:
pip install -r requirements.txt
- Run database migrations:
alembic upgrade head
- Start the server:
uvicorn main:app --reload
The API will be available at http://localhost:8000.
API documentation is available at:
- Swagger UI: http://localhost:8000/docs
- ReDoc: http://localhost:8000/redoc
API Endpoints
Authentication
- POST /api/v1/auth/register - Register a new user
- POST /api/v1/auth/login - Login and get access token
- GET /api/v1/auth/me - Get current user information (requires authentication)
Health Check
- GET /health - Check application health status
Environment Variables
The application uses environment variables for configuration. These can be set in a .env
file:
SECRET_KEY
- Secret key for JWT token generationACCESS_TOKEN_EXPIRE_MINUTES
- Token expiration time in minutesDEBUG
- Debug mode (true/false)
License
This project is licensed under the MIT License.
Description
Languages
Python
97.5%
Mako
2.5%