Skip to main content

feagi_api/v1/
mapping_dtos.rs

1// Copyright 2025 Neuraville Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4// Mapping (Connectome) DTOs for V1 API
5//
6// These DTOs must match Python FastAPI response structures exactly.
7
8use serde::{Deserialize, Serialize};
9use std::collections::HashMap;
10use utoipa::ToSchema;
11
12/// Mapping rule information
13#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
14#[schema(example = json!({
15    "src_cortical_area": "v1",
16    "dst_cortical_area": "v2",
17    "mapping_type": "one_to_many",
18    "mapping_data": {
19        "type": "topological",
20        "parameters": {}
21    }
22}))]
23pub struct MappingInfo {
24    /// Source cortical area ID
25    pub src_cortical_area: String,
26
27    /// Destination cortical area ID
28    pub dst_cortical_area: String,
29
30    /// Mapping type (e.g., "one_to_one", "one_to_many", "topological")
31    pub mapping_type: String,
32
33    /// Mapping configuration data
34    pub mapping_data: serde_json::Value,
35}
36
37/// Create mapping request
38#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
39pub struct CreateMappingRequest {
40    /// Source cortical area ID
41    pub src_cortical_area: String,
42
43    /// Destination cortical area ID
44    pub dst_cortical_area: String,
45
46    /// Mapping type
47    pub mapping_type: String,
48
49    /// Optional: Mapping configuration data
50    #[serde(default)]
51    pub mapping_data: Option<serde_json::Value>,
52}
53
54/// List mappings response
55#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
56pub struct MappingListResponse {
57    /// List of all mappings
58    pub mappings: Vec<MappingInfo>,
59
60    /// Total count
61    pub total_count: usize,
62}
63
64/// Synapse statistics
65#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
66#[schema(example = json!({
67    "cortical_area_id": "v1",
68    "total_synapses": 1000000,
69    "active_synapses": 45000,
70    "inactive_synapses": 955000,
71    "total_neurons": 10000
72}))]
73pub struct SynapseStats {
74    /// Cortical area ID
75    pub cortical_area_id: String,
76
77    /// Total number of synapses
78    pub total_synapses: usize,
79
80    /// Number of active synapses
81    pub active_synapses: usize,
82
83    /// Number of inactive synapses
84    pub inactive_synapses: usize,
85
86    /// Total neurons in the area
87    pub total_neurons: usize,
88}
89
90/// Connectome statistics response
91#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
92pub struct ConnectomeStatsResponse {
93    /// Total number of cortical areas
94    pub total_cortical_areas: usize,
95
96    /// Total number of mappings
97    pub total_mappings: usize,
98
99    /// Total number of synapses across all areas
100    pub total_synapses: usize,
101
102    /// Per-area synapse statistics
103    pub per_area_stats: HashMap<String, SynapseStats>,
104}