• Stars
    star
    128
  • Rank 271,961 (Top 6 %)
  • Language
    C++
  • License
    MIT License
  • Created almost 2 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

This is a modular app architecture that can be scalable as the time passes. I will be using the BLoC state-management package.

ย ย  ย ย  ย ย  ย ย 

Scalable App Architecture - CodeWithAndrea

This scalable app architecture design is inspired by Andrea Bizzotto. Full documentation of this design can be found here. In addition to that, you can use a VSCode extension called Flutter Feature Scaffolding for easily generating the features' folders. This design is using BLoC state-management solution, and for more information on BLoC library, I would strongly suggest you to follow their official documentation.

This project contains everything that you will need in order to immediately start developing your highly scaled application. You can also call this folder structure as Feature-first (layers inside features) design.

About the folder structure

    lib/
    โ”œโ”€โ”€ src/
    โ”‚   โ”œโ”€โ”€ common_widgets/
    โ”‚   โ”‚   โ””โ”€โ”€ common_button.dart
    โ”‚   โ”œโ”€โ”€ constants/
    โ”‚   โ”‚   โ””โ”€โ”€ colors.dart
    โ”‚   โ”œโ”€โ”€ exceptions/
    โ”‚   โ”‚   โ””โ”€โ”€ routing_exception.dart
    โ”‚   โ”œโ”€โ”€ features/
    โ”‚   โ”‚   โ”œโ”€โ”€ address/
    โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ data/
    โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ datasources/
    โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ address_datasources.dart
    โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ models/
    โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ address_model.dart
    โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ repositories/
    โ”‚   โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ address_repositories.dart
    โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ domain/
    โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ entities/
    โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ address_entities.dart
    โ”‚   โ”‚   โ”‚   โ”‚   โ”œโ”€โ”€ repositories/
    โ”‚   โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ address_repositories.dart
    โ”‚   โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ usecases/
    โ”‚   โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ address_usecases.dart
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ presentation/
    โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ bloc/
    โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ address_bloc.dart
    โ”‚   โ”‚   โ”‚       โ”‚   โ”œโ”€โ”€ address_event.dart
    โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ address_state.dart
    โ”‚   โ”‚   โ”‚       โ”œโ”€โ”€ pages/
    โ”‚   โ”‚   โ”‚       โ”‚   โ””โ”€โ”€ address_page.dart
    โ”‚   โ”‚   โ”‚       โ””โ”€โ”€ widgets/
    โ”‚   โ”‚   โ”‚           โ””โ”€โ”€ address_widgets.dart
    โ”‚   โ”‚   โ”œโ”€โ”€ authentication/
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ (...)
    โ”‚   โ”‚   โ”œโ”€โ”€ cart/
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ (...)
    โ”‚   โ”‚   โ”œโ”€โ”€ checkout/
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ (...)
    โ”‚   โ”‚   โ”œโ”€โ”€ orders/
    โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ (...)
    โ”‚   โ”‚   โ””โ”€โ”€ products/
    โ”‚   โ”‚       โ””โ”€โ”€ (...)
    โ”‚   โ”œโ”€โ”€ localization/
    โ”‚   โ”‚   โ”œโ”€โ”€ app_bn.arb
    โ”‚   โ”‚   โ”œโ”€โ”€ app_en.arb
    โ”‚   โ”‚   โ””โ”€โ”€ localization.dart
    โ”‚   โ”œโ”€โ”€ routing/
    โ”‚   โ”‚   โ””โ”€โ”€ routing.dart
    โ”‚   โ””โ”€โ”€ utils/
    โ”‚       โ””โ”€โ”€ utils.dart
    โ””โ”€โ”€ main.dart

You might notice that some files are just dummy (like api.dart, model.dart). They are placed there just for git to take the folder structure into consideration. Leaving those folders empty won't let git to take them into consideration. Since this is mostly a startup project, I was thinking of offering you the standard folder structure from the start. Of course, this may change multiple times, improving every time more and more.

Why this design pattern?

This architecture is made of four distinct layers, each containing the components that our app needs:

โžฎ presentation: widgets, states, and controllers
โžฎ application: services
โžฎ domain: models
โžฎ data: repositories, data sources,
        and DTOs (data transfer objects)

Of course, if we're building just a single-page app, we can put all files in one folder and call it a day. ๐Ÿ˜Ž

But as soon as we start adding more pages and have various data models to deal with, how can we organize all our files in a consistent way?

In practice, a feature-first or layer-first approach is often used.

Layer-first: Drawbacks

This approach is easy to use in practice, but doesn't scale very well as the app grows.

For any given feature, files that belong to different layers are far away from each other. And this makes it harder to work on individual features because we have to keep jumping to different parts of the project.

And if we decide that we want to delete a feature, it's far too easy to forget certain files, because they are all organized by layer.

For these reasons, the feature-first approach is often a better choice when building medium/large apps.

What about shared code?

Of course, when building real apps you'll find that your code doesn't always fit neatly into specific folders as you intended.

What if two or more separate features need to share some widgets or model classes?

