Skip to content

Commit 0b4a23d

Browse files
fix(all): Organizing APIs and docs.
1 parent 2ce7d2e commit 0b4a23d

File tree

10 files changed

+453
-292
lines changed

10 files changed

+453
-292
lines changed

Cargo.lock

Lines changed: 117 additions & 280 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ members = [
44
"gb-core", # Core domain models and traits
55
"gb-api", # API layer and server implementation
66
"gb-media", # Media processing and WebRTC handling
7+
78
"gb-messaging", # Message queue and real-time communication
89
"gb-storage", # Database and storage implementations
910
"gb-monitoring", # Metrics, logging and monitoring

README.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,23 @@ Licensed under terms specified in workspace configuration.
265265
- Annual penetration testing
266266
- Bi-annual disaster recovery testing
267267

268-
---
268+
269+
### **Key Open Source Tools in Rust/Go**:
270+
1. **Zitadel (Go)**: Identity and access management for secure authentication.
271+
2. **Stalwart (Rust)**: Secure email server for threat detection.
272+
3. **MinIO (Go)**: High-performance object storage for unstructured data.
273+
4. **Ubuntu Advantage (Go/Rust tools)**: Compliance and security tools for Ubuntu.
274+
5. **Tantivy (Rust)**: Full-text search engine for data discovery.
275+
6. **Drone (Go)**: CI/CD platform for DevOps automation.
276+
7. **Temporal (Go)**: Workflow orchestration engine.
277+
8. **Caddy (Go)**: Web server for seamless customer experiences.
278+
9. **SeaweedFS (Go)**: Distributed file system for secure file sharing.
279+
10. **Vector (Rust)**: Observability pipeline for monitoring.
280+
11. **Tyk (Go)**: API gateway for secure API management.
281+
12. **Vault (Go)**: Secrets management and encryption.
282+
13. **Hugging Face Transformers (Rust/Go bindings)**: LLM integration and fine-tuning.
283+
14. **Kubernetes (Go)**: Container orchestration for scalable deployments.
284+
15. **Matrix (Rust)**: Real-time communication and collaboration.
285+
269286

270287
Built with ❤️ from Brazil, using Rust for maximum performance and reliability.

gb-api/src/main.rs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,17 @@ use tracing::{info, error};
33
use std::net::SocketAddr;
44
use gb_messaging::MessageProcessor;
55

6+
7+
#[allow(dead_code)]
8+
#[derive(Clone)]
9+
struct AppState {
10+
db: sqlx::PgPool,
11+
redis: redis::Client,
12+
message_processor: MessageProcessor,
13+
customer: PostgresCustomerRepository,
14+
15+
}
16+
617
#[tokio::main]
718
async fn main() -> Result<()> {
819
// Initialize logging first
@@ -20,9 +31,12 @@ async fn initialize_bot_server() -> Result<axum::Router> {
2031

2132
// Initialize the MessageProcessor
2233
let message_processor = MessageProcessor::new();
23-
34+
let state = AppState::new();
35+
state.repo = PostgresCustomerRepository::new(Arc::new(pool));
36+
37+
2438
// Build the Axum router using our router module
25-
let app = gb_api::create_router(message_processor)
39+
let app = gb_api::create_router(state)
2640
.layer(tower_http::trace::TraceLayer::new_for_http());
2741

2842
Ok(app)
@@ -61,12 +75,6 @@ async fn initialize_redis() -> Result<redis::Client> {
6175
.map_err(|e| Error::internal(e.to_string()))
6276
}
6377

64-
#[allow(dead_code)]
65-
#[derive(Clone)]
66-
struct AppState {
67-
db: sqlx::PgPool,
68-
redis: redis::Client,
69-
}
7078

7179

7280
async fn start_server(app: axum::Router) -> Result<()> {

gb-calendar/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "gb-calendar"
3+
version = { workspace = true }
4+
edition = { workspace = true }
5+
authors = { workspace = true }
6+
license = { workspace = true }
7+
8+
[dependencies]
9+
gb-core = { path = "../gb-core" }
10+
async-trait= { workspace = true }
11+
tokio= { workspace = true }
12+
serde = { version = "1.0", features = ["derive"] }
13+
serde_json = "1.0"thiserror= { workspace = true }
14+
tracing= { workspace = true }
15+
minio-rs = "0.1"
16+
17+
[dev-dependencies]
18+
rstest= { workspace = true }
19+
tokio-test = "0.4"
20+
tempfile = "3.8"
File renamed without changes.

gb-file/Cargo.toml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "gb-document"
2+
name = "gb-file"
33
version = { workspace = true }
44
edition = { workspace = true }
55
authors = { workspace = true }
@@ -10,9 +10,10 @@ gb-core = { path = "../gb-core" }
1010
async-trait= { workspace = true }
1111
tokio= { workspace = true }
1212
serde = { version = "1.0", features = ["derive"] }
13-
serde_json = "1.0"thiserror= { workspace = true }
13+
serde_json = "1.0"
14+
thiserror= { workspace = true }
1415
tracing= { workspace = true }
15-
minio-rs = "0.1"
16+
minio = "0.1.0"
1617

1718
[dev-dependencies]
1819
rstest= { workspace = true }

gb-file/src/lib.rs

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
use minio::s3::client::Client;
2+
use minio::s3::args::{BucketExistsArgs, MakeBucketArgs, RemoveObjectArgs, GetObjectArgs, PutObjectArgs, ListObjectsArgs};
3+
use minio::s3::creds::StaticProvider;
4+
use minio::s3::error::Error as MinioError;
5+
use minio::s3::types::{BaseUrl, Item};
6+
use std::io::Cursor;
7+
use std::path::Path;
8+
9+
pub struct FileManager {
10+
client: Client,
11+
bucket_name: String,
12+
}
13+
14+
impl FileManager {
15+
pub async fn new(endpoint: &str, access_key: &str, secret_key: &str, bucket_name: &str, use_ssl: bool) -> Result<Self, MinioError> {
16+
// Create BaseUrl from endpoint
17+
let base_url = BaseUrl::from_string(endpoint)?;
18+
let static_provider = StaticProvider::new(
19+
access_key,
20+
secret_key,
21+
None,
22+
);
23+
let client = Client::new(base_url.clone(), Some(Box::new(static_provider)), None, None).unwrap();
24+
25+
26+
Ok(Self {
27+
client,
28+
bucket_name: bucket_name.to_string(),
29+
})
30+
}
31+
32+
pub async fn ensure_bucket_exists(&self) -> Result<(), MinioError> {
33+
let exists = self.client
34+
.bucket_exists(&BucketExistsArgs::new(&self.bucket_name)?)
35+
.await?;
36+
if !exists {
37+
self.client
38+
.make_bucket(&MakeBucketArgs::new(&self.bucket_name)?)
39+
.await?;
40+
}
41+
Ok(())
42+
}
43+
44+
pub async fn upload_file(&self, path: &str, file_data: Vec<u8>) -> Result<(), MinioError> {
45+
let reader = Cursor::new(&file_data);
46+
let file_size = file_data.len() as u64;
47+
48+
let args = PutObjectArgs::new(
49+
&self.bucket_name,
50+
path,
51+
reader,
52+
Some(file_size),
53+
None
54+
)?;
55+
56+
self.client.put_object(&args).await?;
57+
Ok(())
58+
}
59+
60+
pub async fn download_file(&self, path: &str) -> Result<Vec<u8>, MinioError> {
61+
let args = GetObjectArgs::new(&self.bucket_name, path)?;
62+
let object = self.client.get_object(&args).await?;
63+
let data = object.bytes().await?;
64+
Ok(data.to_vec())
65+
}
66+
67+
pub async fn copy_file(&self, source_path: &str, destination_path: &str) -> Result<(), MinioError> {
68+
// Download the source file
69+
let data = self.download_file(source_path).await?;
70+
71+
// Upload it to the destination
72+
let reader = Cursor::new(&data);
73+
let file_size = data.len() as u64;
74+
75+
let args = PutObjectArgs::new(
76+
&self.bucket_name,
77+
destination_path,
78+
reader,
79+
Some(file_size),
80+
None
81+
)?;
82+
83+
self.client.put_object(&args).await?;
84+
Ok(())
85+
}
86+
87+
pub async fn move_file(&self, source_path: &str, destination_path: &str) -> Result<(), MinioError> {
88+
self.copy_file(source_path, destination_path).await?;
89+
self.delete_file(source_path).await?;
90+
Ok(())
91+
}
92+
93+
pub async fn delete_file(&self, path: &str) -> Result<(), MinioError> {
94+
let args = RemoveObjectArgs::new(&self.bucket_name, path)?;
95+
self.client.remove_object(&args).await?;
96+
Ok(())
97+
}
98+
99+
pub async fn list_files(&self, prefix: &str) -> Result<Vec<String>, MinioError> {
100+
// Create a predicate function that always returns true
101+
let predicate = |_: Vec<Item>| -> bool { true };
102+
103+
let args = ListObjectsArgs::new(&self.bucket_name, &predicate)?;
104+
let objects = self.client.list_objects(&args).await?;
105+
106+
// Filter objects based on prefix manually
107+
let file_names: Vec<String> = objects
108+
.into_iter()
109+
.filter(|obj| obj.name().starts_with(prefix))
110+
.map(|obj| obj.name().to_string())
111+
.collect();
112+
113+
Ok(file_names)
114+
}
115+
116+
pub async fn get_file_contents(&self, path: &str) -> Result<String, MinioError> {
117+
let data = self.download_file(path).await?;
118+
let contents = String::from_utf8(data)
119+
.map_err(|_| MinioError::InvalidResponse(400, "Invalid UTF-8 sequence".to_string()))?;
120+
Ok(contents)
121+
}
122+
123+
pub async fn create_folder(&self, path: &str) -> Result<(), MinioError> {
124+
let folder_path = if path.ends_with('/') {
125+
path.to_string()
126+
} else {
127+
format!("{}/", path)
128+
};
129+
130+
// Create empty file with folder path
131+
self.upload_file(&folder_path, vec![]).await
132+
}
133+
134+
pub async fn share_folder(&self, path: &str) -> Result<String, MinioError> {
135+
// This is just a placeholder implementation
136+
Ok(format!("Folder shared: {}", path))
137+
}
138+
139+
pub async fn search_files(&self, prefix: &str, query: &str) -> Result<Vec<String>, MinioError> {
140+
let files = self.list_files(prefix).await?;
141+
let results = files.into_iter().filter(|f| f.contains(query)).collect();
142+
Ok(results)
143+
}
144+
}

gb-llm/Cargo.toml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
[package]
2+
name = "gb-llm"
3+
version = { workspace = true }
4+
edition = { workspace = true }
5+
authors = { workspace = true }
6+
license = { workspace = true }
7+
8+
[dependencies]
9+
gb-core = { path = "../gb-core" }
10+
async-trait= { workspace = true }
11+
tokio= { workspace = true }
12+
serde = { version = "1.0", features = ["derive"] }
13+
serde_json = "1.0"thiserror= { workspace = true }
14+
tracing= { workspace = true }
15+
minio-rs = "0.1"
16+
17+
[dev-dependencies]
18+
rstest= { workspace = true }
19+
tokio-test = "0.4"
20+
tempfile = "3.8"

0 commit comments

Comments
 (0)