Full Stack Flutter Developer
Phase 1: Flutter Fundamentals (Complete Guide for Full Stack Flutter Developer)
Agar aap Flutter me professional level par kaam karna chahte hain, to sabse pehle Dart language aur Flutter fundamentals ko deeply samajhna zaroori hai. Yeh guide aap blog par bhi publish kar sakte hain.
Module 1: Dart OOP (Object Oriented Programming)
Object-Oriented Programming ka matlab hai ki hum real-world objects ko classes aur objects ke through represent karte hain.
Class and Object
Example
class Student {
String name = "Rahul";
int age = 20;
void display() {
print("Name: $name");
print("Age: $age");
}
}
void main() {
Student s = Student();
s.display();
}
Output
Name: Rahul
Age: 20
Constructor
Constructor object create hote hi call hota hai.
class Student {
String name;
int age;
Student(this.name, this.age);
void display() {
print("$name $age");
}
}
void main() {
Student s = Student("Amit", 22);
s.display();
}
Inheritance
Ek class doosri class ke properties inherit kar sakti hai.
class Animal {
void sound() {
print("Animal Sound");
}
}
class Dog extends Animal {
void bark() {
print("Dog Barking");
}
}
void main() {
Dog d = Dog();
d.sound();
d.bark();
}
Polymorphism
class Animal {
void sound() {
print("Animal Sound");
}
}
class Dog extends Animal {
@override
void sound() {
print("Dog Bark");
}
}
void main() {
Animal a = Dog();
a.sound();
}
Output:
Dog Bark
Encapsulation
class Employee {
String _name = "";
void setName(String name) {
_name = name;
}
String getName() {
return _name;
}
}
Abstraction
abstract class Vehicle {
void start();
}
class Car extends Vehicle {
@override
void start() {
print("Car Started");
}
}
Module 2: Async Programming
Mobile apps me API calls aur database operations asynchronous hote hain.
Synchronous Example
void main() {
print("Start");
print("Loading Data");
print("End");
}
Output:
Start
Loading Data
End
Asynchronous Example
Future<void> getData() async {
await Future.delayed(Duration(seconds: 3));
print("Data Loaded");
}
void main() {
print("Start");
getData();
print("End");
}
Output:
Start
End
Data Loaded
Module 3: Future
Future future me milne wale result ko represent karta hai.
Creating Future
Future<String> fetchData() {
return Future.delayed(
Duration(seconds: 2),
() => "Data Received",
);
}
Using Future
void main() async {
String data = await fetchData();
print(data);
}
Output:
Data Received
Future.then()
fetchData().then((value) {
print(value);
});
Module 4: Async and Await
Modern way of handling Future.
Without Async Await
fetchData().then((value) {
print(value);
});
With Async Await
Future<void> loadData() async {
String result = await fetchData();
print(result);
}
Module 5: Streams
Stream continuous data flow ke liye use hota hai.
Examples:
- Chat Messages
- Live Location
- Stock Market
- Notifications
Creating Stream
Stream<int> countNumbers() async* {
for (int i = 1; i <= 5; i++) {
await Future.delayed(Duration(seconds: 1));
yield i;
}
}
Listening Stream
void main() async {
await for (int value in countNumbers()) {
print(value);
}
}
Output
1
2
3
4
5
StreamController
import 'dart:async';
void main() {
StreamController controller = StreamController();
controller.stream.listen((data) {
print(data);
});
controller.add("Hello");
controller.add("Flutter");
}
Module 6: Generics
Generics type safety provide karta hai.
Without Generic
List items = [];
items.add("Rahul");
items.add(100);
Problem:
Mixed data aa sakta hai.
With Generic
List<String> names = [];
names.add("Rahul");
Wrong:
names.add(100);
Compiler Error.
Generic Class
class Box<T> {
T value;
Box(this.value);
}
void main() {
Box<String> box = Box("Flutter");
print(box.value);
}
Module 7: Flutter Widgets
Flutter me sab kuch Widget hai.
Stateless Widget
Immutable Widget
class HomeScreen extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Text("Hello Flutter");
}
}
Stateful Widget
Mutable Widget
class CounterScreen extends StatefulWidget {
@override
State<CounterScreen> createState() {
return _CounterScreenState();
}
}
class _CounterScreenState extends State<CounterScreen> {
int count = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Text("$count"),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
setState(() {
count++;
});
},
),
);
}
}
Common Widgets
Text
Text("Hello")
Container
Container(
height: 100,
width: 100,
color: Colors.red,
)
Row
Row(
children: [
Text("A"),
Text("B"),
],
)
Column
Column(
children: [
Text("A"),
Text("B"),
],
)
ListView
ListView.builder(
itemCount: 10,
itemBuilder: (context, index) {
return ListTile(
title: Text("Item $index"),
);
},
)
Module 8: State Management
State = Data + UI
Example:
Counter Value = 10
Ye State hai.
Provider
Flutter ka official lightweight state management.
Dependency
provider: ^6.1.2
Counter Provider
class CounterProvider extends ChangeNotifier {
int count = 0;
void increment() {
count++;
notifyListeners();
}
}
Register Provider
ChangeNotifierProvider(
create: (_) => CounterProvider(),
)
Access Provider
Consumer<CounterProvider>(
builder: (context, provider, child) {
return Text(
provider.count.toString(),
);
},
)
Riverpod (Recommended)
Provider ka advanced version.
Benefits:
- Compile Time Safety
- Better Performance
- No BuildContext Required
Dependency
flutter_riverpod: ^2.5.1
Create Provider
final counterProvider =
StateProvider<int>((ref) => 0);
Use Provider
class HomePage extends ConsumerWidget {
@override
Widget build(
BuildContext context,
WidgetRef ref) {
final count =
ref.watch(counterProvider);
return Scaffold(
body: Center(
child: Text("$count"),
),
floatingActionButton:
FloatingActionButton(
onPressed: () {
ref
.read(counterProvider.notifier)
.state++;
},
),
);
}
}
Bloc State Management
Large projects ke liye.
Architecture:
UI
↓
Event
↓
Bloc
↓
State
↓
UI
Event
abstract class CounterEvent {}
class IncrementEvent
extends CounterEvent {}
State
class CounterState {
final int count;
CounterState(this.count);
}
Bloc
class CounterBloc
extends Bloc<CounterEvent,
CounterState> {
CounterBloc()
: super(CounterState(0)) {
on<IncrementEvent>((event, emit) {
emit(
CounterState(
state.count + 1,
),
);
});
}
}
UI
BlocBuilder<
CounterBloc,
CounterState>(
builder: (context, state) {
return Text(
"${state.count}",
);
},
)
Provider vs Riverpod vs Bloc
| Feature | Provider | Riverpod | Bloc |
|---|---|---|---|
| Easy | ✅ | ✅ | ❌ |
| Performance | Good | Excellent | Excellent |
| Learning Curve | Easy | Medium | Hard |
| Large Project | Medium | Excellent | Excellent |
| Testing | Medium | Excellent | Excellent |
Recommended Learning Order
- Dart OOP
- Future
- Async Await
- Streams
- Generics
- Widgets
- StatefulWidget
- Provider
- Riverpod
- Bloc
Phase 2: API Integration in Flutter (Complete Beginner to Advanced Guide)
Flutter app ko backend (Node.js, PHP, Java, .NET, Python, etc.) se connect karne ke liye APIs ka use hota hai. Aaj lagbhag har production app API based hoti hai.
Examples:
- WhatsApp → API
- Instagram → API
- Facebook → API
- Banking App → API
- Sugar Cane Management App → API
What is API?
API (Application Programming Interface) ek bridge hai jo Flutter App aur Database/Server ke beech communication karata hai.
Flow
Flutter App
↓
REST API
↓
Backend Server
↓
Database
Example:
Login Button Click
↓
POST API Call
↓
Backend Verify User
↓
Database Check
↓
Success Response
REST API Basics
REST = Representational State Transfer
Most common API architecture.
HTTP Methods
| Method | Purpose |
|---|---|
| GET | Data Fetch |
| POST | Create Data |
| PUT | Update Data |
| PATCH | Partial Update |
| DELETE | Delete Data |
Example
GET
GET /users
Response
[
{
"id":1,
"name":"Rahul"
}
]
POST
POST /users
Body
{
"name":"Rahul"
}
PUT
PUT /users/1
Body
{
"name":"Amit"
}
DELETE
DELETE /users/1
Understanding JSON
JSON = JavaScript Object Notation
Most APIs JSON format use karti hain.
JSON Object
{
"name":"Rahul",
"age":25
}
JSON Array
[
{
"name":"Rahul"
},
{
"name":"Amit"
}
]
JSON Parsing in Flutter
Response:
{
"id":1,
"name":"Rahul"
}
Create Model
class User {
final int id;
final String name;
User({
required this.id,
required this.name,
});
factory User.fromJson(
Map<String, dynamic> json) {
return User(
id: json['id'],
name: json['name'],
);
}
}
Parse JSON
User user =
User.fromJson(responseData);
HTTP Package
Most commonly used package.
Install
dependencies:
http: ^1.2.0
Import
import 'package:http/http.dart'
as http;
GET API Example
Future<void> getUsers() async {
final response =
await http.get(
Uri.parse(
'https://jsonplaceholder.typicode.com/users',
),
);
print(response.body);
}
Decode JSON
import 'dart:convert';
final data =
jsonDecode(response.body);
print(data);
POST API Example
Future<void> login() async {
final response =
await http.post(
Uri.parse(
"https://api.com/login",
),
body: {
"username": "admin",
"password": "123456"
},
);
print(response.body);
}
POST JSON Body
await http.post(
Uri.parse(url),
headers: {
"Content-Type":
"application/json"
},
body: jsonEncode({
"username":"admin",
"password":"123456"
}),
);
Handling Status Codes
if(response.statusCode == 200){
print("Success");
}else{
print("Failed");
}
Dio Package
Production apps me Dio zyada powerful mana jata hai.
Benefits:
- Better Error Handling
- Interceptors
- Upload Support
- Timeout
- Logging
Install
dio: ^5.4.0
Create Dio Instance
final dio = Dio();
GET Request
final response =
await dio.get(
"https://api.com/users",
);
print(response.data);
POST Request
final response =
await dio.post(
"https://api.com/login",
data: {
"username":"admin",
"password":"123456"
},
);
Dio Interceptor
Har request me token add karne ke liye.
dio.interceptors.add(
InterceptorsWrapper(
onRequest:
(options, handler) {
options.headers[
"Authorization"
] = "Bearer token";
return handler.next(
options,
);
},
),
);
Login API Project
Request
{
"username":"admin",
"password":"123456"
}
Response
{
"status":true,
"token":"abc123"
}
Login Model
class LoginResponse {
bool status;
String token;
LoginResponse({
required this.status,
required this.token,
});
factory LoginResponse.fromJson(
Map<String,dynamic> json) {
return LoginResponse(
status: json['status'],
token: json['token'],
);
}
}
Login API Service
class AuthService {
Future<LoginResponse>
login() async {
final response =
await dio.post(
"login",
data: {
"username":"admin",
"password":"123456"
},
);
return LoginResponse.fromJson(
response.data,
);
}
}
CRUD API Project
CRUD = Create Read Update Delete
Most interview questions CRUD par based hote hain.
Create User
await dio.post(
"users",
data: {
"name":"Rahul"
},
);
Read Users
await dio.get(
"users",
);
Update User
await dio.put(
"users/1",
data: {
"name":"Amit"
},
);
Delete User
await dio.delete(
"users/1",
);
Generic API Service
Reusable code.
class ApiService {
final Dio dio = Dio();
Future get(
String url) async {
return await dio.get(url);
}
Future post(
String url,
dynamic data) async {
return await dio.post(
url,
data: data,
);
}
}
Multipart Upload
Images, PDF, Videos upload karne ke liye.
Pick File
file_picker: ^8.0.0
FilePickerResult? result =
await FilePicker.platform
.pickFiles();
Upload Image
FormData formData =
FormData.fromMap({
"image":
await MultipartFile
.fromFile(
file.path,
),
});
Upload API
await dio.post(
"upload",
data: formData,
);
Multiple File Upload
FormData formData =
FormData.fromMap({
"files": [
await MultipartFile
.fromFile(file1.path),
await MultipartFile
.fromFile(file2.path),
]
});
Download File
await dio.download(
fileUrl,
savePath,
);
API Error Handling
Production app ka sabse important topic.
Try Catch
try {
final response =
await dio.get(url);
} catch (e) {
print(e);
}
DioException Handling
try {
await dio.get(url);
} on DioException catch(e){
print(e.message);
}
Handle Different Errors
on DioException catch(e){
switch(e.type){
case DioExceptionType.connectionTimeout:
print("Timeout");
break;
case DioExceptionType.badResponse:
print("Server Error");
break;
case DioExceptionType.connectionError:
print("No Internet");
break;
default:
print("Unknown Error");
}
}
Internet Connectivity Check
Package:
connectivity_plus: ^6.0.0
ConnectivityResult result =
await Connectivity()
.checkConnectivity();
if(result ==
ConnectivityResult.none){
print("No Internet");
}
Token Based Authentication
Login ke baad token save karte hain.
Example Response:
{
"token":"abc123"
}
Save Token
SharedPreferences prefs =
await SharedPreferences
.getInstance();
prefs.setString(
"token",
token,
);
Read Token
String? token =
prefs.getString(
"token",
);
Recommended Project Structure
lib
│
├── models
│ ├── user_model.dart
│
├── services
│ ├── api_service.dart
│ ├── auth_service.dart
│
├── repository
│ ├── auth_repository.dart
│
├── screens
│
├── widgets
│
└── main.dart
Real Project Practice
Beginner
✅ Login API
✅ Register API
✅ User Profile API
Intermediate
✅ Employee Management System
✅ Inventory Management
✅ Student Management
Advanced
✅ E-Commerce API
✅ Chat Application API
✅ Sugar Cane Management System API
✅ ERP System
Industry Best Practices
- Dio Package Use Karo
- Model Classes Banao
- Repository Pattern Follow Karo
- API Response Generic Rakho
- Error Handling Zarur Karo
- JWT Token Use Karo
- HTTPS APIs Use Karo
- Sensitive Data Secure Storage Me Rakho
- Loading State Handle Karo
- Clean Architecture Follow Karo
Learning Sequence
- REST API Basics
- JSON Parsing
- HTTP Package
- Dio Package
- Login API
- CRUD API
- Multipart Upload
- Token Authentication
- Error Handling
- Repository Pattern
- Clean Architecture
- Production-Level API Integration
Phase 3: Backend Development (Complete Roadmap for Flutter Developers)
Agar aap Full Stack Flutter Developer banna chahte hain, to Backend Development sabse important phase hai. Backend hi app ka brain hota hai jo:
- User Login Handle karta hai
- Database Manage karta hai
- Business Logic Execute karta hai
- APIs Provide karta hai
- Notifications Send karta hai
- File Upload Handle karta hai
Backend Kya Hota Hai?
Jab user Flutter app me Login button click karta hai:
Flutter App
↓
Login API
↓
Backend Server
↓
Database
↓
Response
↓
Flutter App
Example:
Username = admin
Password = 123456
Backend verify karega:
Database Check
↓
Valid User ?
↓
Yes
↓
Token Generate
↓
Response Send
Backend Developer Ko Kya Kya Aana Chahiye?
Core Skills
Programming Language
- JavaScript (Node.js)
- TypeScript (Recommended)
Backend Framework
- Express.js
Database
- MongoDB
- PostgreSQL
Authentication
- JWT
- Refresh Token
- OTP
APIs
- REST APIs
- CRUD Operations
Storage
- File Upload
- Images
- PDFs
- OTP Email
- Forgot Password
Deployment
- AWS
- VPS
- Docker
Why Node.js?
Node.js duniya ke sabse popular backend platforms me se ek hai.
Companies:
Node.js Fast, Scalable aur Easy hai.
Step 1: JavaScript ES6
Node.js seekhne se pehle JavaScript zaroor seekho.
Variables
var
var name = "Rahul";
let
let age = 25;
const
const city = "Delhi";
Recommended:
const name = "Rahul";
Functions
function add(a, b) {
return a + b;
}
console.log(add(10,20));
Output
30
Arrow Functions
const add = (a,b) => {
return a+b;
};
Short Form
const add = (a,b) => a+b;
Arrays
const users = [
"Rahul",
"Amit",
"Rohit"
];
Objects
const user = {
name:"Rahul",
age:25
};
console.log(user.name);
Async Await
Backend me bahut use hota hai.
async function getData() {
const data =
await fetch(url);
console.log(data);
}
Step 2: Node.js
Node.js JavaScript ko server par chalane ki facility deta hai.
Install
Download:
https://nodejs.org
Check Version
node -v
Output
v22.x.x
Create First Project
mkdir backend
cd backend
npm init -y
Create Server
app.js
const http = require('http');
const server = http.createServer(
(req,res)=>{
res.end("Hello Backend");
}
);
server.listen(3000);
Run
node app.js
Browser
http://localhost:3000
Output
Hello Backend
Step 3: Express.js
Express Node.js ka sabse popular framework hai.
Install
npm install express
First Express App
const express = require('express');
const app = express();
app.get('/',(req,res)=>{
res.send(
"Backend Running"
);
});
app.listen(3000);
API Example
app.get('/users',
(req,res)=>{
res.json([
{
id:1,
name:"Rahul"
}
]);
});
Response
[
{
"id":1,
"name":"Rahul"
}
]
Step 4: REST APIs
Backend ka sabse important topic.
GET
app.get('/users',
(req,res)=>{
});
Data Fetch
POST
app.post('/users',
(req,res)=>{
});
Data Create
PUT
app.put('/users/:id',
(req,res)=>{
});
Data Update
DELETE
app.delete('/users/:id',
(req,res)=>{
});
Data Delete
CRUD Example
Create
app.post('/users',
(req,res)=>{
res.send(
"User Created"
);
});
Read
app.get('/users',
(req,res)=>{
res.send(
"User List"
);
});
Update
app.put('/users/:id',
(req,res)=>{
res.send(
"Updated"
);
});
Delete
app.delete('/users/:id',
(req,res)=>{
res.send(
"Deleted"
);
});
Step 5: MongoDB
MongoDB NoSQL Database hai.
Data JSON format me store hota hai.
Example Document
{
"_id":"123",
"name":"Rahul",
"email":"rahul@gmail.com"
}
Install Mongoose
npm install mongoose
Connect Database
const mongoose =
require('mongoose');
mongoose.connect(
"mongodb://127.0.0.1:27017/cms"
);
Create Schema
const userSchema =
new mongoose.Schema({
name:String,
email:String
});
Create Model
const User =
mongoose.model(
'User',
userSchema
);
Save Data
const user =
new User({
name:"Rahul",
email:"rahul@gmail.com"
});
await user.save();
Get Data
const users =
await User.find();
Step 6: Middleware
Middleware request ke beech me execute hota hai.
Request
↓
Middleware
↓
Controller
↓
Response
Example
app.use(
(req,res,next)=>{
console.log(
"Middleware"
);
next();
});
Authentication Middleware
const auth =
(req,res,next)=>{
const token =
req.headers.authorization;
if(!token){
return res.status(401)
.send("Unauthorized");
}
next();
};
Step 7: JWT Authentication
Production apps ka standard login system.
Install
npm install jsonwebtoken
Generate Token
const jwt =
require('jsonwebtoken');
const token =
jwt.sign(
{id:1},
"secretkey",
{expiresIn:'7d'}
);
Verify Token
jwt.verify(
token,
"secretkey"
);
Login Flow
User Login
↓
Check Database
↓
Generate JWT
↓
Send Token
↓
Flutter Save Token
↓
Every API Request
Step 8: File Upload
Real projects me image upload bahut common hai.
Examples:
- Profile Image
- Aadhaar Upload
- Invoice PDF
- Sugar Cane Slip
Install Multer
npm install multer
Configuration
const multer =
require('multer');
const upload =
multer({
dest:'uploads/'
});
Upload API
app.post(
'/upload',
upload.single('image'),
(req,res)=>{
res.send(
"Uploaded"
);
});
Multiple Files
upload.array(
'files',
5
);
Step 9: Email Service
Use Cases
- OTP Verification
- Forgot Password
- Welcome Email
Install
npm install nodemailer
Send Email
const nodemailer =
require('nodemailer');
const transporter =
nodemailer.createTransport({
service:'gmail',
auth:{
user:'email',
pass:'password'
}
});
Send Mail
await transporter.sendMail({
from:'admin@gmail.com',
to:'user@gmail.com',
subject:'OTP',
text:'123456'
});
Production Folder Structure
backend
│
├── config
│
├── models
│
├── routes
│
├── controllers
│
├── middleware
│
├── services
│
├── utils
│
├── uploads
│
├── app.js
│
└── package.json
MVC Architecture
Request
↓
Route
↓
Controller
↓
Model
↓
Database
Example
Route
router.get(
'/users',
userController.getUsers
);
Controller
exports.getUsers =
async(req,res)=>{
const users =
await User.find();
res.json(users);
};
Full Login Flow
Flutter App
↓
Login Screen
↓
POST /login
↓
Express.js
↓
MongoDB
↓
Check User
↓
Generate JWT
↓
Send Token
↓
Flutter Store Token
↓
Dashboard Open
Option 2: Dart Backend (Serverpod)
Agar aap JavaScript nahi seekhna chahte aur Dart hi continue rakhna chahte hain to Serverpod ek achha option hai.
Kya Seekhna Hoga?
- Dart Advanced
- Serverpod
- PostgreSQL
- Docker
- REST APIs
- Authentication
Architecture:
Flutter
↓
Serverpod
↓
PostgreSQL
Pros
✅ Same Language (Dart)
✅ Flutter Integration Easy
✅ Type Safety
✅ Faster Development
Cons
❌ Community Chhoti Hai
❌ Jobs Kam Hain
❌ Learning Resources Kam
Industry Recommendation (2026)
Agar aap job, freelancing aur enterprise projects target kar rahe hain:
Flutter
↓
Riverpod
↓
Node.js
↓
Express.js
↓
MongoDB Atlas
↓
JWT
↓
AWS
↓
Docker
Ye stack seekhne ke baad aap:
✅ Flutter App Bana Sakte Ho
✅ Backend APIs Bana Sakte Ho
✅ MongoDB Database Handle Kar Sakte Ho
✅ Authentication System Bana Sakte Ho
✅ File Upload Kar Sakte Ho
✅ Email/OTP System Bana Sakte Ho
✅ Cloud Deployment Kar Sakte Ho
Phase 4: Database (MongoDB + PostgreSQL Complete Guide for Flutter Developers)
Agar aap Full Stack Flutter Developer banna chahte hain, to Database ki understanding bahut zaroori hai. Backend data ko store, retrieve aur manage karne ke liye Database ka use karta hai.
Database ke bina:
❌ Login System nahi banega
❌ User Data Store nahi hoga
❌ Products Save nahi honge
❌ Reports Generate nahi hongi
❌ Sugar Cane Management System nahi chalega
Database Kya Hota Hai?
Database ek digital storage system hai jahan data permanently save hota hai.
Example:
User Registration
↓
Backend
↓
Database
↓
Data Save
Types of Databases
1. NoSQL Database
Example:
- MongoDB
- Cassandra
- DynamoDB
Data JSON format me store hota hai.
2. SQL Database
Example:
- PostgreSQL
- MySQL
- SQL Server
- Oracle
Data Tables me store hota hai.
MongoDB (Most Popular for Node.js)
MongoDB ek NoSQL Database hai.
Data JSON jaise format (BSON) me store hota hai.
MongoDB Architecture
Database
↓
Collections
↓
Documents
Example:
CMS
│
├── Users Collection
├── Farmers Collection
├── Payments Collection
└── CaneCollection
Collection Kya Hai?
SQL me Table hoti hai.
MongoDB me Collection hoti hai.
Example:
Users
Farmers
Employees
Payments
Document Kya Hai?
Collection ke andar jo record hota hai use Document kehte hain.
Example:
{
"_id":"123",
"name":"Rahul",
"email":"rahul@gmail.com",
"mobile":"9876543210"
}
Ye ek document hai.
MongoDB Installation
Download:
https://www.mongodb.com
Connect MongoDB with Node.js
Install:
npm install mongoose
Database Connection
const mongoose =
require('mongoose');
mongoose.connect(
'mongodb://127.0.0.1:27017/cms'
);
Create Schema
Schema data structure define karta hai.
const userSchema =
new mongoose.Schema({
name:String,
email:String,
mobile:String
});
Create Model
const User =
mongoose.model(
'User',
userSchema
);
CRUD Operations
CRUD = Create Read Update Delete
Har project me CRUD hota hai.
CREATE
User Save Karna
const user =
new User({
name:"Rahul",
email:"rahul@gmail.com"
});
await user.save();
READ
Data Fetch Karna
const users =
await User.find();
console.log(users);
Find One
const user =
await User.findOne({
email:"rahul@gmail.com"
});
UPDATE
await User.updateOne(
{email:"rahul@gmail.com"},
{$set:{name:"Amit"}}
);
DELETE
await User.deleteOne({
email:"rahul@gmail.com"
});
Query Filtering
const users =
await User.find({
city:"Noida"
});
Sorting
const users =
await User.find()
.sort({
createdAt:-1
});
Pagination
Large Data ke liye.
const users =
await User.find()
.skip(0)
.limit(10);
Aggregation Framework
MongoDB ka sabse powerful feature.
Reports aur Analytics me use hota hai.
Example
Total Farmers Count
await Farmer.aggregate([
{
$group:{
_id:null,
total:{
$sum:1
}
}
}
]);
Group By Example
Village Wise Farmer Count
await Farmer.aggregate([
{
$group:{
_id:"$village",
count:{
$sum:1
}
}
}
]);
Output:
[
{
"_id":"Village A",
"count":120
},
{
"_id":"Village B",
"count":75
}
]
Aggregation Use Cases
Sugar Cane Management System
Village Wise Report
Bank Wise Payment Report
Farmer Wise Cane Quantity
Advice Wise Summary
Season Wise Production
Indexing
Performance improve karne ke liye use hota hai.
Without Index
10 Lakh Records
Search Time = Slow
With Index
10 Lakh Records
Search Time = Fast
Create Index
userSchema.index({
email:1
});
Compound Index
userSchema.index({
name:1,
mobile:1
});
Relationships in MongoDB
MongoDB me foreign key nahi hoti.
References use hote hain.
Example
Farmer Collection
{
"_id":"1",
"name":"Rahul"
}
Payment Collection
{
"_id":"10",
"farmerId":"1",
"amount":10000
}
Populate
Payment.find()
.populate('farmerId');
Output:
{
"amount":10000,
"farmerId":{
"name":"Rahul"
}
}
MongoDB Atlas
MongoDB ka cloud version.
Benefits:
✅ Free Cluster
✅ Cloud Hosting
✅ Automatic Backup
✅ Security
✅ Global Access
Atlas Flow
Flutter App
↓
Node.js
↓
MongoDB Atlas Cloud
Atlas Connection String
mongodb+srv://username:
password@cluster.mongodb.net
Why Atlas?
Production projects me local database use nahi hota.
Industry:
MongoDB Atlas
AWS
Azure
Google Cloud
Use karti hai.
PostgreSQL
PostgreSQL duniya ke best SQL Databases me se ek hai.
Enterprise companies bahut use karti hain.
SQL Database Structure
Database
↓
Tables
↓
Rows
↓
Columns
Example
Users Table
| id | name | |
|---|---|---|
| 1 | Rahul | rahul@gmail.com |
| 2 | Amit | amit@gmail.com |
Create Table
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name VARCHAR(100),
email VARCHAR(100)
);
Insert Data
INSERT INTO users
(name,email)
VALUES
('Rahul',
'rahul@gmail.com');
Select Data
SELECT * FROM users;
Update Data
UPDATE users
SET name='Amit'
WHERE id=1;
Delete Data
DELETE FROM users
WHERE id=1;
Joins
SQL ka sabse important topic.
Farmers Table
| id | name |
|---|---|
| 1 | Rahul |
Payments Table
| id | farmer_id | amount |
|---|---|---|
| 1 | 1 | 10000 |
INNER JOIN
SELECT *
FROM farmers f
INNER JOIN payments p
ON f.id=p.farmer_id;
Output
Rahul 10000
LEFT JOIN
SELECT *
FROM farmers f
LEFT JOIN payments p
ON f.id=p.farmer_id;
Views
Virtual Table.
Complex query ko reusable bana sakte ho.
Create View
CREATE VIEW payment_report AS
SELECT
name,
amount
FROM farmers
JOIN payments
ON farmers.id=
payments.farmer_id;
Use View
SELECT *
FROM payment_report;
Stored Procedures
Database ke andar function.
Example
CREATE PROCEDURE getUsers()
LANGUAGE SQL
AS $$
SELECT * FROM users;
$$;
Normalization
Duplicate data remove karne ki technique.
Bad Design
Farmer Name
Village
Bank Name
Bank IFSC
Har record me repeat hoga.
Good Design
Farmers Table
Villages Table
Banks Table
Payments Table
Separate tables.
Normal Forms
1NF
Single Value Columns
❌
Mobile:
123,456
✅
123
2NF
Partial Dependency Remove
3NF
Transitive Dependency Remove
MongoDB vs PostgreSQL
| Feature | MongoDB | PostgreSQL |
|---|---|---|
| Data Type | JSON | Tables |
| Schema | Flexible | Fixed |
| Learning | Easy | Medium |
| Performance | Excellent | Excellent |
| Complex Reports | Good | Excellent |
| Joins | Limited | Powerful |
| ERP Projects | Good | Excellent |
| Flutter Projects | Excellent | Excellent |
Kya Choose Kare?
Agar Aap Flutter + Node.js Seekh Rahe Ho
Flutter
↓
Node.js
↓
MongoDB Atlas
Best Choice ✅
Agar Aap Enterprise ERP Bana Rahe Ho
Flutter
↓
Node.js
↓
PostgreSQL
Best Choice ✅
Sugar Cane Management System Ke Liye
Aapke project me:
- Farmer Data
- Village Data
- Bank Data
- Advice Data
- Cane Quantity
- Payment Reports
- Season Reports
Bahut saare relationships aur reports hain.
Isliye Professional Architecture:
Flutter
↓
Node.js
↓
Express.js
↓
PostgreSQL
ya
Flutter
↓
Node.js
↓
MongoDB AtlasPhase 5: Authentication (Complete Guide for Flutter + Node.js + MongoDB/PostgreSQL)
Authentication kisi bhi production app ka sabse important part hota hai. Agar authentication nahi hai to koi bhi user kisi bhi account me access kar sakta hai.
Examples:
- WhatsApp Login
- Google Login
- Facebook Login
- Banking App Login
- Sugar Cane Management Login
- Employee Management Login
Sabme Authentication use hoti hai.
Authentication Kya Hai?
Authentication ka matlab hai:
User Kaun Hai?Authorization ka matlab hai:
User Kya Kar Sakta Hai?Example:
Admin Login
↓
Dashboard Access
Employee Login
↓
Limited Access
Authentication Flow
Flutter App
↓
Login Screen
↓
Backend API
↓
Database Check
↓
Generate Token
↓
Send Token
↓
Flutter Store Token
↓
Dashboard Open
Authentication Types
1. Username Password Login
Most common.
Username
PasswordExample:
admin
123456
2. OTP Login
Mobile Number Login
9876543210
↓
Send OTP
↓
123456
↓
Verify
3. Google Login
Click Google Login
↓
Google Account Select
↓
Success
4. Social Login
- Apple
- GitHub
JWT Authentication
JWT = JSON Web Token
Industry standard authentication system.
Login Flow
User Login
↓
Backend Verify
↓
JWT Generate
↓
Send Token
↓
Flutter Save Token
↓
Every API Call
JWT Structure
Header.Payload.SignatureExample:
eyJhbGci...
Generate JWT
Node.js Package:
npm install jsonwebtoken
Create Token
const jwt =
require('jsonwebtoken');
const token =
jwt.sign(
{
userId:1
},
"secretkey",
{
expiresIn:"7d"
}
);
Response
{
"status":true,
"token":"eyJhbGci..."
}
Verify Token
jwt.verify(
token,
"secretkey"
);
Auth Middleware
const auth =
(req,res,next)=>{
const token =
req.headers.authorization;
if(!token){
return res.status(401)
.json({
message:
"Unauthorized"
});
}
next();
};
Protected API
app.get(
'/profile',
auth,
(req,res)=>{
res.send(
"Profile Data"
);
});
Flutter Token Save
Package:
shared_preferences: ^2.2.2
Save Token
SharedPreferences prefs =
await SharedPreferences
.getInstance();
prefs.setString(
"token",
token
);
Read Token
String? token =
prefs.getString(
"token"
);
Send Token in API
Using Dio:
dio.options.headers = {
"Authorization":
"Bearer $token"
};
Refresh Token
JWT expire ho jata hai.
Example:
Access Token
7 DaysExpiry ke baad user logout ho jayega.
Refresh Token se naya token generate karte hain.
Refresh Flow
Login
↓
Access Token
↓
Refresh Token
↓
Access Expired
↓
Refresh API
↓
New Token
Login Response
{
"accessToken":"abc",
"refreshToken":"xyz"
}
Refresh API
app.post(
'/refresh-token',
(req,res)=>{
const refreshToken =
req.body.refreshToken;
// verify
const token =
jwt.sign(...);
res.json({
token
});
});
Why Refresh Token?
Benefits:
✅ Better Security
✅ Long Session
✅ Auto Login
✅ Production Standard
OTP Authentication
Mobile Apps me bahut common.
Examples:
- Paytm
- PhonePe
- Banking Apps
OTP Flow
Mobile Number
↓
Send OTP
↓
123456
↓
Verify
↓
Login Success
Generate OTP
const otp = Math.floor(
100000 +
Math.random() * 900000
);Example:
483921
Save OTP
Database:
{
"mobile":"9876543210",
"otp":"483921"
}
Verify OTP
if(savedOtp ==
enteredOtp){
Login Success
}
OTP Expiry
OTP
Valid For
5 MinutesBest Practice.
SMS Services
Popular Services:
Google Login
Most users password yaad nahi rakhna chahte.
Google Login easiest option hai.
Flow
Google Button
↓
Choose Account
↓
Google Verify
↓
User Data
↓
Login Success
Flutter Package
google_sign_in: ^7.0.0
Sign In
final GoogleSignIn
googleSignIn =
GoogleSignIn();
final user =
await googleSignIn
.signIn();
User Info
print(user?.email);
print(user?.displayName);
Backend Verification
Flutter:
Google Login
↓
Get ID Token
↓
Send BackendBackend:
Verify Token
↓
Create User
↓
JWT Generate
Firebase Authentication
Flutter Developers ke liye sabse easy authentication system.
Why Firebase Auth?
Benefits:
✅ Easy Setup
✅ OTP Login
✅ Google Login
✅ Apple Login
✅ Email Login
✅ Secure
✅ Free Tier
Authentication Methods
Firebase Support:
Email Password
Google Login
Phone OTP
Apple Login
Anonymous Login
Setup Firebase
Flutter Project
flutterfire configure
Dependencies
firebase_core: ^4.0.0
firebase_auth: ^6.0.0
Initialize Firebase
await Firebase.initializeApp();
Email Password Registration
await FirebaseAuth.instance
.createUserWithEmailAndPassword(
email: email,
password: password
);
Login
await FirebaseAuth.instance
.signInWithEmailAndPassword(
email: email,
password: password
);
Current User
User? user =
FirebaseAuth
.instance
.currentUser;
Logout
await FirebaseAuth
.instance
.signOut();
Phone Authentication
FirebaseAuth.instance
.verifyPhoneNumber(
phoneNumber:
"+919876543210",
verificationCompleted:
(credential){},
verificationFailed:
(error){},
codeSent:
(verificationId,
resendToken){},
codeAutoRetrievalTimeout:
(verificationId){},
);
Verify OTP
PhoneAuthCredential
credential =
PhoneAuthProvider
.credential(
verificationId:
verificationId,
smsCode:
otp
);
Sign In
await FirebaseAuth.instance
.signInWithCredential(
credential
);
Forgot Password
await FirebaseAuth.instance
.sendPasswordResetEmail(
email: email
);
Production Security Rules
Password Hashing
Never save password directly.
❌ Wrong
{
"password":"123456"
}✅ Correct
{
"password":
"$2b$10$abc..."
}Use:
npm install bcrypt
Hash Password
const bcrypt =
require('bcrypt');
const hash =
await bcrypt.hash(
password,
10
);
Compare Password
const match =
await bcrypt.compare(
password,
user.password
);
Role Based Authentication
Example:
Admin
Manager
Employee
Farmer
User Schema
{
"name":"Rahul",
"role":"Admin"
}
Authorization Middleware
if(
user.role
!== "Admin"
){
return res.status(403);
}
Authentication Architecture
Flutter App
↓
Login API
↓
Node.js
↓
JWT Generate
↓
MongoDB/PostgreSQL
↓
Token Response
↓
Flutter Save Token
↓
Protected APIs
Recommended Learning Order
Week 1
- Authentication Basics
- Session vs Token
Week 2
- JWT Authentication
- Middleware
Week 3
- Refresh Token
- Secure Storage
Week 4
- OTP Login
- SMS Integration
Week 5
- Google Login
- Social Login
Week 6
- Firebase Authentication
- Phone Auth
Week 7
- Password Hashing
- Role Based Access
Production Recommendation for Flutter Developers
Flutter
↓
Firebase Auth
↓
Google Login
↓
Phone OTP
↓
Node.js Backend
↓
JWT Authentication
↓
MongoDB AtlasPhase 6: Firebase (Complete Guide for Flutter Developers)
Agar aap Flutter Developer hain, to Firebase seekhna almost mandatory hai. Firebase Google ka Backend-as-a-Service (BaaS) platform hai jo backend development ko bahut easy bana deta hai.
Firebase ki madad se aap bina Node.js backend likhe bhi:
✅ Login System bana sakte ho
✅ Database use kar sakte ho
✅ Push Notifications bhej sakte ho
✅ Analytics dekh sakte ho
✅ Crash Reports track kar sakte ho
✅ Cloud Functions chala sakte ho
✅ File Storage use kar sakte ho
Firebase Kya Hai?
Firebase Google ka cloud platform hai.
Architecture:
Flutter App
↓
Firebase Services
↓
Google CloudTraditional Approach:
Flutter
↓
Node.js
↓
DatabaseFirebase Approach:
Flutter
↓
Firebase
Firebase Services
Most Important Firebase Services:
- Authentication
- Firestore Database
- Cloud Functions
- Cloud Messaging (FCM)
- Analytics
- Crashlytics
- Storage
Firebase Setup
Step 1
Firebase Project Create Karo
Official Website:
Step 2
FlutterFire CLI Install
dart pub global activate flutterfire_cli
Step 3
Configure Project
flutterfire configure
Step 4
Install Packages
dependencies:
firebase_core: ^4.0.0
Step 5
Initialize Firebase
void main() async {
WidgetsFlutterBinding
.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}
Firebase Authentication
Authentication user login manage karta hai.
Supported Login Types
Email Password
Google Login
Phone OTP
Apple Login
Anonymous Login
Package
firebase_auth: ^6.0.0
Registration
await FirebaseAuth.instance
.createUserWithEmailAndPassword(
email: email,
password: password
);
Login
await FirebaseAuth.instance
.signInWithEmailAndPassword(
email: email,
password: password
);
Current User
User? user =
FirebaseAuth
.instance
.currentUser;
Logout
await FirebaseAuth
.instance
.signOut();
Firestore Database
Firestore Firebase ka NoSQL Cloud Database hai.
MongoDB ki tarah document-based database.
Structure
Firestore
↓
Collections
↓
DocumentsExample:
Users
↓
Rahul
Farmers
↓
Farmer001
Payments
↓
Payment123
Package
cloud_firestore: ^6.0.0
Save Data
FirebaseFirestore
.instance
.collection("users")
.add({
"name":"Rahul",
"mobile":"9876543210"
});
Read Data
final data =
await FirebaseFirestore
.instance
.collection("users")
.get();
Update Data
FirebaseFirestore
.instance
.collection("users")
.doc(id)
.update({
"name":"Amit"
});
Delete Data
FirebaseFirestore
.instance
.collection("users")
.doc(id)
.delete();
Real-Time Listener
Firestore ka sabse powerful feature.
Data change hote hi UI automatically update.
FirebaseFirestore.instance
.collection("users")
.snapshots();
Example Use Cases
Live Chat
Live Attendance
Live Dashboard
Live Orders
Live Vehicle Tracking
Firebase Cloud Functions
Cloud Functions server-side code run karne ke liye use hoti hain.
Backend likhne ki zarurat nahi padti.
Example
User Registered
↓
Cloud Function Trigger
↓
Welcome Email Send
Install
firebase init functions
Example Function
const functions =
require(
'firebase-functions'
);
exports.helloWorld =
functions.https.onRequest(
(req,res)=>{
res.send(
"Hello Firebase"
);
});
Common Uses
OTP Generation
Email Sending
Auto Reports
Data Processing
Notification Sending
Firebase Cloud Messaging (FCM)
FCM Push Notifications ke liye use hota hai.
Examples
WhatsApp Message Notification
Bank Alert
Order Delivered
Attendance Alert
Payment Received
Package
firebase_messaging: ^16.0.0
Request Permission
FirebaseMessaging messaging =
FirebaseMessaging.instance;
await messaging
.requestPermission();
Device Token
String? token =
await FirebaseMessaging
.instance
.getToken();
Listen Notification
FirebaseMessaging.onMessage
.listen((message){
print(
message.notification?.title
);
});
Notification Flow
Admin Panel
↓
Send Notification
↓
FCM Server
↓
Flutter App
↓
Notification Received
Sugar Cane Project Use Cases
Payment Released
Farmer Registration
Advice Approved
Meeting Reminder
Cane Survey Update
Firebase Analytics
Analytics user behavior track karta hai.
Google Analytics ka mobile version.
Package
firebase_analytics: ^12.0.0
Log Event
FirebaseAnalytics.instance
.logEvent(
name:"login_success"
);
Example Events
Login
Logout
Payment Screen Open
Farmer Added
Report Downloaded
Analytics Data
You can track:
Daily Users
Monthly Users
Most Opened Screen
App Usage Time
Country Wise Users
Crashlytics
Production app crashes track karta hai.
Package
firebase_crashlytics: ^5.0.0
Initialize
FlutterError.onError =
FirebaseCrashlytics
.instance
.recordFlutterFatalError;
Manual Error
try {
throw Exception(
"Testing Error"
);
}
catch(e){
FirebaseCrashlytics
.instance
.recordError(
e,
StackTrace.current
);
}
Crashlytics Benefits
Error Details
Stack Trace
Affected Users
App Version
Device Information
Firebase Storage
Files upload karne ke liye.
Examples
Profile Images
PDF Files
Videos
Documents
Farmer Photos
Package
firebase_storage: ^13.0.0
Upload Image
Reference ref =
FirebaseStorage
.instance
.ref()
.child("images")
.child("profile.jpg");
await ref.putFile(file);
Get Download URL
String url =
await ref.getDownloadURL();
Firebase Security Rules
Never keep database public.
Wrong
allow read, write:
if true;
Correct
allow read, write:
if request.auth
!= null;
Complete Firebase Architecture
Flutter App
↓
Firebase Auth
↓
Firestore
↓
Cloud Functions
↓
Firebase Storage
↓
FCM Notifications
↓
Analytics
↓
Crashlytics
Real Project Example
Employee Management
Login
↓
Firebase Auth
Employee Data
↓
Firestore
Profile Photo
↓
Storage
Notifications
↓
FCM
Analytics
↓
Firebase Analytics
Crash Reports
↓
Crashlytics
Firebase vs Node.js Backend
Feature Firebase Node.js Learning Easy Medium Setup Time Fast Medium Authentication Excellent Manual Database Firestore MongoDB/PostgreSQL Notifications Excellent Manual Analytics Built-in External Crash Reporting Built-in External Large Enterprise Projects Medium Excellent
Flutter Developer Learning Order
Week 1
- Firebase Setup
- Firebase Authentication
Week 2
- Firestore CRUD
- Real-Time Database
Week 3
- Firebase Storage
Week 4
- Cloud Messaging (FCM)
Week 5
- Cloud Functions
Week 6
- Analytics
Week 7
- Crashlytics
Week 8
- Security Rules
Production Recommendation
Aapke jaise Flutter Developer ke liye best stack:
Flutter
↓
Riverpod
↓
Firebase Auth
↓
Firestore
↓
Firebase Storage
↓
FCM
↓
Analytics
↓
CrashlyticsAur agar aap enterprise-level projects (Sugar Cane Management, ERP, CRM, Inventory, Attendance, HRMS) banana chahte hain to:
Flutter
↓
Firebase Auth
↓
Node.js + Express
↓
MongoDB Atlas/PostgreSQL
↓
FCM
↓
CrashlyticsPhase 7: Cloud Storage (Firebase Storage + AWS S3 Complete Guide)
Agar aap Full Stack Flutter Developer banna chahte hain, to Cloud Storage seekhna bahut zaroori hai. Database (MongoDB/PostgreSQL) sirf text data store karne ke liye hota hai, lekin images, PDFs, videos aur documents ko Cloud Storage me store kiya jata hai.
Examples:
- Profile Photo
- Aadhaar Card
- PAN Card
- Farmer Documents
- Sugar Cane Survey Photos
- Payment PDFs
- Invoice Files
- Training Videos
Cloud Storage Kya Hai?
Cloud Storage ek online storage system hai jahan aap files upload aur manage kar sakte ho.
Flow:
Flutter App
↓
Upload File
↓
Cloud Storage
↓
File URL
↓
Database Save
Wrong Approach
❌ Image ko MongoDB me save karna
❌ PDF ko PostgreSQL me save karna
❌ Video ko Database me save karna
Correct Approach
✅ File Cloud Storage me
✅ URL Database me
Example:
{
"farmerName":"Rahul",
"photoUrl":"https://storage.com/image.jpg"
}
Most Popular Cloud Storage Services
Firebase Storage
Google ka cloud storage.
Best for Flutter Developers.
AWS S3
Amazon ka cloud storage.
Industry Standard.
Firebase Storage
Firebase Storage Google Cloud Storage par based hai.
Benefits:
✅ Easy Setup
✅ Flutter Friendly
✅ Secure
✅ Fast
✅ Free Tier Available
Architecture
Flutter App
↓
Firebase Storage
↓
Download URL
↓
Firestore / MongoDB
Setup Firebase Storage
Package Install
firebase_storage: ^13.0.0
Import
import 'package:firebase_storage/firebase_storage.dart';
Create Reference
Reference ref =
FirebaseStorage.instance
.ref()
.child("images")
.child("profile.jpg");
Upload Image
await ref.putFile(file);
Complete Upload Example
Future<String> uploadImage(
File file) async {
Reference ref =
FirebaseStorage.instance
.ref()
.child("images")
.child(
DateTime.now()
.millisecondsSinceEpoch
.toString(),
);
await ref.putFile(file);
return await ref
.getDownloadURL();
}
Save URL
String imageUrl =
await uploadImage(file);
Store in Firestore
FirebaseFirestore.instance
.collection("users")
.add({
"name":"Rahul",
"imageUrl":imageUrl
});
Display Image
Image.network(
imageUrl
)
Upload PDF
Reference ref =
FirebaseStorage.instance
.ref()
.child("pdf")
.child("report.pdf");
await ref.putFile(file);
Upload Video
Reference ref =
FirebaseStorage.instance
.ref()
.child("videos")
.child("training.mp4");
await ref.putFile(file);
Delete File
await FirebaseStorage.instance
.refFromURL(url)
.delete();
List Files
ListResult result =
await FirebaseStorage.instance
.ref("images")
.listAll();
Folder Structure
Storage
│
├── images
│ ├── profile.jpg
│
│ ├── report.pdf
│
├── videos
│ ├── demo.mp4
│
└── documents
Security Rules
Wrong
allow read, write:
if true;Sab access kar sakte hain.
Correct
allow read, write:
if request.auth
!= null;Sirf logged-in users access karenge.
Firebase Storage Pricing
Free Tier Available:
5 GB Storage
1 GB Download/DaySmall Projects ke liye kaafi hota hai.
AWS S3 (Amazon Simple Storage Service)
AWS S3 duniya ka sabse popular cloud storage service hai.
Used By:
- Netflix
- Airbnb
- Dropbox
- Enterprise Applications
Benefits:
✅ Extremely Fast
✅ Highly Scalable
✅ Secure
✅ Cheap
✅ Industry Standard
AWS S3 Architecture
Flutter App
↓
Node.js Backend
↓
AWS S3
↓
File URL
↓
MongoDB/PostgreSQL
What is Bucket?
S3 me storage container ko Bucket kehte hain.
Example:
cms-storageInside:
cms-storage
│
├── images
├── pdfs
├── videos
└── documents
Install AWS SDK
Node.js:
npm install aws-sdk
Configure S3
const AWS =
require('aws-sdk');
const s3 =
new AWS.S3({
accessKeyId:
process.env.ACCESS_KEY,
secretAccessKey:
process.env.SECRET_KEY
});
Upload File
const params = {
Bucket:'cms-storage',
Key:'profile.jpg',
Body:fileBuffer
};
await s3.upload(
params
).promise();
Upload Response
{
"Location":
"https://bucket.s3.amazonaws.com/profile.jpg"
}
Save URL
MongoDB:
{
"name":"Rahul",
"imageUrl":
"https://bucket.s3.amazonaws.com/profile.jpg"
}
Generate Secure URL
const url =
s3.getSignedUrl(
'getObject',
{
Bucket:'cms-storage',
Key:'profile.jpg'
}
);Useful for:
- Private PDFs
- Salary Slips
- Farmer Documents
- Internal Reports
AWS S3 Security
Never:
public-readfor sensitive documents.
Use:
Private Bucketand Signed URLs.
Firebase Storage vs AWS S3
Feature Firebase Storage AWS S3 Setup Easy Medium Flutter Integration Excellent Good Free Tier Good Good Security Excellent Excellent Enterprise Usage Medium Excellent Learning Curve Easy Medium Scalability High Very High Cost Control Medium Excellent
Real Project Examples
Employee Management
Employee Photo
↓
Firebase Storage
Sugar Cane Management
Farmer Photo
Survey Image
Payment PDF
Advice Document
↓
AWS S3
E-Commerce
Product Images
↓
Firebase Storage
or
AWS S3
Learning App
Training Videos
PDF Notes
Assignments
↓
AWS S3
Recommended Folder Structure
storage
│
├── profile_images
│
├── farmer_photos
│
├── employee_photos
│
├── reports
│
├── invoices
│
├── documents
│
└── videos
Complete Upload Flow
Flutter App
↓
Image Picker
↓
Choose File
↓
Upload Storage
↓
Get URL
↓
Save URL Database
↓
Display Anywhere
Production Architecture
Small/Medium Flutter Apps
Flutter
↓
Firebase Auth
↓
Firestore
↓
Firebase Storage
Enterprise Projects
Flutter
↓
Node.js
↓
AWS S3
↓
MongoDB/PostgreSQL
Learning Sequence
Week 1
- Firebase Storage Setup
- Image Upload
Week 2
- PDF Upload
- Video Upload
Week 3
- File Delete
- File List
Week 4
- AWS S3 Basics
- Bucket Management
Week 5
- Upload API
- Signed URLs
Week 6
- Security Rules
- Access Control
Final Recommendation
Agar aap abhi Flutter Full Stack journey start kar rahe hain:
Flutter
↓
Firebase StoragePehle ye seekho kyunki setup bahut easy hai.
Uske baad:
Flutter
↓
Node.js
↓
AWS S3
↓
MongoDB/PostgreSQLPhase 8: Real-Time Features (WebSocket + Socket.IO Complete Guide)
Real-time features modern apps ka backbone hote hain. Aaj ke apps me data instant update hota hai bina refresh kiye.
Examples:
- WhatsApp Chat
- Live Tracking (Zomato / Ola)
- Stock Market Updates
- Online Gaming
- Live Notifications
- Delivery Tracking
- Sugar Cane Truck Tracking System
Real-Time Kya Hota Hai?
Normal API system:
Request → ResponseReal-time system:
Client ⇄ Server (Continuous Connection)Matlab connection open rehta hai.
WebSocket Kya Hai?
WebSocket ek protocol hai jo:
✅ Continuous connection banata hai
✅ Fast communication deta hai
✅ Low latency hota hai
❌ Repeated API calls nahi hote
WebSocket Flow
Flutter App
⇄
WebSocket Server
⇄
Backend Database
Socket.IO Kya Hai?
Socket.IO WebSocket ka advanced version hai.
Features:
- Auto reconnect
- Event based communication
- Room system (Chat rooms)
- Broadcasting
- Cross platform support
WebSocket vs Socket.IO
Feature WebSocket Socket.IO Speed Fast Fast Reliability Medium High Auto Reconnect ❌ ✅ Events Manual Built-in Rooms ❌ ✅ Production Use Good Excellent 👉 Industry me mostly Socket.IO use hota hai.
Chat System Architecture
Flutter App
↓
Socket Connection
↓
Node.js + Socket.IO
↓
Database (MongoDB/PostgreSQL)
↓
Other Users
Step 1: Backend (Node.js + Socket.IO)
Install
npm install socket.io express
Server Setup
const express = require("express");
const http = require("http");
const socketIo = require("socket.io");
const app = express();
const server = http.createServer(app);
const io = socketIo(server, {
cors: {
origin: "*"
}
});
io.on("connection", (socket) => {
console.log("User Connected:", socket.id);
socket.on("message", (data) => {
io.emit("message", data);
});
socket.on("disconnect", () => {
console.log("User Disconnected");
});
});
server.listen(3000);
Step 2: Flutter Socket.IO Setup
Package
socket_io_client: ^3.0.0
Connect Socket
import 'package:socket_io_client/socket_io_client.dart'
as IO;
late IO.Socket socket;
void connectSocket() {
socket = IO.io(
"http://YOUR_SERVER:3000",
IO.OptionBuilder()
.setTransports(['websocket'])
.build(),
);
socket.connect();
socket.onConnect((_) {
print("Connected");
});
}
Send Message
socket.emit("message", {
"user": "Rahul",
"message": "Hello"
});
Receive Message
socket.on("message", (data) {
print("New Message: $data");
});
Chat App Flow
User A → Message Send → Server → Broadcast → User B
Chat App Features
✔ Real-time messaging
✔ Online status
✔ Typing indicator
✔ Message delivery status
✔ Chat rooms
Typing Indicator Example
Backend
socket.on("typing", (data) => {
socket.broadcast.emit("typing", data);
});
Flutter
socket.emit("typing", {
"user": "Rahul"
});
Live Tracking System
Real-time apps ka most powerful use case.
Examples:
- Delivery Boy Tracking (Zomato)
- Cab Tracking (Ola/Uber)
- Truck Tracking (Sugar Cane Transport)
- Field Survey Tracking
Live Location Flow
GPS Device → Backend → Socket.IO → Flutter Map
Send Location (Backend)
socket.emit("location", {
lat: 28.61,
lng: 77.20
});
Flutter Receive
socket.on("location", (data) {
print(data);
});
Use Google Maps
Package:
google_maps_flutter: ^2.5.0
Real-Time Notification System
Socket-based notifications:
Admin Panel
↓
Socket Emit
↓
All Users
↓
Instant Notification
Backend Notification
io.emit("notification", {
title: "Payment Received",
message: "₹10,000 added"
});
Flutter Receive
socket.on("notification", (data) {
print(data);
});
Sugar Cane Project Use Case
✔ Farmer Payment Update
✔ Truck Live Location
✔ Field Survey Update
✔ Admin Notification
✔ Advice Approval Status
Advanced Features
1. Rooms (Group Chat)
socket.join("room1");
2. Private Messaging
socket.to(socketId).emit("message", data);
3. Broadcasting
io.emit("message", data);
WebSocket Use Cases
✔ Chat Apps
✔ Live Tracking
✔ Online Games
✔ Stock Market Apps
✔ Sports Live Score
✔ Delivery Apps
Interview Questions
Q1: WebSocket kya hai?
👉 Continuous connection protocol for real-time communication.
Q2: Socket.IO kya hai?
👉 WebSocket ka advanced version with extra features.
Q3: Real-time apps kaise kaam karti hain?
👉 Client-server persistent connection se data instantly exchange hota hai.
Best Practice Architecture
Flutter App
↓
Socket.IO Client
↓
Node.js Server
↓
MongoDB/PostgreSQL
↓
Redis (optional scaling)
Production Tips
✔ Always use authentication in sockets
✔ Use rooms for scalability
✔ Use Redis for large systems
✔ Handle reconnection properly
✔ Avoid too frequent emits
Learning Roadmap
Week 1
- WebSocket basics
- Socket.IO setup
Week 2
- Chat App development
Week 3
- Live Tracking system
Week 4
- Notification system
Week 5
- Rooms + Private chat
Week 6
- Production scaling
Final Recommendation
Agar aap Flutter Full Stack Developer banna chahte hain:
Flutter
↓
Node.js + Socket.IO
↓
MongoDB/PostgreSQL
↓
Firebase (Notifications/Auth optional)
↓
AWS DeploymentYe stack aapko real-world enterprise apps jaise:
- Chat App
- Delivery App
- ERP System
- Sugar Cane Tracking System
- Live Monitoring System
Phase 9: Advanced Backend (Professional Level Architecture Guide)
Jab aap basic backend (Node.js + Express + MongoDB/PostgreSQL) seekh lete ho, tab next step hota hai Advanced Backend Architecture.
Ye phase aapko “coder” se hata kar Software Engineer / System Architect bana deta hai.
Why Advanced Backend?
Simple backend:
Route → Logic → DatabaseProblem:
❌ Code messy ho jata hai
❌ Large project maintain nahi hota
❌ Team collaboration difficult
❌ Bugs increase hote hain
Solution: Architecture Patterns
Industry me 4 important concepts use hote hain:
- MVC Architecture
- Clean Architecture
- Repository Pattern
- Dependency Injection
- Microservices (Advanced Level)
1. MVC Architecture (Most Important Starting Point)
MVC = Model + View + Controller
Client → Controller → Model → Database
Model
Data structure define karta hai
const userSchema = new mongoose.Schema({
name: String,
email: String
});
Controller
Business logic hota hai
exports.createUser = async (req, res) => {
const user = await User.create(req.body);
res.json(user);
};
Route
API endpoint define karta hai
router.post("/users", userController.createUser);
MVC Flow
Request
↓
Route
↓
Controller
↓
Model
↓
Database
↓
Response
MVC Benefits
✔ Code organized
✔ Easy debugging
✔ Team friendly
✔ Scalable for medium apps
2. Clean Architecture (Industry Standard)
Clean Architecture ko Robert C. Martin (Uncle Bob) ne define kiya tha.
Core Idea
👉 Business logic kabhi framework pe depend nahi karta
Layers
Presentation Layer (Routes / API)
↓
Use Cases (Business Logic)
↓
Domain Layer (Entities)
↓
Data Layer (Database)
Example (Simple)
Domain (Entity)
class User {
constructor(name, email) {
this.name = name;
this.email = email;
}
}
Use Case
class CreateUser {
async execute(userRepo, data) {
return await userRepo.create(data);
}
}
Controller
const result = await createUser.execute(userRepo, req.body);
res.json(result);
Clean Architecture Benefits
✔ Highly scalable
✔ Testable code
✔ Framework independent
✔ Enterprise ready
3. Repository Pattern (Very Important)
Repository pattern ka use database logic ko isolate karne ke liye hota hai.
Problem Without Repository
Controller → Direct DB Access❌ Tight coupling
❌ Hard to test
❌ Hard to replace DB
With Repository Pattern
Controller → Service → Repository → Database
Example
Repository
class UserRepository {
async create(data) {
return await User.create(data);
}
async findAll() {
return await User.find();
}
}
Service
class UserService {
constructor(userRepo) {
this.userRepo = userRepo;
}
createUser(data) {
return this.userRepo.create(data);
}
}
Controller
const user = await userService.createUser(req.body);
res.json(user);
Benefits
✔ DB change easy (MongoDB → PostgreSQL)
✔ Testing easy
✔ Clean separation
✔ Scalable architecture
4. Dependency Injection (DI)
DI ka matlab hai:
👉 Objects ko khud create nahi karna, bahar se inject karna
Without DI
const service = new UserService();❌ Tight coupling
With DI
const service = new UserService(userRepository);
Real Example
function createUser(service) {
return service.createUser();
}
Benefits
✔ Easy testing (mock objects)
✔ Flexible code
✔ Loose coupling
✔ Better architecture
5. Microservices Architecture (Advanced Level)
Microservices = Large system ko small services me todna
Monolithic vs Microservices
Monolithic
App = One Big Backend❌ Hard to scale
❌ Hard to maintain
Microservices
User Service
Payment Service
Notification Service
Order Service
Example (E-commerce)
Flutter App
↓
API Gateway
↓
User Service
Order Service
Payment Service
Inventory Service
Communication
- REST APIs
- Message Queue (Kafka / RabbitMQ)
- gRPC (Advanced)
Benefits
✔ Highly scalable
✔ Independent deployment
✔ Fault isolation
✔ Large enterprise systems
Disadvantages
❌ Complex setup
❌ DevOps heavy
❌ Monitoring required
Architecture Comparison
Architecture Level Use Case MVC Beginner Small Apps Clean Architecture Advanced Large Apps Repository Pattern Professional Enterprise Apps Microservices Expert Big Systems
Recommended Learning Path
Step 1 (Must Learn First)
✔ MVC Architecture
Step 2
✔ Repository Pattern
Step 3
✔ Dependency Injection
Step 4
✔ Clean Architecture
Step 5 (Later)
✔ Microservices
Real Project Mapping (Your Sugar Cane System)
MVC → Basic APIs
Repository → Farmer/Payment Data Layer
Clean Architecture → Reports System
Microservices →
Farmer Service
Payment Service
Report Service
Notification Service
Industry Stack (2026 Recommendation)
Flutter
↓
Clean Architecture (Frontend)
↓
Node.js (Backend)
↓
Express.js
↓
Repository Pattern
↓
MongoDB / PostgreSQL
↓
Microservices (Scale)
↓
Docker + AWS
Final Summary
Agar aap Phase 9 master kar lete ho to aap:
✔ Junior Developer nahi rahoge
✔ Senior Backend Developer ban jaoge
✔ Enterprise level systems design kar sakoge
✔ Large ERP/CRM/Banking apps bana sakoge
Phase 10: DevOps Basics (Flutter Full Stack Developer ke liye Complete Guide)
DevOps ka matlab hota hai:
👉 Development + Operations
Simple language me:
Aap sirf app banana nahi, balki deploy, maintain aur scale karna bhi seekhte ho.
DevOps Kya Hai?
Developer Code likhta hai
↓
DevOps Code ko server par deploy karta hai
↓
Users app use karte hain
DevOps Kyu Zaroori Hai?
Agar aap Flutter + Backend Developer ho:
❌ Sirf coding se job complete nahi hoti
❌ App ko live kaise karna hai ye bhi aana chahiye
❌ Server crash handle karna hota hai
❌ Updates deploy karne hote hain
Phase 10 Topics
- Linux Commands
- Git & GitHub
- Docker
- Nginx
- CI/CD (GitHub Actions)
1. Linux Commands (Must Learn)
Almost 90% servers Linux par hote hain.
Basic Commands
Folder Navigation
pwd
ls
cd folder_name
Create Folder
mkdir project
Delete File
rm file.txt
Delete Folder
rm -rf folder_name
File Open
nano app.js
System Info
top
htop
Install Package
sudo apt install nodejs
Why Linux?
✔ Server friendly
✔ Fast
✔ Secure
✔ Industry standard
2. Git & GitHub (Version Control)
Git code tracking system hai.
Why Git?
Code loss → Backup required
Team work → Collaboration needed
Version history → Track changes
Git Flow
Code → Commit → Push → GitHub
Basic Commands
Initialize Repo
git init
Add Files
git add .
Commit
git commit -m "first commit"
Push
git push origin main
Clone Repo
git clone repo_url
Branching
git checkout -b feature-login
Why GitHub?
✔ Code backup
✔ Team collaboration
✔ Open source projects
✔ Portfolio building
3. Docker (Very Important Modern Tool)
Docker ka use app ko container me run karne ke liye hota hai.
Problem Without Docker
Local Machine → Works
Server → Error
Docker Solution
Same environment everywhere
Docker Concept
👉 Container = Mini server
Docker Flow
App Code
↓
Docker Image
↓
Docker Container
↓
Server Deployment
Dockerfile Example
FROM node:18
WORKDIR /app
COPY . .
RUN npm install
CMD ["node","server.js"]
Build Image
docker build -t myapp .
Run Container
docker run -p 3000:3000 myapp
Benefits
✔ Same environment everywhere
✔ Easy deployment
✔ Scalable apps
✔ Microservices friendly
4. Nginx (Web Server)
Nginx ek web server hai jo requests handle karta hai.
Use Case
User Request
↓
Nginx
↓
Backend Server
Why Nginx?
✔ Fast
✔ Load balancing
✔ Reverse proxy
✔ SSL handling
Reverse Proxy Example
Flutter App → Nginx → Node.js API
Basic Config
server {
listen 80;
location / {
proxy_pass http://localhost:3000;
}
}
Load Balancing
User → Nginx → Server 1
Server 2
Server 3
5. CI/CD (Continuous Integration / Deployment)
CI/CD modern DevOps ka most important part hai.
CI/CD Meaning
Term Meaning CI Code Auto Build/Test CD Auto Deploy
CI/CD Flow
Code Push → Build → Test → Deploy → Live App
GitHub Actions (Best Tool)
GitHub ka built-in CI/CD tool.
Example Workflow
name: Node CI
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node
uses: actions/setup-node@v3
with:
node-version: 18
- run: npm install
- run: npm test
Benefits
✔ Auto deployment
✔ No manual work
✔ Fast updates
✔ Production safety
Complete DevOps Architecture
Flutter App
↓
GitHub Repo
↓
GitHub Actions (CI/CD)
↓
Docker Container
↓
Nginx Server
↓
Node.js Backend
↓
Database (MongoDB/PostgreSQL)
Real Project Example (Sugar Cane System)
Flutter App
↓
GitHub Actions
↓
Docker Deployment
↓
Nginx Server
↓
Node.js API
↓
MongoDB Atlas
↓
Live System
DevOps Tools Summary
Tool Use Linux Server control Git Code versioning GitHub Code hosting Docker Containerization Nginx Web server GitHub Actions CI/CD
Learning Roadmap
Week 1
- Linux Commands
Week 2
- Git & GitHub
Week 3
- Docker Basics
Week 4
- Nginx Setup
Week 5
- CI/CD Pipelines
Week 6
- Project Deployment
Final Outcome (After Phase 10)
Aap ban jaoge:
✔ Full Stack Flutter Developer
✔ Backend Developer
✔ DevOps Beginner Engineer
✔ Production-ready Developer
Industry Stack (Final Level)
Flutter
↓
Node.js / Firebase
↓
MongoDB / PostgreSQL
↓
Docker
↓
Nginx
↓
GitHub Actions (CI/CD)
↓
AWS / Cloud DeploymentPhase 11: Cloud Deployment (AWS EC2 + VPS + DigitalOcean Complete Guide)
Ab tak aapne app banana seekh liya (Flutter + Backend + Database).
Ab next step hota hai:👉 App ko internet par live karna (Production Deployment)
Is phase ko DevOps ka real-world part bhi bolte hain.
Cloud Deployment Kya Hota Hai?
Cloud deployment ka matlab:
👉 Aapka backend server + database + files internet par publicly accessible ho jaye
Simple Flow
Flutter App
↓
Cloud Server (AWS / VPS)
↓
Backend API (Node.js)
↓
Database (MongoDB/PostgreSQL)
↓
Storage (S3 / Firebase)
1. AWS (Amazon Web Services)
AWS duniya ka sabse powerful cloud platform hai.
Official:
AWS Services (Important for Developers)
Service Use EC2 Server (Virtual Machine) S3 File Storage RDS SQL Database Lambda Serverless Functions CloudWatch Monitoring
2. AWS EC2 (Most Important)
EC2 = Virtual Linux Server
What is EC2?
👉 Cloud me ek computer jaisa server
EC2 Flow
Create Instance
↓
Linux Server
↓
Install Node.js
↓
Run Backend
↓
Public IP → App Access
Steps to Deploy Backend
Step 1: Create EC2 Instance
- Select Ubuntu
- Choose free tier (t2.micro)
Step 2: Connect Server (SSH)
ssh -i key.pem ubuntu@your-ip
Step 3: Install Node.js
sudo apt update
sudo apt install nodejs npm
Step 4: Upload Code
git clone your-repo
cd project
npm install
Step 5: Run Server
node server.js
Production Run (PM2)
npm install -g pm2
pm2 start server.js
Benefits of EC2
✔ Full control
✔ Scalable
✔ Production ready
✔ Industry standard
3. AWS S3 (File Storage)
AWS S3 = Cloud file storage system
Already Phase 7 me detail hai, but deployment perspective:
Use Cases
Images
Videos
Reports
Invoices
Flow
Flutter App
↓
Backend API
↓
S3 Bucket
↓
File URL → Database
Why S3?
✔ Highly scalable
✔ Secure
✔ Cheap
✔ Global access
4. VPS Hosting (Simple Alternative to AWS)
VPS = Virtual Private Server
What is VPS?
👉 A rented Linux server
Popular VPS Providers
- DigitalOcean
- Linode
- Vultr
- Hostinger VPS
5. DigitalOcean (Very Popular for Developers)
Official:
Why Developers Love DigitalOcean?
✔ Simple UI
✔ Easy deployment
✔ Cheap droplets
✔ Fast setup
✔ Beginner friendly
DigitalOcean Flow
Create Droplet
↓
Linux Server
↓
Deploy Node.js App
↓
Domain Connect
↓
Live API
Steps
Step 1: Create Droplet
- Ubuntu 22.04
- Choose plan ($4–$6)
Step 2: Login
ssh root@ip-address
Step 3: Install Node.js
apt update
apt install nodejs npm
Step 4: Deploy Code
git clone repo
cd project
npm install
node server.js
Step 5: Keep Alive (PM2)
pm2 start server.js
6. Domain + SSL Setup
Domain Example:
api.yourapp.com
SSL (HTTPS)
Use:
Let's Encrypt (Free SSL)
7. Reverse Proxy (Nginx)
Nginx server request handle karta hai.
Example
User → Nginx → Node.js Server
Nginx Config
server {
listen 80;
location / {
proxy_pass http://localhost:3000;
}
}
8. Production Architecture
Small Apps
Flutter
↓
Firebase / Node.js
↓
MongoDB Atlas
Enterprise Apps
Flutter App
↓
AWS EC2 / DigitalOcean
↓
Node.js Backend
↓
MongoDB / PostgreSQL
↓
AWS S3 Storage
↓
Nginx
9. AWS vs VPS vs DigitalOcean
Feature AWS EC2 VPS DigitalOcean Cost Medium Low Low Scalability Very High Medium Medium Easy Setup Medium Easy Very Easy Industry Use High Medium High Beginner Friendly No Yes Yes
10. Real Project Example (Sugar Cane System)
Flutter App
↓
API Gateway
↓
EC2 Server
↓
Node.js Backend
↓
MongoDB Atlas
↓
S3 Storage (Documents)
↓
Nginx (Routing)
↓
Live Production System
11. Deployment Tools
Tool Use EC2 Server hosting S3 File storage Nginx Reverse proxy PM2 Process manager GitHub Code deployment DigitalOcean VPS hosting
12. Learning Roadmap
Week 1
- AWS Basics
- EC2 Setup
Week 2
- Linux Server Management
- Node.js Deployment
Week 3
- DigitalOcean VPS
Week 4
- Nginx Configuration
Week 5
- Domain + SSL Setup
Week 6
- Production Deployment Project
Final Outcome (After Phase 11)
Aap ban jaoge:
✔ Production Flutter Developer
✔ Backend Deployment Expert
✔ Cloud Engineer Beginner
✔ Real-world App Host karne wale developer
Final Industry Stack (Complete System)
Flutter
↓
Node.js Backend
↓
MongoDB / PostgreSQL
↓
AWS EC2 / DigitalOcean
↓
AWS S3 Storage
↓
Nginx
↓
PM2
↓
GitHub CI/CD
↓
Live Production AppBest Tech Stack For Flutter Developer (2026)
Beginner to Intermediate
Flutter
↓
REST API
↓
Node.js
↓
Express.js
↓
MongoDB Atlas
Professional Production Stack
Flutter
↓
Riverpod
↓
Node.js
↓
Express.js
↓
MongoDB Atlas
↓
AWS
↓
Docker
Practice Projects
Beginner
- Login System
- Notes App
- Expense Tracker
- Student Management
Intermediate
- E-Commerce App
- Inventory Management
- Employee Attendance
- CRM System
Advanced
- Food Delivery App
- Hospital Management
- Sugar Mill Management System
- Real Time Chat App
6 Month Learning Plan
Month 1
- Dart Advanced
- API Integration
Month 2
- JavaScript
- Node.js Basics
Month 3
- Express.js
- MongoDB
Month 4
- Authentication
- JWT
- Firebase
Month 5
- AWS
- File Upload
- Deployment
Month 6
- Docker
- CI/CD
- Full Production Project
Blog by Rehan Khan | © 2026 LearnWithRehan. All Rights Reserved.
Follow me on GitHub: https://github.com/LearnWithRehan
YouTube: https://www.youtube.com/@Learnwithrehan86147/
Instagram: https://www.instagram.com/learnwithrehan86147/
Facebook: https://www.facebook.com/people/Learnwith-Rehan/61572192551355/LearnWithRehan 🚀
Comments
Post a Comment