In these cases, it's easy to end up with folders called shared or common, or utils.

But how should these folders themselves be organized? And how do you prevent them from becoming a dumping ground for all sorts of files?

If your app has 20 features and has some code that needs to be shared by only two of them, should it really belong to a top-level shared folder?

What if it's shared among 5 features? Or 10?

In this scenario, there is no right or wrong answer, and you have to use your best judgement on a case-by-case basis.

What is a feature?

Feature-first is not about the UI!

Feature is not about what the user sees, but what the user does:

โžฎ authenticate
โžฎ manage the shopping cart
โžฎ checkout
โžฎ view all past orders
โžฎ leave a review

In other words, a feature is a functional requirement that helps the user complete a given task.

And using some hints from domain-driven design, I decided to organize the project structure around the domain layer.

Once I figured that out, everything fell into place. And I ended up with seven functional areas that you can see on the right.

Note that with this approach is still possible for code inside a given feature to depend on code from a different feature. For example:

โžฎ the product page shows a list of reviews
โžฎ the orders page shows some product information
โžฎ the checkout flow requires the user to authenticate first

But we end up with far fewer files that are shared across all features, and the entire structure is much more balanced.

How to do feature-first, the right way?

In summary, the feature-first approach lets us structure our project around the functional requirements of our app.

So here's how to use this correctly in your own apps:

โ˜ž start from the domain layer and identify the model classes and business logic for manipulating them
โ˜ž create a folder for each model (or group of models) that belong together
โ˜ž within that folder, create the presentation, application, domain, data sub-folders as needed
โ˜ž inside each sub-folder, add all the files you need

More Repositories

1

widget_of_the_day

Introduction to flutter widgets: This repo will teach you some of the common widgets that are available in flutter SDK, & how to use them for UI design.
Dart
431
star
2

package_of_the_day

Introduction to flutter packages: This repo will teach you some of the popular packages that are available in pub.dev, & how to use them for UI design.
Dart
401
star
3

getx_clean_architecture

This repo is an example of clean architecture using the GetX state-management solution.
Dart
158
star
4

bloc_architecture_app

This is going to serve as a startup project for every app that I'll build on by using the BLoC state-management package
Dart
68
star
5

flutter_puzzle_hack

This game is for the "Flutter Puzzle Hack" contest, 2022. It is a simple slide puzzle game, where the player has to arrange the squares into sorted order.
Dart
59
star
6

kid_starter

This is an application for kids who want to learn the English alphabet, Numbers, and Colors names with accurate pronunciation.
Dart
39
star
7

sensor_packages

Introduction to sensor packages: This repo will teach you some of the popular sensor related packages that are available in pub.dev
Dart
22
star
8

bloc_concept

This repository is for understanding the core concepts of BLoC pattern in flutter.
Dart
15
star
9

zombieland

Instead of a simple counter app, the @FlutterDev team can provide a simple game like the one below. Thanks to the @rive_app team for their easy-to-use animation kit.
Dart
13
star
10

taja_khobor

It's a mobile application that will use the machine learning algorithm to personalize news according to individual tastes. In addition to that, it will provide comfort to your eyes by reading aloud newspaper in both Bangla & English.
Dart
8
star
11

flutter_multithreading

This repo is for understanding multithreading implementation in flutter ecosystem. Flutter, in its core, is a single-threaded SDK. But there is an option of multithreading for developers.
Dart
7
star
12

softcent_app

Your task is to create the app same as the UI given in the figma. For the images, use the mock API given below. Deadline: 4th April, 2022
Dart
7
star
13

Hackintosh_EliteBook_Folio_9470m

This is a tutorial for running macOS Mojave on Hp EliteBook Folio 9470m.
6
star
14

nilam

This is an auction application just like eBay. Using firebase as the backend for signup & sign-in functionality. In addition to that, it's a two pages application with user bid in input and count down view.
Dart
6
star
15

getx_tutorial

It's an introduction to one of the famous flutter package called "GetX": https://pub.dev/packages/get
Dart
6
star
16

tip_calculator

It's a UI challenge from "Frontend Mentor". This 'Tip Calculator' app can calculate the exact tip amount and the total amount shared per person in a group. It's two `Listener` widgets for calculating tip automatically in the background.
Dart
6
star
17

Real-Time-Water-Quality-Monitoring-and-Contamination-event-Detection-using-Machine-Learning

This was my final year project. It was a group project, with a total of three members. Here we implemented four sensors to detect the water quality of a storage tank. The user can see the real-time reading of the sensors using the Website & through the Android app.
JavaScript
6
star
18

Hackintosh-Legion-Y730_Y740

If you are a windows user and require macOS to learn XCode, then you can transform your windows machine into hackintosh machine. Remember, this tutorial is for educational purpose. I will be not responsible for any damage done to your device while installing macOS. Do at your own risk. This tutorial is only for Lenovo legion Y730/Y740. Back up your important files before starting. All files, that you require for macOS installation, are available in my GitHub page. So, letโ€™s beginโ€ฆ
5
star
19

md-siam

