Skip to content

Commit 0f773df

Browse files
committed
initial commit
0 parents  commit 0f773df

File tree

3,810 files changed

+54792
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,810 files changed

+54792
-0
lines changed

.env.example

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Fula Gateway Configuration
2+
# Copy this file to .env and customize
3+
4+
# ============================================
5+
# Gateway Settings
6+
# ============================================
7+
8+
# Host and port to bind
9+
FULA_HOST=0.0.0.0
10+
FULA_PORT=9000
11+
12+
# Debug logging
13+
FULA_DEBUG=false
14+
15+
# Disable authentication (DEVELOPMENT ONLY!)
16+
FULA_NO_AUTH=false
17+
18+
# ============================================
19+
# IPFS Settings
20+
# ============================================
21+
22+
# IPFS API URL
23+
IPFS_API_URL=http://localhost:5001
24+
25+
# IPFS Cluster API URL
26+
CLUSTER_API_URL=http://localhost:9094
27+
28+
# ============================================
29+
# Authentication
30+
# ============================================
31+
32+
# JWT secret for token validation (generate a strong random string)
33+
JWT_SECRET=your-secret-key-here-change-in-production
34+
35+
# OAuth 2.0 settings (optional)
36+
# OAUTH_ISSUER=https://your-oauth-provider.com
37+
# OAUTH_AUDIENCE=fula-storage
38+
39+
# ============================================
40+
# Rate Limiting
41+
# ============================================
42+
43+
# Requests per second per user
44+
RATE_LIMIT_RPS=100
45+
46+
# ============================================
47+
# Storage Limits
48+
# ============================================
49+
50+
# Maximum single upload size (5GB)
51+
MAX_UPLOAD_SIZE=5368709120
52+
53+
# Multipart chunk size (8MB)
54+
MULTIPART_CHUNK_SIZE=8388608
55+
56+
# Multipart upload expiry (24 hours)
57+
MULTIPART_EXPIRY_SECS=86400
58+
59+
# ============================================
60+
# IPFS Cluster Settings
61+
# ============================================
62+
63+
# Cluster secret (generate with: od -vN 32 -An -tx1 /dev/urandom | tr -d ' \n')
64+
CLUSTER_SECRET=
65+
66+
# Replication settings
67+
REPLICATION_FACTOR_MIN=2
68+
REPLICATION_FACTOR_MAX=3
69+
70+
# ============================================
71+
# Monitoring (optional)
72+
# ============================================
73+
74+
# Grafana admin password
75+
GRAFANA_PASSWORD=admin
76+
77+
# ============================================
78+
# Logging
79+
# ============================================
80+
81+
# Rust log level (error, warn, info, debug, trace)
82+
RUST_LOG=info,fula_cli=debug,tower_http=debug

