Skip to content

pranavroy22/Authentication-sys

Repository files navigation

FastAPI Authentication System

A production-oriented authentication backend built using FastAPI, PostgreSQL, SQLAlchemy, JWT Authentication, Docker, and Docker Compose.

Features

  • User Registration
  • User Login
  • JWT Authentication
  • Protected Routes
  • Password Hashing with bcrypt
  • PostgreSQL Database
  • SQLAlchemy ORM
  • Dockerized Backend
  • Docker Compose Setup
  • REST API Documentation with Swagger UI

Tech Stack

  • FastAPI
  • PostgreSQL
  • SQLAlchemy
  • Pydantic
  • JWT
  • Passlib (bcrypt)
  • Docker
  • Docker Compose
  • pgAdmin

Project Structure

auth-practice/
│
├── routers/
│   ├── auth.py
│   └── users.py
│
├── main.py
├── models.py
├── schemas.py
├── database.py
├── auth.py
├── Dockerfile
├── docker-compose.yml
├── requirements.txt
└── .env

API Endpoints

Authentication

Method Endpoint Description
POST /register Register a new user
POST /user-login Login and receive JWT token
GET /profile Verify token
GET /me Get current authenticated user

User Management

Method Endpoint Description
GET /get-users Get all users
GET /A-user/{id} Get user by ID
PUT /user/{id}/{new_name} Update username
DELETE /delete_user/{name} Delete user

Local Setup

Clone Repository

git clone <https://github.com/pranavroy22/Authentication-sys.git>
cd auth-practice

Create Virtual Environment

python -m venv auth-prac

Activate Environment

Windows:

auth-prac\Scripts\activate

Install Dependencies

pip install -r requirements.txt

Configure Environment Variables

Create a .env file:

SECRET_KEY=your-secret-key

DATABASE_URL=postgresql+psycopg2://postgres:postgres@postgres:5432/auth_db

Run with Docker Compose

docker compose up --build

Application:

http://localhost:8000

Swagger Documentation:

http://localhost:8000/docs

Learning Goals

This project is being continuously improved while learning backend engineering concepts including:

  • Alembic Migrations
  • Environment-based Configuration
  • Docker Networking
  • Docker Volumes
  • Deployment
  • CI/CD
  • Testing

Current Status

Completed:

  • FastAPI CRUD APIs
  • PostgreSQL Integration
  • JWT Authentication
  • Docker
  • Docker Compose

Upcoming:

  • Alembic Migrations
  • Production Deployment
  • Testing
  • CI/CD Pipeline

About

In this project i have learnt and implemented concepts like JWT , Sessions , FastAPI for creating a auth-app

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors