Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Dat-TG committed Dec 29, 2023
1 parent 877aa9e commit 7ae6735
Showing 1 changed file with 32 additions and 277 deletions.
309 changes: 32 additions & 277 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,299 +1,54 @@
# This branch is still under development
# AI Chat.

This is an assignment of Advanced Mobile Programming module at FIT-HCMUS

# Boilerplate Project
20120454 - Lê Công Đắt

A boilerplate project created in flutter using MobX and Provider. Boilerplate supports both web and mobile, clone the appropriate branches mentioned below:
# Tech Stack

* For Mobile: https://github.com/zubairehman/flutter-boilerplate-project/tree/master (stable channel)
* For Web: https://github.com/zubairehman/flutter-boilerplate-project/tree/feature/web-support (beta channel)
Flutter, [Flutter Boilerplate](https://github.com/zubairehman/flutter_boilerplate_project)

## Getting Started
# Video Demo

The Boilerplate contains the minimal implementation required to create a new library or project. The repository code is preloaded with some basic components like basic app architecture, app theme, constants and required dependencies to create a new project. By using boiler plate code as standard initializer, we can have same patterns in all the projects that will inherit it. This will also help in reducing setup & development time by allowing you to use same code pattern and avoid re-writing from scratch.
Youtube: https://youtu.be/VP1b0xhNbR8

## How to Use
# Features
- AI chat (maintain context for the AI chat to understand the content of previous chats).
- Store chat threads and provide the option to select older chat threads on the sidebar for continued chatting.
- Rename a chat thread
- Delete a chat thread
- Typing Indicator
- Typing Text Animation
- View send time of each message

**Step 1:**
## Installation

Download or clone this repo by using the link below:
```
```
https://github.com/zubairehman/flutter-boilerplate-project.git
```

**Step 2:**

Go to project root and execute the following command in console to get the required dependencies:

```
flutter pub get
```

**Step 3:**

This project uses `inject` library that works with code generation, execute the following command to generate files:

```
flutter packages pub run build_runner build --delete-conflicting-outputs
```

or watch command in order to keep the source code synced automatically:

```
flutter packages pub run build_runner watch
```

## Hide Generated Files

In-order to hide generated files, navigate to `Android Studio` -> `Preferences` -> `Editor` -> `File Types` and paste the below lines under `ignore files and folders` section:

```
*.inject.summary;*.inject.dart;*.g.dart;
```

In Visual Studio Code, navigate to `Preferences` -> `Settings` and search for `Files:Exclude`. Add the following patterns:
```
**/*.inject.summary
**/*.inject.dart
**/*.g.dart
```

## Boilerplate Features:

* Splash
* Login
* Home
* Routing
* Theme
* Dio
* Database
* MobX (to connect the reactive data of your application with the UI)
* Provider (State Management)
* Encryption
* Validation
* Code Generation
* User Notifications
* Logging
* Dependency Injection
* Dark Theme Support (new)
* Multilingual Support (new)
* Provider example (new)

### Up-Coming Features:

* Connectivity Support
* Background Fetch Support

### Libraries & Tools Used

* [Dio](https://github.com/flutterchina/dio)
* [Database](https://github.com/tekartik/sembast.dart)
* [MobX](https://github.com/mobxjs/mobx.dart) (to connect the reactive data of your application with the UI)
* [Provider](https://github.com/rrousselGit/provider) (State Management)
* [Encryption](https://github.com/xxtea/xxtea-dart)
* [Validation](https://github.com/dart-league/validators)
* [Logging](https://github.com/zubairehman/Flogs)
* [Notifications](https://github.com/AndreHaueisen/flushbar)
* [Json Serialization](https://github.com/dart-lang/json_serializable)
* [Dependency Injection](https://github.com/fluttercommunity/get_it)

### Folder Structure
Here is the core folder structure which flutter provides.

```
flutter-app/
|- android
|- build
|- ios
|- lib
|- test
```

Here is the folder structure we have been using in this project

```
lib/
|- constants/
|- data/
|- stores/
|- ui/
|- utils/
|- widgets/
|- main.dart
|- routes.dart
```

Now, lets dive into the lib folder which has the main code for the application.

```
1- constants - All the application level constants are defined in this directory with-in their respective files. This directory contains the constants for `theme`, `dimentions`, `api endpoints`, `preferences` and `strings`.
2- data - Contains the data layer of your project, includes directories for local, network and shared pref/cache.
3- stores - Contains store(s) for state-management of your application, to connect the reactive data of your application with the UI.
4- ui — Contains all the ui of your project, contains sub directory for each screen.
5- util — Contains the utilities/common functions of your application.
6- widgets — Contains the common widgets for your applications. For example, Button, TextField etc.
7- routes.dart — This file contains all the routes for your application.
8- main.dart - This is the starting point of the application. All the application level configurations are defined in this file i.e, theme, routes, title, orientation etc.
```

### Constants

This directory contains all the application level constants. A separate file is created for each type as shown in example below:
git clone https://github.com/Dat-TG/ChatGPT.git
flutter pub get
flutter run
```
constants/
|- app_theme.dart
|- dimens.dart
|- endpoints.dart
|- preferences.dart
|- strings.dart
```

### Data

All the business logic of your application will go into this directory, it represents the data layer of your application. It is sub-divided into three directories `local`, `network` and `sharedperf`, each containing the domain specific logic. Since each layer exists independently, that makes it easier to unit test. The communication between UI and data layer is handled by using central repository.
## Environment
Create a .env file at the root directory, and add your OpenAI API access key:

```
data/
|- local/
|- constants/
|- datasources/
|- app_database.dart
|- network/
|- constants/
|- exceptions/
|- rest_client.dart
|- sharedpref
|- constants/
|- shared_preference_helper.dart
|- repository.dart
```
OPEN_API_ACCESS_KEY=
### Stores

The store is where all your application state lives in flutter. The Store is basically a widget that stands at the top of the widget tree and passes it's data down using special methods. In-case of multiple stores, a separate folder for each store is created as shown in the example below:

```
stores/
|- login/
|- login_store.dart
|- form_validator.dart
```

### UI

This directory contains all the ui of your application. Each screen is located in a separate folder making it easy to combine group of files related to that particular screen. All the screen specific widgets will be placed in `widgets` directory as shown in the example below:

```
ui/
|- login
|- login_screen.dart
|- widgets
|- login_form.dart
|- login_button.dart
```

### Utils

Contains the common file(s) and utilities used in a project. The folder structure is as follows:

```
utils/
|- encryption
|- xxtea.dart
|- date
|- date_time.dart
```

### Widgets

Contains the common widgets that are shared across multiple screens. For example, Button, TextField etc.

```
widgets/
|- app_icon_widget.dart
|- empty_app_bar.dart
|- progress_indicator.dart
```

### Routes

This file contains all the routes for your application.

```dart
import 'package:flutter/material.dart';
import 'ui/post/post_list.dart';
import 'ui/login/login.dart';
import 'ui/splash/splash.dart';
class Routes {
Routes._();
//static variables
static const String splash = '/splash';
static const String login = '/login';
static const String home = '/post';
static final routes = <String, WidgetBuilder>{
splash: (BuildContext context) => SplashScreen(),
login: (BuildContext context) => LoginScreen(),
home: (BuildContext context) => HomeScreen(),
};
}
```

### Main

This is the starting point of the application. All the application level configurations are defined in this file i.e, theme, routes, title, orientation etc.

```dart
import 'package:boilerplate/routes.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'constants/app_theme.dart';
import 'constants/strings.dart';
import 'ui/splash/splash.dart';
void main() {
SystemChrome.setPreferredOrientations([
DeviceOrientation.portraitUp,
DeviceOrientation.portraitDown,
DeviceOrientation.landscapeRight,
DeviceOrientation.landscapeLeft,
]).then((_) {
runApp(MyApp());
});
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: Strings.appName,
theme: themeData,
routes: Routes.routes,
home: SplashScreen(),
);
}
}
```

## Wiki

Checkout [wiki](https://github.com/zubairehman/flutter-boilerplate-project/wiki) for more info

## Conclusion
## Feedback

I will be happy to answer any questions that you may have on this approach, and if you want to lend a hand with the boilerplate then please feel free to submit an issue and/or pull request 🙂
If you have any feedback, please reach out to me at [email protected]

Again to note, this is example can appear as over-architectured for what it is - but it is an example only. If you liked my work, don’t forget to ⭐ star the repo to show your support.
## Screenshots

| | | |
|--- |--- |--- |
| ![Screenshot_1703869507](https://github.com/Dat-TG/Racing-And-Betting/assets/83936894/68af2b6e-9a1b-48ac-8d8d-10c19179217f)|![Screenshot_1703869520](https://github.com/Dat-TG/Racing-And-Betting/assets/83936894/7958bc7c-4d85-4ac2-99a9-8693602c08f9)| ![Screenshot_1703869524](https://github.com/Dat-TG/Racing-And-Betting/assets/83936894/94e97a9c-8dc9-43e8-82c5-bc8837972aaf)|
| ![Screenshot_1703869527](https://github.com/Dat-TG/Racing-And-Betting/assets/83936894/3f96d4e8-7dfe-4c13-9acd-0d28bd9f0088) |![Screenshot_1703869532](https://github.com/Dat-TG/Racing-And-Betting/assets/83936894/ee2916bb-812c-45c2-acd6-5601388c2f50)| ![Screenshot_1703869540](https://github.com/Dat-TG/Racing-And-Betting/assets/83936894/e30eb73c-85b7-4209-8903-4aaa5125a12d)|
|![Screenshot_1703869544](https://github.com/Dat-TG/Racing-And-Betting/assets/83936894/d3515ed2-cc05-455e-abb9-d7ee0374153d) | ![Screenshot_1703869550](https://github.com/Dat-TG/Racing-And-Betting/assets/83936894/ffc896b9-10f9-4dd9-b9f5-ee2c34c1de51) |![Screenshot_1703869575](https://github.com/Dat-TG/Racing-And-Betting/assets/83936894/e74b644d-e96e-4175-981d-2e34f09c3375)|
| ![Screenshot_1703869584](https://github.com/Dat-TG/Racing-And-Betting/assets/83936894/73e77127-51ab-4ee0-a079-664080a42ab6)| | |

0 comments on commit 7ae6735

Please sign in to comment.