CONTRIBUTING.md

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
# Contributing to Fula Storage API
2+
3+
Thank you for your interest in contributing to Fula Storage! This document provides guidelines and information for contributors.
4+
5+
## Getting Started
6+
7+
### Prerequisites
8+
9+
- Rust 1.83 or later
10+
- Docker and Docker Compose (for running IPFS locally)
11+
- Git
12+
13+
### Development Setup
14+
15+
1. **Clone the repository**
16+
```bash
17+
git clone https://github.com/functionland/fula-api
18+
cd fula-api
19+
```
20+
21+
2. **Start the development stack**
22+
```bash
23+
docker-compose up -d ipfs cluster
24+
```
25+
26+
3. **Build the project**
27+
```bash
28+
cargo build
29+
```
30+
31+
4. **Run tests**
32+
```bash
33+
cargo test
34+
```
35+
36+
5. **Run the gateway locally**
37+
```bash
38+
cargo run --package fula-cli -- --no-auth --debug
39+
```
40+
41+
## Project Structure
42+
43+
```
44+
fula-api/
45+
├── crates/
46+
│ ├── fula-crypto/ # Cryptographic primitives
47+
│ ├── fula-blockstore/ # IPFS block storage
48+
│ ├── fula-core/ # Storage engine
49+
│ ├── fula-cli/ # Gateway server
50+
│ └── fula-client/ # Client SDK
51+
├── examples/ # Usage examples
52+
├── docs/ # Documentation
53+
└── tests/ # Integration tests
54+
```
55+
56+
## Coding Standards
57+
58+
### Rust Style
59+
60+
- Follow the [Rust API Guidelines](https://rust-lang.github.io/api-guidelines/)
61+
- Run `cargo fmt` before committing
62+
- Run `cargo clippy` and address warnings
63+
- Add documentation for public APIs
64+
65+
### Commit Messages
66+
67+
Use conventional commit format:
68+
69+
```
70+
type(scope): description
71+
72+
[optional body]
73+
74+
[optional footer]
75+
```
76+
77+
Types:
78+
- `feat`: New feature
79+
- `fix`: Bug fix
80+
- `docs`: Documentation changes
81+
- `style`: Code style changes
82+
- `refactor`: Code refactoring
83+
- `test`: Test changes
84+
- `chore`: Build/tooling changes
85+
86+
Examples:
87+
```
88+
feat(core): add Prolly Tree diff algorithm
89+
fix(gateway): handle multipart upload timeout
90+
docs(readme): add S3 compatibility examples
91+
```
92+
93+
### Pull Request Process
94+
95+
1. Fork the repository
96+
2. Create a feature branch: `git checkout -b feat/my-feature`
97+
3. Make your changes
98+
4. Add tests for new functionality
99+
5. Ensure all tests pass: `cargo test`
100+
6. Run lints: `cargo fmt && cargo clippy`
101+
7. Push and create a Pull Request
102+
103+
### Testing
104+
105+
- Write unit tests for all new functions
106+
- Add integration tests for API endpoints
107+
- Test with real IPFS nodes when possible
108+
- Aim for >80% code coverage
109+
110+
```bash
111+
# Run all tests
112+
cargo test
113+
114+
# Run with logging
115+
RUST_LOG=debug cargo test
116+
117+
# Run specific test
118+
cargo test test_prolly_tree
119+
120+
# Run benchmarks
121+
cargo bench
122+
```
123+
124+
## Architecture Guidelines
125+
126+
### Layer Separation
127+
128+
- `fula-crypto`: Pure cryptographic functions, no I/O
129+
- `fula-blockstore`: Block-level operations, IPFS interaction
130+
- `fula-core`: Business logic, bucket/object management
131+
- `fula-cli`: HTTP layer, S3 API translation
132+
133+
### Error Handling
134+
135+
- Use `thiserror` for error types
136+
- Propagate errors with context
137+
- Map internal errors to S3 error codes at the gateway layer
138+
139+
### Async Considerations
140+
141+
- Use `tokio` for async runtime
142+
- Prefer `async_trait` for async trait methods
143+
- Avoid blocking operations in async contexts
144+
145+
## Documentation
146+
147+
- Add rustdoc comments for public APIs
148+
- Include examples in documentation
149+
- Update README.md for user-facing changes
150+
- Update OpenAPI spec for API changes
151+
152+
## Security
153+
154+
### Reporting Vulnerabilities
155+
156+
Please report security vulnerabilities privately to security@fx.land. Do not create public issues for security problems.
157+
158+
### Security Best Practices
159+
160+
- Never log sensitive data (keys, tokens)
161+
- Validate all user input
162+
- Use constant-time comparison for secrets
163+
- Follow cryptographic best practices
164+
165+
## Getting Help
166+
167+
- Open a GitHub issue for bugs or features
168+
- Join our Discord for discussions
169+
- Check existing issues before creating new ones
170+
171+
## License
172+
173+
By contributing, you agree that your contributions will be licensed under the MIT/Apache-2.0 dual license.

0 commit comments

Comments
 (0)