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

  1. Fork el proyecto
  2. Crea tu rama de feature (git checkout -b feature/AmazingFeature)
  3. Commit tus cambios (git commit -m 'Add some AmazingFeature')
  4. Push a la rama (git push origin feature/AmazingFeature)
  5. 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

  1. Instalar Flutter y Dart
  2. Configurar variables de entorno
  3. Instalar extensiones de IDE

Pruebas

# Ejecutar todas las pruebas
flutter test

# Ejecutar pruebas con cobertura
flutter test --coverage

🀝 Contribución

  1. Fork el proyecto
  2. Crear una rama feature (git checkout -b feature/amazing_feature)
  3. Commit los cambios (git commit -m 'feat: Add amazing_feature')
  4. Push a la rama (git push origin feature/amazing_feature)
  5. Abrir un Pull Request

πŸ“ Convenciones

Commits

Seguimos Conventional Commits:

  • feat: Nueva funcionalidad
  • fix: CorrecciΓ³n de bug
  • docs: Cambios en documentaciΓ³n
  • refactor: RefactorizaciΓ³n de cΓ³digo
  • test: 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:

  1. Revisar la documentaciΓ³n
  2. Abrir un issue
  3. Contactar al equipo de desarrollo

Versión: 1.0.0 Última actualización: Diciembre 2024