Chalona API Framework
Un framework completo para desarrollo de aplicaciones Flutter con servicios en background, notificaciones, base de datos y comunicaciΓ³n en tiempo real.
π CaracterΓsticas
- β Servicios en Background - Ejecuta tareas en segundo plano
- β Notificaciones Locales - Sistema de notificaciones integrado
- β Base de Datos - Soporte para SQL Server, PostgreSQL y SQLite
- β WebSocket - ComunicaciΓ³n en tiempo real
- β Sesiones - Manejo de autenticaciΓ³n y sesiones
- β Storage - Almacenamiento local persistente
- β Generador de Servicios - Herramientas para generar servicios automΓ‘ticamente
ποΈ Estructura del Proyecto
api/
βββ lib/
β βββ core/ # Framework base
β β βββ db.dart # AbstracciΓ³n de base de datos
β β βββ http.dart # Cliente HTTP
β β βββ types.dart # Sistema de tipos
β β
β βββ ecf/ # FacturaciΓ³n ElectrΓ³nica
β β βββ dgii.dart # IntegraciΓ³n DGII
β β βββ ecf.dart # LΓ³gica de negocio
β β
β βββ services/ # Servicios adicionales
β
βββ docs/
β βββ core/ # DocumentaciΓ³n del framework
β βββ ecf/ # DocumentaciΓ³n de ECF
β βββ android/ # GuΓas de Android
β
βββ scripts/ # Scripts de utilidad
βββ android/ # Scripts especΓficos Android
π¦ InstalaciΓ³n
Agrega esto a tu pubspec.yaml
:
dependencies:
chalona_api: ^0.0.174
Luego ejecuta:
flutter pub get
π― Uso BΓ‘sico
1. Crear una AplicaciΓ³n Chalona
import 'package:chalona_api/android-components.dart';
class MiApp extends ChalonaAndroidApp<MiSession> {
MiApp() : super(
name: 'Mi App',
title: 'Mi AplicaciΓ³n',
host: 'https://mi-servidor.com',
session: MiSession.builder(),
routes: {
'/home': (context) => HomePage(),
},
);
}
final app = MiApp();
2. Crear un Servicio en Background
import 'package:chalona_api/core/service.dart';
@ChalonaMainService(
title: 'Mi Servicio',
description: 'Servicio que procesa datos en background',
)
class MiServicio extends ChalonaService {
@override
String get name => 'MiServicio';
@override
Future<void> start() async {
// Configurar callbacks
onStart(() {
notifyState(detail: 'Servicio iniciado');
});
// LΓ³gica del servicio
while (active) {
await procesarDatos();
await Future.delayed(Duration(seconds: 10));
}
}
Future<void> procesarDatos() async {
// Tu lΓ³gica aquΓ
notifyState(detail: 'Procesando datos...');
}
}
3. Generar Servicio AutomΓ‘ticamente
dart bin/generate_service.dart
4. Conectar con Base de Datos
// SQL Server
final db = ChalonaMSQLConnection(
host: 'mssql://user:pass@server:1433/database'
);
// PostgreSQL
final db = ChalonaPsqlConnection(
host: 'postgres://user:pass@server:5432/database'
);
// Ejecutar consulta
final result = await db.request('SELECT * FROM tabla');
5. ComunicaciΓ³n WebSocket
final socket = ChalonaSocketService();
// Escuchar eventos
socket.onNotifyState((data) {
print('Estado: ${data['detail']}');
});
// Enviar comandos
socket.start(); // Iniciar servicio
socket.stop(); // Detener servicio
ποΈ Arquitectura
βββββββββββββββββββββββββββββββββββββββ
β ChalonaApp β
βββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ ββββββββββββββββββββ
β β Session β β Background ββ
β β Management β β Service ββ
β βββββββββββββββ ββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ ββββββββββββββββββββ
β β Database β β WebSocket ββ
β β Connections β β Communication ββ
β βββββββββββββββ ββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββ€
β βββββββββββββββ ββββββββββββββββββββ
β βLocal Storageβ β Notifications ββ
β β System β β System ββ
β βββββββββββββββ ββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββ
π DocumentaciΓ³n Completa
π€ Contribuir
- Fork el proyecto
- Crea tu rama de feature (
git checkout -b feature/AmazingFeature
) - Commit tus cambios (
git commit -m 'Add some AmazingFeature'
) - Push a la rama (
git push origin feature/AmazingFeature
) - Abre un Pull Request
π Licencia
Este proyecto estΓ‘ bajo la Licencia MIT - ver el archivo LICENSE para detalles.
π Agradecimientos
- Flutter Team por el excelente framework
- Comunidad Dart por las librerΓas utilizadas
Desarrollado con β€οΈ por Tu Nombre
π οΈ Desarrollo
Prerrequisitos
- Flutter SDK β₯ 3.0.0
- Dart SDK β₯ 3.0.0
- Android Studio (para desarrollo Android)
ConfiguraciΓ³n del Entorno
- Instalar Flutter y Dart
- Configurar variables de entorno
- Instalar extensiones de IDE
Pruebas
# Ejecutar todas las pruebas
flutter test
# Ejecutar pruebas con cobertura
flutter test --coverage
π€ ContribuciΓ³n
- Fork el proyecto
- Crear una rama feature (
git checkout -b feature/amazing_feature
) - Commit los cambios (
git commit -m 'feat: Add amazing_feature'
) - Push a la rama (
git push origin feature/amazing_feature
) - Abrir un Pull Request
π Convenciones
Commits
Seguimos Conventional Commits:
feat:
Nueva funcionalidadfix:
CorrecciΓ³n de bugdocs:
Cambios en documentaciΓ³nrefactor:
RefactorizaciΓ³n de cΓ³digotest:
AΓ±adir o modificar tests
CΓ³digo
- Usar
dart format
antes de commit - Seguir Effective Dart
- Mantener cobertura de tests > 80%
π Soporte
Para soporte y consultas:
- Revisar la documentaciΓ³n
- Abrir un issue
- Contactar al equipo de desarrollo
VersiΓ³n: 1.0.0 Γltima actualizaciΓ³n: Diciembre 2024
Libraries
- android-components
- api-components
- app-components
- core/app
- core/arg
- core/core
- core/db
- core/defs
- core/event
- core/exception
- core/file
- core/file/file.base
- core/file/file.html
- core/file/file.io
- core/host
- core/http
- core/http.server
- core/msg
- core/msql
- core/notification/android.notifcation
- core/notification/notify
- core/number
- core/object
- core/p12
- core/psql
- core/search
- core/server
- core/service
- core/session
- core/signer
- core/socket/socket
- core/socket/socket.io
- core/socket/socket.web
- core/sqlite
- core/state
- core/storage
- core/storage/storage
- core/storage/storage.console
- core/storage/storage.flutter
- core/storage/storage.web
- core/table
- core/types
- core/util
- ecf-components
- ecf/dgii
- ecf/ecf
- ecf/http_signer
- forms/login.form
- merc/merc
- merc/tmerc
- server-components
- sistema/usuario