Skip to main content

feagi_api/v1/
neuron_dtos.rs

1// Copyright 2025 Neuraville Inc.
2// SPDX-License-Identifier: Apache-2.0
3
4// Neuron DTOs for V1 API
5//
6// These DTOs must match Python FastAPI response structures exactly.
7
8use serde::{Deserialize, Serialize};
9use utoipa::ToSchema;
10
11/// Neuron information
12#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
13#[schema(example = json!({
14    "neuron_id": 12345,
15    "cortical_area": "v1",
16    "coordinates": [10, 15, 2],
17    "membrane_potential": -70.0,
18    "is_firing": false,
19    "synaptic_inputs": 120,
20    "synaptic_outputs": 85
21}))]
22pub struct NeuronInfoResponse {
23    /// Global neuron ID
24    pub neuron_id: u64,
25
26    /// Cortical area this neuron belongs to
27    pub cortical_area: String,
28
29    /// 3D coordinates within the cortical area [x, y, z]
30    pub coordinates: [u32; 3],
31
32    /// Current membrane potential (mV)
33    pub membrane_potential: f32,
34
35    /// Whether the neuron is currently firing
36    pub is_firing: bool,
37
38    /// Number of incoming synapses
39    pub synaptic_inputs: usize,
40
41    /// Number of outgoing synapses
42    pub synaptic_outputs: usize,
43}
44
45/// Create neuron request
46#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
47pub struct CreateNeuronRequest {
48    /// Cortical area ID
49    pub cortical_area: String,
50
51    /// 3D coordinates within the cortical area [x, y, z]
52    pub coordinates: [u32; 3],
53}
54
55/// List neurons response
56#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
57pub struct NeuronListResponse {
58    /// List of neurons
59    pub neurons: Vec<NeuronInfoResponse>,
60
61    /// Total count
62    pub total_count: usize,
63
64    /// Cortical area (if filtered by area)
65    #[serde(skip_serializing_if = "Option::is_none")]
66    pub cortical_area: Option<String>,
67}
68
69/// Neuron count response
70#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
71pub struct NeuronCountResponse {
72    /// Cortical area ID
73    pub cortical_area: String,
74
75    /// Number of neurons in the area
76    pub neuron_count: usize,
77}