Skip to content

Commit

Permalink
init: 26 - prompts
Browse files Browse the repository at this point in the history
  • Loading branch information
iamfiscus committed Nov 13, 2024
1 parent 5289fe3 commit b06da40
Show file tree
Hide file tree
Showing 3 changed files with 463 additions and 0 deletions.
80 changes: 80 additions & 0 deletions instructions/context-project-structure.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
```
tree -d -I 'node_modules|bin|build|android|ios' | pbcopy
```

.
├── art
│   └── undraw
│   └── png
├── assets
│   ├── audio
│   │   ├── music
│   │   └── sfx
│   └── images
│   ├── app
│   ├── platform
│   └── undraw
├── instructions
├── lib
│   ├── app
│   │   ├── extensions
│   │   ├── models
│   │   ├── modules
│   │   │   ├── diary
│   │   │   │   ├── bindings
│   │   │   │   ├── controllers
│   │   │   │   ├── views
│   │   │   │   │   ├── activity
│   │   │   │   │   │   └── widgets
│   │   │   │   │   ├── food
│   │   │   │   │   │   └── scanner
│   │   │   │   │   ├── water
│   │   │   │   │   └── weight
│   │   │   │   └── widgets
│   │   │   ├── home
│   │   │   │   ├── bindings
│   │   │   │   ├── controllers
│   │   │   │   └── views
│   │   │   ├── intro
│   │   │   │   ├── bindings
│   │   │   │   ├── controllers
│   │   │   │   └── views
│   │   │   │   └── widgets
│   │   │   ├── login
│   │   │   │   ├── bindings
│   │   │   │   ├── controllers
│   │   │   │   └── views
│   │   │   │   └── widgets
│   │   │   ├── profile
│   │   │   │   ├── bindings
│   │   │   │   ├── controllers
│   │   │   │   └── views
│   │   │   ├── track
│   │   │   │   ├── bindings
│   │   │   │   ├── controllers
│   │   │   │   └── views
│   │   │   ├── update
│   │   │   │   ├── bindings
│   │   │   │   ├── controllers
│   │   │   │   └── views
│   │   │   └── zone
│   │   │   ├── bindings
│   │   │   ├── controllers
│   │   │   └── views
│   │   ├── routes
│   │   ├── services
│   │   │   └── persistence
│   │   ├── style
│   │   ├── utils
│   │   └── widgets
│   │   └── skinner
│   │   ├── fluid_nav_bar
│   │   ├── math
│   │   ├── physics
│   │   └── ui
│   │   └── placeholder
│   └── gen
└── test
└── helper

74 directories
172 changes: 172 additions & 0 deletions instructions/new-feature.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
# Feature Development Guide

## Initial Setup

- Create feature branch: `feature/[name]`
- Verify Firebase config in firebase.json
- Follow existing patterns for consistency

## Backend Development

### Firestore Service

Add new methods to firebase_service.dart following pattern:

```
Future<void> saveData(String id, Map<String, dynamic> data) async {
try {
await _db.collection('collection').doc(id).set(data);
logger.i('Data saved successfully');
} catch (e) {
logger.e('Error saving data: $e');
rethrow;
}
}
```

### Models

Create models in lib/app/models/ with:

- Required fields as final
- Factory constructors for JSON
- Clean serialization methods

```
class MyModel {
final String id;
final String name;
MyModel({required this.id, required this.name});
factory MyModel.fromJson(Map<String, dynamic> json) {
return MyModel(
id: json['id'] as String,
name: json['name'] as String,
);
}
Map<String, dynamic> toJson() {
return {
'id': id,
'name': name,
};
}
}
```

## Frontend Development

### Controllers

Use GetX controllers with:

- Observable (.obs) variables
- Clean error handling
- Service injection

```
class MyController extends GetxController {
final service = Get.find<MyService>();
final data = <MyModel>[].obs;
Future<void> loadData() async {
try {
data.value = await service.getData();
} catch (e) {
logger.e('Error: $e');
}
}
}
```

### Views

Create views with:

- GetView<Controller> base class
- Responsive layouts
- Proper state management

```
class MyView extends GetView<MyController> {
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Obx(() {
if (controller.data.isEmpty) {
return LoadingWidget();
} else {
return ListView.builder(
itemCount: controller.data.length,
itemBuilder: (context, index) {
final item = controller.data[index];
return ListTile(
title: Text(item.name),
);
},
);
}
}),
),
);
}
}
```

### UI Components

Build reusable widgets:

- Extract common UI patterns
- Use composition over inheritance
- Follow material design

```
class MyWidget extends StatelessWidget {
final String title;
final VoidCallback onTap;
Widget build(BuildContext context) {
return Card(
child: ListTile(
title: Text(title),
onTap: onTap,
),
);
}
}
```

## Testing

Write tests for:

- Models
- Controllers
- Services
- Widget behavior

```
test('should load data', () async {
final controller = MyController();
await controller.loadData();
expect(controller.data.length, greaterThan(0));
});
```

## Key Directories

- lib/app/modules/[feature]/views/ - UI components
- lib/app/modules/[feature]/controllers/ - Business logic
- lib/app/services/ - External services
- lib/app/models/ - Data models
- test/ - Test files

## Build & Deploy

- Use make mobile for builds
- Use make test for testing
- Monitor Firebase Crashlytics
- Keep documentation updated
Loading

0 comments on commit b06da40

Please sign in to comment.