Initial commit: NutriApp - Rust + Axum + Dioxus - CI/CD con Gitea Runner

This commit is contained in:
2026-06-24 08:35:09 +01:00
commit bede2018a6
35 changed files with 829 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
[package]
name = "shared"
version = "0.1.0"
edition = "2024"
[dependencies]
serde = { workspace = true }
uuid = { workspace = true }
chrono = { workspace = true }
+96
View File
@@ -0,0 +1,96 @@
use chrono::NaiveDate;
use serde::{Deserialize, Serialize};
use uuid::Uuid;
/// Tipos compartidos entre backend y frontend (Dioxus).
/// Ambos crates dependen de `shared`.
// ─── Enums ────────────────────────────────────────────────────
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum TipoComida {
Desayuno,
Comida,
Cena,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum UnidadMedida {
Gramos,
Mililitros,
Unidad,
Cucharada,
Cucharadita,
Taza,
Pizca,
AlGusto,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub enum CategoriaIngrediente {
Verdura,
Fruta,
Proteina,
Lacteo,
Cereal,
Legumbre,
Bebida,
Snack,
Condimento,
Otro,
}
// ─── DTOs ─────────────────────────────────────────────────────
/// Receta con sus ingredientes
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RecetaDto {
pub id: Uuid,
pub nombre: String,
pub descripcion: Option<String>,
pub porciones: i32,
pub tiempo_preparacion_min: Option<i32>,
pub instrucciones: Option<String>,
pub imagen_url: Option<String>,
pub ingredientes: Vec<IngredienteRecetaDto>,
}
/// Cantidad de un ingrediente en una receta
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct IngredienteRecetaDto {
pub ingrediente_id: Uuid,
pub nombre: String,
pub cantidad: f64,
pub unidad: UnidadMedida,
pub categoria: CategoriaIngrediente,
}
/// Un platillo asignado a un slot del calendario
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SlotComidaDto {
pub id: Uuid,
pub fecha: NaiveDate,
pub tipo: TipoComida,
pub receta_id: Uuid,
pub receta_nombre: String,
pub porciones: i32,
}
/// Solicitud de lista de compras
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ListaCompraRequest {
pub familia_id: Uuid,
pub desde: NaiveDate,
pub hasta: NaiveDate,
}
/// Item de la lista de compras
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ItemCompraDto {
pub ingrediente_id: Uuid,
pub nombre: String,
pub cantidad_total: f64,
pub unidad: UnidadMedida,
pub categoria: CategoriaIngrediente,
pub en_inventario: bool,
}