yahrdev /
fastapi_custom_auth_project
This project is a backend application built with FastAPI and MySQL. Here custom user authorization using JWT, OAuth2 etc was implemented.
Loading repository data…
nohan-ahmed / repository
This project was built entirely for practice to recall and reinforce my FastAPI knowledge while improving my overall backend development skills
A modern, secure Todo application built with FastAPI, featuring JWT authentication, user management, and address management.
fastapi-todo-app/
├── api/ # API route handlers
│ ├── auth_routes.py # Authentication endpoints
│ └── todo_routes.py # Todo CRUD endpoints
├── app/
│ └── config.py # Database and app configuration
├── models/ # SQLAlchemy models
│ ├── user.py # User and Address models
│ └── todo.py # Todo model
├── schemas/ # Pydantic schemas
│ ├── user_schema.py # User validation schemas
│ ├── address_schema.py # Address validation schemas
│ └── todo_schema.py # Todo validation schemas
├── utils/ # Utility functions
│ ├── jwt_utils.py # JWT token handling
│ └── password_hashing_utils.py # Password utilities
├── alembic/ # Database migrations
├── main.py # FastAPI application entry point
└── pyproject.toml # Project dependencies
Clone the repository
git clone <repository-url>
cd fastapi-todo-app
Install dependencies
# Using uv (recommended)
uv sync
# Or using pip
pip install -r requirements.txt
Set up environment variables
cp .example.env .env
Edit .env with your configuration:
# Database
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=localhost
DB_PORT=5432
DB_NAME=todo_app
# JWT
SECRET_KEY=your-secret-key-here
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=30
Set up PostgreSQL database
# Create database
createdb todo_app
Run database migrations
alembic upgrade head
Start the server
uvicorn main:app --reload
The API will be available at http://localhost:8000
Once the server is running, you can access:
/api/v1/auth)| Method | Endpoint | Description |
|---|---|---|
| POST | /signup | Register a new user |
| POST | /login | Login and get JWT token |
| GET | /users/me/ | Get current user profile |
| POST | /password-change | Change user password |
/api/v1/auth)| Method | Endpoint | Description |
|---|---|---|
| POST | /address | Create new address |
| GET | /address | Get user's addresses |
| PUT | /address/{address_id} | Update address |
| DELETE | /address/{address_id} | Delete address |
/api/v1/todo)| Method | Endpoint | Description |
|---|---|---|
| POST | / | Create new todo |
| GET | / | Get user's todos |
| GET | /todo_id={todo_id} | Get specific todo |
| PUT | /todo_id={todo_id} | Update todo |
| DELETE | /todo_id={todo_id} | Delete todo |
curl -X POST "http://localhost:8000/api/v1/auth/signup" \
-H "Content-Type: application/json" \
-d '{
"username": "johndoe",
"email": "john@example.com",
"password": "securepassword",
"first_name": "John",
"last_name": "Doe"
}'
curl -X POST "http://localhost:8000/api/v1/auth/login" \
-H "Content-Type: application/json" \
-d '{
"username": "johndoe",
"password": "securepassword"
}'
curl -X POST "http://localhost:8000/api/v1/todo/" \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"title": "Learn FastAPI",
"description": "Complete the FastAPI tutorial",
"completed": false
}'
# Add your test commands here
pytest
# Create a new migration
alembic revision --autogenerate -m "Description of changes"
# Apply migrations
alembic upgrade head
# Rollback migration
alembic downgrade -1
# Format code with black
black .
# Sort imports
isort .
git checkout -b feature/amazing-feature)git commit -m 'Add some amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
If you have any questions or issues, please open an issue on GitHub.
Selected from shared topics, language and repository description—not editorial ratings.
yahrdev /
This project is a backend application built with FastAPI and MySQL. Here custom user authorization using JWT, OAuth2 etc was implemented.