h1 style="color:#2c3e50;">🚀 FastAPI Auth App
A lightweight FastAPI project with JWT-based authentication and MongoDB Cloud.
- JWT login/register
- Protected user routes
- MongoDB Cloud integration
- CRUD operations
- Password hashing with
passlib
To run the project locally:
pip install -r requirements.txt
uvicorn app.main:app --reload
app/main.py
– FastAPI app instance and routesapp/api/routes_auth.py
– user registration and login operationsapp/db/models.py
– Pydantic modelsapp/core/auth.py
– JWT utilities and authentication logicapp/core/config.py
– project name and secret keysapp/db/database.py
– MongoDB Cloud connectionapp/api/routes_user.py
– token login and CRUD operations on usersapp/schemas/schemas.py
– login token models
Users receive a JWT token upon login. Send it in the Authorization
header as a Bearer token for protected routes.
Set up a MongoDB Atlas cluster and add your connection string in app/database.py
.
MONGO_URL="your_mongodb_connection_string"
JWT_SECRET_KEY="your_secret_key"
ALGORITHM="HS256"
ACCESS_TOKEN_EXPIRE_MINUTES=30
fastapi
uvicorn
pymongo
python-jose
passlib[bcrypt]
python-dotenv