# 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 1. Clone the repository: ```bash git clone cd userauthenticationflowservice ``` 2. Install dependencies: ```bash pip install -r requirements.txt ``` 3. Run database migrations: ```bash alembic upgrade head ``` 4. Start the server: ```bash 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 generation - `ACCESS_TOKEN_EXPIRE_MINUTES` - Token expiration time in minutes - `DEBUG` - Debug mode (true/false) ## License This project is licensed under the MIT License.