use gigabrain::Graph; use gigabrain::cypher::parse_cypher; use gigabrain::storage::MemoryStore; use gigabrain::server::{ApiServer, ServerConfig}; use tracing::{info, warn}; use tracing_subscriber; #[tokio::main] async fn main() -> Result<(), Box> { tracing_subscriber::fmt() .with_max_level(tracing::Level::INFO) .init(); info!("Starting GigaBrain Graph Database"); let graph = std::sync::Arc::new(Graph::new()); { let mut schema = graph.schema().write(); let _person_label = schema.get_or_create_label("Person"); let _name_prop = schema.get_or_create_property_key("name"); let _age_prop = schema.get_or_create_property_key("age"); let knows_rel = schema.get_or_create_relationship_type("KNOWS"); drop(schema); let alice = graph.create_node(); let bob = graph.create_node(); let charlie = graph.create_node(); graph.create_relationship(alice, bob, knows_rel)?; graph.create_relationship(bob, charlie, knows_rel)?; } info!("Created sample graph with 3 nodes and 2 relationships"); let query = "MATCH (n:Person)-[:KNOWS]->(m) RETURN n, m"; match parse_cypher(query) { Ok(parsed) => { info!("Successfully parsed Cypher query: {:?}", parsed); // Execute the query let executor = gigabrain::cypher::QueryExecutor::new(graph.clone()); match executor.execute_query(&parsed).await { Ok(result) => { info!("Query executed successfully!"); info!("Columns: {:?}", result.columns); info!("Rows: {} returned", result.rows.len()); for (i, row) in result.rows.iter().enumerate() { info!("Row {}: {:?}", i, row.values); } } Err(e) => { warn!("Failed to execute query: {}", e); } } } Err(e) => { warn!("Failed to parse Cypher query: {}", e); } } let _storage = MemoryStore::new(); info!("Initialized persistent storage"); info!("GigaBrain Graph Database started successfully!"); // Start the API server let config = ServerConfig::default(); let server = ApiServer::new(graph, config); info!("Starting API servers..."); info!("REST API will be available at: http://localhost:3000"); info!("gRPC API will be available at: http://localhost:50051"); info!("API documentation: http://localhost:3000/api/v1/docs"); // This will run indefinitely serving requests server.start().await?; Ok(()) }