Skip to content

Latest commit

 

History

History
58 lines (49 loc) · 2.13 KB

File metadata and controls

58 lines (49 loc) · 2.13 KB

h1 style="color:#2c3e50;">🚀 FastAPI Auth App

A lightweight FastAPI project with JWT-based authentication and MongoDB Cloud.

📌 Features

  • JWT login/register
  • Protected user routes
  • MongoDB Cloud integration
  • CRUD operations
  • Password hashing with passlib

🚀 Getting Started

To run the project locally:

pip install -r requirements.txt
uvicorn app.main:app --reload

📁 Project Structure

  • app/main.py – FastAPI app instance and routes
  • app/api/routes_auth.py – user registration and login operations
  • app/db/models.py – Pydantic models
  • app/core/auth.py – JWT utilities and authentication logic
  • app/core/config.py – project name and secret keys
  • app/db/database.py – MongoDB Cloud connection
  • app/api/routes_user.py – token login and CRUD operations on users
  • app/schemas/schemas.py – login token models

🔐 Authentication

Users receive a JWT token upon login. Send it in the Authorization header as a Bearer token for protected routes.

🌐 MongoDB Cloud

Set up a MongoDB Atlas cluster and add your connection string in app/database.py.

✅ Example .env File

MONGO_URL="your_mongodb_connection_string"
JWT_SECRET_KEY="your_secret_key"
ALGORITHM="HS256"
ACCESS_TOKEN_EXPIRE_MINUTES=30

🛠️ Requirements

fastapi
uvicorn
pymongo
python-jose
passlib[bcrypt]
python-dotenv