A comprehensive RESTful API blog application built with FastAPI and MySQL, featuring user authentication, blog post management, and secure data handling.
- 🔐 JWT Authentication
- 📝 Blog Post CRUD Operations
- 🗄️ MySQL Database Integration
- 🚀 FastAPI Framework
- 🔄 RESTful API Architecture
- 🛡️ Secure Password Hashing
- FastAPI: Modern Python web framework for building APIs
- MySQL: Relational database for persistent storage
- SQLAlchemy: SQL toolkit and ORM
- Alembic: Database migration tool
- PyJWT: JSON Web Token implementation
- Python 3.8+: Core programming language
- Clone the repository:
git clone https://github.com/AKA2114SH/fastapi-blogapplication-mysql.git
cd fastapi-blogapplication-mysql
- Create a virtual environment:
python -m venv .vscode
source .vscode/bin/activate # On Windows: .vscode\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
-
Configure your MySQL database in
database.py
-
Run database migrations:
alembic upgrade head
- Start the application:
uvicorn main:app --reload
- POST
/auth/register
: Register new user - POST
/auth/login
: Login user
- GET
/posts
: Get all blog posts - GET
/posts/{id}
: Get specific blog post - POST
/posts
: Create new blog post - PUT
/posts/{id}
: Update blog post - DELETE
/posts/{id}
: Delete blog post
fastapi-blogapplication-mysql/
├── alembic/ # Database migrations
├── blog/ # Blog related modules
├── .vscode/ # Virtual environment
├── main.py # Application entry point
├── database.py # Database configuration
├── requirements.txt # Project dependencies
└── README.md # Project documentation
The project uses Alembic for database migrations and SQLAlchemy as the ORM. The authentication system is implemented using JWT tokens for secure user sessions.
Update the database connection string in database.py
:
SQLALCHEMY_DATABASE_URL = "mysql+mysqlconnector://user:password@localhost/dbname"
To run the test suite:
pytest
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- FastAPI documentation
- SQLAlchemy documentation
- Python community
Your Name - @AKA2114SH
Project Link: https://github.com/AKA2114SH/fastapi-blogapplication-mysql