4
star
20

Hackintosh_EliteBook_840_G5

This is a tutorial for running macOS Big Sur on Hp EliteBook 840 G5
4
star
21

flutter_adaptive_widgets

Adaptive widgets are a great way to keep the UI uniform in both Android & iOS platforms. This repo contains few of the adaptive widgets. But there are more to implement like: date picker, time picker, bottom tab bar etc.
Dart
4
star
22

hive_crud

This repo will teach you how to use hive package for storing data locally in your device. Hive is a lightweight and blazing fast key-value database written in pure Dart.
Dart
3
star
23

react_conf

This is the repository for the assessment task for the Mid_Level Flutter Developer role at Lemon Hive.
Dart
3
star
24

riverpod_concept

This repository is for learning different types of State management widgets found in flutter_riverpod
Dart
3
star
25

dhaka_stocks_price

This app uses 'cheerio' npm package to web scrap the official site of Dhaka Stock Exchange. In addition, it is connected to ParseServer for storing the scripted values.
JavaScript
3
star
26

provider_tutorial

It's an introduction to one of the famous flutter package called "provider" :https://pub.dev/packages/provider/install
Dart
3
star
27

flutter_localization

Localization in flutter using the intl package: https://pub.dev/packages/intl
Dart
3
star
28

bn_calculator

Bengali Numeric, in short, BN Calculator is designed with a custom neumorphic button class, with a custom button press sound. In addition to that, it has a beautiful dark theme, and a user can turn On/Off the dark theme using a custom animated button on the AppBar.
Dart
3
star
29

flutter_fonts

This repo will teach you how to use custom fronts that are available on the internet.
Dart
2
star
30

flutter_tester

Introduction to flutter testing: This repo will teach you about testing in a flutter. It includes unit testing, widget testing & integration testing.
Dart
2
star
31

recipe_app

This is the repository for the assessment task for the Flutter Developer role at Battery Low Interactive Ltd.
Dart
2
star
32

flutter_responsive_ui_design

This is a must know for every Flutter developer! Since Flutter is a cross platform framework, dealing with different screen sizes smoothly is essential
Dart
2
star
33

flutter_widget_lifecycle

Introduction to how the Stateful Widget Lifecycle works in detail and how to react to changes of widgets in Flutter.
Dart
2
star
34

easybank_landing_page

It's an UI challenge from "Frontend Mentor". URL https://www.frontendmentor.io/challenges/easybank-landing-page-WaUhkoDN
Dart
2
star
35

Legion_Y730_running_BigSur

If you are a windows user and require macOS to learn XCode, then you can transform your windows machine into the Hackintosh machine. Remember, this tutorial is for educational purpose. I will be not responsible for any damage done to your device while installing macOS. Do at your own risk. This tutorial is only for Lenovo legion Y730/Y740. Back up your important files before starting.
2
star
36

sqflite_crud

It is a simple journal application that stores user input into the device's storage using the package sqflite package: https://pub.dev/packages/sqflite
Dart
2
star
37

Legion_Y730_running_Catalina

If you are a windows user and require macOS to learn XCode, then you can transform your windows machine into the Hackintosh machine. Remember, this tutorial is for educational purpose. I will be not responsible for any damage done to your laptop while installing macOS. Do at your own risk.
2
star
38

FlutterUI---Emojis

Dart
1
star
39

High-Quality-PDF

People need high quality (no compresses) PDF file for research paper submission. This tutorial will teach you to create high quality PDF files using Acrobat Pro DC.
1
star
40

node_express_api

Making an API using NodeJS
JavaScript
1
star
41

Clima-Flutter

Dart
1
star
42

quizzler-flutter

Dart
1
star
43

online_shoppe_getx_tutorial

Dart
1
star
44

COVID19_data_scraping

This will scrap covid19 data from https://www.worldometers.info/coronavirus/
JavaScript
1
star
45

flash-chat-flutter

Dart
1
star
46

isar_crud

Isar is for local database storage in a Flutter application. Isar is No-SQL relational database.
Dart
1
star
47

layout-demo-flutter

Super Useful Flutter Layouts - Right in Your Pocket. ๐Ÿ˜‰
Dart
1
star
48

new_ui_design_in_flutter

This repo will teach you the complex UI design using flutter. These designs are new and trending.
Dart
1
star
49

Prison-Management-System

It was a database management system, where we had to manage information of all the prisoners in a prison.
HTML
1
star
50

BullsEye_iOS

It is an iOS game using Swift 5, and SwiftUI framework
Swift
1
star
51

flutter_theme_shared_preferences

Storing theme data to local storage using Shared Preferences.
C++
1
star
52

bangladesh_map

It is an interactive map of Bangladesh. As you all know, Google Maps requires money to use, but my map is completely free of charge. You can use this map on your website to display information.
HTML
1
star
53

Mini-Drone-using-Arduino-mini-micro-controller-unit

A low cost drone using Arduino mini, DC motors, and a mobile battery. It can be controlled by an android application. The connection between the drone & the application is done by the Bluetooth module present in the Arduino mini
C++
1
star