Skip to content

Repository files navigation

FastAPI Login System 🔐

A production-style authentication and authorization backend built using FastAPI, featuring secure user authentication, JWT-based access control, and database-backed user management.

This project demonstrates how modern backend systems handle authentication, security, and role-based access using industry-standard practices.


🚀 Features

  • User registration and login
  • Secure password hashing
  • JWT-based authentication (access tokens)
  • Role-based access control (RBAC)
  • Protected routes using dependency injection
  • PostgreSQL database integration
  • SQLAlchemy ORM for data modeling
  • Environment-based configuration
  • Automatic API documentation (Swagger / OpenAPI)

🧠 Tech Stack

  • Backend Framework: FastAPI
  • Language: Python
  • Database: PostgreSQL
  • ORM: SQLAlchemy
  • Auth: JWT (JSON Web Tokens)
  • Security: Password hashing with passlib
  • API Docs: Swagger UI (built-in FastAPI)

📁 Project Structure

login-fastapi/
├── app/
│   ├── main.py
│   ├── database.py
│   ├── models.py
│   ├── schemas.py
│   ├── auth.py
│   ├── dependencies.py
│   └── routes/
│       ├── auth.py
│       └── users.py
├── .env
├── requirements.txt
└── README.md

🔐 Authentication Flow

  1. User registers with email and password
  2. Password is securely hashed before storage
  3. User logs in with valid credentials
  4. Server issues a signed JWT access token
  5. Client sends token in Authorization header
  6. Protected routes validate token and user role

🛠️ Setup & Installation

Clone the repository

git clone https://github.com/404zhan/login-fastapi.git
cd login-fastapi

Create virtual environment

python -m venv venv
source venv/bin/activate

Install dependencies

pip install -r requirements.txt

Environment variables

DATABASE_URL=postgresql://username:password@localhost:5432/dbname
SECRET_KEY=your_secret_key
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30

Run the server

uvicorn app.main:app --reload

📖 API Documentation


👤 Author

Azhan Farooqui
GitHub: https://github.com/404zhan

About

just a basic tkinter based loginpage GUI with backend using FASTAPI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages