A simple side project focused on utilizing Python FastAPI resources and navigating the world of user registration systems. This project explores what happens behind the scenes when interacting with styled web pages, providing a practical implementation of user registration, authentication, and email verification.
Feel free to use it, play around with it, and update whatever doesn't suit your needs.
- User registration with email verification
- JWT-based authentication (access tokens and refresh tokens)
- User profile management
- Secure password handling
- Email confirmation system
- Token-based session management
- Account deletion functionality
- Python 3.10+
- MySQL database
- FastAPI (with standard dependencies)
- curl
- postman
git clone https://github.com/debil746429/UserRegAPI.git
cd UserRegAPIOn Linux/macOS:
python3 -m venv .venv
source .venv/bin/activateOn Windows:
python -m venv .venv
.venv\Scripts\activatepip install -r requirements.txt-
Create a MySQL database (make sure you don't have a database named
chatif you're using the default configuration) -
Update the
.envfile with your configuration:
# Database Configuration
db_host = localhost
db_name = chat
db_user = your_database_user
db_password = your_database_password
# JWT Configuration
JWT_SECRET = your_secret_key_here
JWT_ALGORITHM = HS256
JWT_ACCESS_TOKEN_EXPIRE_MINUTES = 100 # in minutes
REFRESH_TOKEN_EXPIRY_DAYS = 3000 # in days
# Email Configuration (for email verification)
sender_email = your_email@gmail.com
email_password = your_app_password- Import the database schema:
mysql -u your_db_user -p your_database_name < schema.sqlOr manually execute the SQL commands from schema.sql in your MySQL client.
Start the development server:
fastapi dev app/main.pyThe API will be available at http://127.0.0.1:8000
Once the server is running, you can view the interactive API documentation at:
- ReDoc: http://127.0.0.1:8000/redoc
- Swagger UI: http://127.0.0.1:8000/docs
GET /api/v1/- Test endpointPOST /api/v1/register- Register a new userGET /api/v1/auth/verify_email/{token}- Verify email and complete registrationPOST /api/v1/login- User login
PATCH /api/v1/update-profile- Update user profileDELETE /api/v1/delete-account- Delete user accountPOST /api/v1/logout- Logout user
You can test the endpoints using:
- cURL - Command-line tool for making HTTP requests
- Postman - API testing and development platform
- Swagger UI - Interactive documentation at
/docsendpoint
UserRegAPI/
├── app/
│ ├── api/
│ │ ├── routes/
│ │ │ └── user.py # User-related endpoints
│ │ └── main.py # API router configuration
│ ├── core/
│ │ ├── config.py # Application configuration
│ │ ├── db.py # Database connection
│ │ ├── emailConf.py # Email configuration
│ │ └── security.py # Security utilities (JWT, etc.)
│ ├── model/
│ │ └── models.py # Pydantic models
│ ├── services/
│ │ └── user.py # User business logic
│ └── main.py # FastAPI application entry point
├── .env # Environment variables
├── requirements.txt # Python dependencies
├── schema.sql # Database schema
├── LICENSE.md # License information
└── README.md # This file
See LICENSE.md for details.
Feel free to fork this project, make changes, and submit pull requests. This is a learning project, so contributions and improvements are welcome!