A simple frontend-backend project that exposes a FastAPI REST API back-end and a Flutter frontend to showcase API integration, Pydantic Schemas, Alembic Migrations and SQLAlchemy ORM models.
FastAPI-Flutter-Final.mp4
First, see it in action:
- Open a terminal and start the backend.
uvicorn app.main:app --reload --host 127.0.0.1 --port 8000
- In Postman, set the base_url to
localhost:8000
, the headers toContent-Type
:application/json
and send a POST /new with the body (below) to create a new fruit.

{
"name": "Strawberry",
"seedless": true
}
- Run the Flutter app on an emulator or device.
- Switch to the List tab to fetch and view fruits.
- Provide a reliable HTTP API for managing fruit records and a simple cross-platform UI for users to view and add fruits.
- FastAPI REST endpoints
- SQLAlchemy ORM models
- Alembic migration scripts
- Pydantic schemas for input/output validation
- Flutter UI with bottom navigation
- Dart model mapping TINYINT seedless flag to bool
- HTTP integration tested via Postman
- Clone
git clone https://github.com/ex-rnd/FastAPI-Flutter-API-Integration-Using-Alembic-MySQL.git
cd fastapi-flutter-integration
- Backend setup
- Create a Python virtual environment.
python3 -m venv venv
source venv/bin/activate # macOS/Linux
venv\Scripts\activate # Windows
pip install -r requirements.txt
- Install requirements.
pip install -r requirements.txt
- Create a .env with your MySQL URL.
DATABASE_URL=mysql+pymysql://user:pass@host:3306/dbname
- Run alembic migrations.
alembic upgrade head
- Frontend setup
- Navigate to the flutter folder.
cd frontend
- Fetch Dart packages.
flutter pub get
- Update lib/config.dart with your API base URL.

-
Open Postman.
-
Use the Environment to set
base_url
tohttp://127.0.0.1:8000
. -
Run requests and inspect responses.
-
Use
GET, POST, PUT
. -
Automate tests by creating assertions on status codes and JSON schemas
- Ensure your emulator or device is connected
- From project root:
cd frontend
flutter run

Flutter App ← HTTP (http package) → FastAPI
↑ │
│ ↓
ListView / Form SQLAlchemy ORM → MySQL
Alembic Migrations
[Flutter UI] → http.get/post → [FastAPI App]
↓ ↓
ListView / Form Pydantic validation
↓
SQLAlchemy models
↓
MySQL database
(migrations via Alembic)
- Fork the repo
- Branch naming: feature/xyz or fix/xyz
- Run linters:
Backend: flake8, black
Frontend: flutter format
- Add tests:
Backend unit tests with: pytest
Frontend widget tests with: flutter test
- Submit PRs with clear descriptions and link related issues