|
| 1 | +# FastAPI MVC starter for Backend |
| 2 | + |
| 3 | +## Table of Contents |
| 4 | + |
| 5 | +- [Description](#description) |
| 6 | +- [Features](#features) |
| 7 | +- [Dependencies](#dependencies-used) |
| 8 | +- [Installation](#installation) |
| 9 | + |
| 10 | +## Description |
| 11 | + |
| 12 | +The FastAPI MVC Starter Template is an open-source project providing a starting point for building backend applications using the Model-View-Controller (MVC) architectural pattern with the FastAPI framework. This template is specifically designed to help backend developers create structured, scalable, and maintainable applications. It’s ideal for those looking to kickstart FastAPI development efficiently, without needing to set everything up from scratch. |
| 13 | + |
| 14 | +### Objective |
| 15 | +The project aims to provide a solid, reusable foundation for building backend applications with FastAPI. It reduces the initial setup and offers clear examples of implementing the MVC pattern in FastAPI, allowing developers to focus on business logic rather than repetitive technical setup. |
| 16 | + |
| 17 | +### Features: |
| 18 | + |
| 19 | +1. **MVC-Based Project Structure** |
| 20 | +<br>Separates application logic into Model, View (API endpoints), and Controller layers to enhance code readability, modularity, and maintainability. |
| 21 | + |
| 22 | + |
| 23 | +2. **ORM (Object-Relational Mapping) Support** |
| 24 | +<br>Includes built-in support for SQLAlchemy, integrated with MySQL database using PyMySQL as default. |
| 25 | + |
| 26 | + |
| 27 | +3. **Authentication and Authorization** |
| 28 | +<br>Pre-configured JWT (JSON Web Token) authentication for securing APIs, including user login, registration, and access management. |
| 29 | + |
| 30 | + |
| 31 | +4. **Middleware Support** |
| 32 | +<br>Comes with middleware for logging, CORS (Cross-Origin Resource Sharing) configuration, and request tracking to simplify debugging and development. |
| 33 | + |
| 34 | + |
| 35 | +5. **Migrations Database** |
| 36 | +<br>Supports database migration schema using alembic, this allows developers to more easily make changes to database structures and perform migrations. This feature can also synchronize the sqlalchemy ORM model. |
| 37 | + |
| 38 | + |
| 39 | +6. **Easy Configuration** |
| 40 | +<br>Utilizes dotenv for environment variable management, simplifying the configuration and deployment of the application across different environments. |
| 41 | + |
| 42 | + |
| 43 | +## Dependencies Used |
| 44 | + |
| 45 | +- **FastAPI**: A modern, fast (high-performance), web framework for building APIs with Python 3.7+. |
| 46 | +- **Uvicorn**: A ASGI web server implementation for Python, asynchronous support, support HTTP/1.1 and WebSockets. |
| 47 | +- **Alembic**: A lightweight database migration tool for usage with the SQLAlchemy Database Toolkit for Python. |
| 48 | +- **SQLAlchemy**: A Python SQL toolkit and Object Relational Mapper that gives application developers the full power and flexibility of SQL. |
| 49 | +- **PyJWT**: A Python library which allows you to encode and decode JSON Web Tokens (JWT). |
| 50 | + |
| 51 | +## Installation |
| 52 | + |
| 53 | +1. Clone Repository using git |
| 54 | +```bash |
| 55 | +git clone https://github.com/Jrhero14/FastApi-BackendMVC |
| 56 | +cd FastApi-BackendMVC |
| 57 | +``` |
| 58 | + |
| 59 | +2. Copy .env file and update it with your database credentials |
| 60 | +```bash |
| 61 | +cp .env.example .env |
| 62 | +``` |
| 63 | + |
| 64 | +3. Install Dependencies |
| 65 | +```bash |
| 66 | +pip install -r requirements.txt |
| 67 | +``` |
| 68 | + |
| 69 | +4. Migrate database |
| 70 | +```bash |
| 71 | +alembic upgrade head |
| 72 | +``` |
| 73 | + |
| 74 | +5. Run the Application |
| 75 | +```bash |
| 76 | +uvicorn app.main:app --reload |
| 77 | +``` |
| 78 | + |
| 79 | +## Tables of Database |
| 80 | + |
| 81 | +<img width="35%" src="https://i.ibb.co.com/FnZbtBd/Screenshot-2024-10-12-222819.png"> |
| 82 | + |
| 83 | +### Contributions |
| 84 | +Developers are welcome to contribute to this project by opening issues, submitting pull requests, or suggesting improvements. All forms of contributions are greatly appreciated. |
0 commit comments