A lightweight, JSON-based database with a RESTful API. Think of it as a simpler version of MongoDB that's incredibly easy to set up and run.
BarelyDB is a minimalist database system that stores data as JSON files on disk and provides a simple HTTP API for accessing your data. Perfect for prototyping, small projects, or when you need a quick database solution without the overhead of traditional database systems. Or when you need a quick and fast database for startups.
- Zero configuration - Just run the binary and start using it
- JSON storage - All data stored as human-readable JSON files
- RESTful API - Simple HTTP endpoints for data access
- Lightweight - Minimal dependencies, fast startup
- File-based - Easy to backup, version control, and inspect
- Go 1.16 or higher
go build -o barelydb- Run BarelyDB:
./barelydbThe server will start on port 3838 and create a root database directory automatically.
- Access your data via HTTP:
# Get all records from a table
curl http://localhost:3838/mydb/users
# Get a specific record by ID
curl http://localhost:3838/mydb/users/user123Retrieve all records from a table.
Endpoint: GET /:database/:table
Example:
curl http://localhost:3838/myapp/usersResponse:
{
"user1": {
"name": "John Doe",
"email": "john@example.com"
},
"user2": {
"name": "Jane Smith",
"email": "jane@example.com"
}
}Retrieve a specific record by its ID.
Endpoint: GET /:database/:table/:id
Example:
curl http://localhost:3838/myapp/users/user1Response:
{
"id": "user1",
"name": "John Doe",
"email": "john@example.com"
}Database Not Found (404):
{
"error": "Database Not Found"
}Table Not Found (404):
{
"error": "Table Not Found"
}Record Not Found (404):
{
"error": "Record Not Found"
}BarelyDB organizes data in a simple file structure:
barelydb_data/
├── database1/
│ ├── table1.json
│ └── table2.json
└── database2/
└── table1.json
Each table is stored as a JSON file with records keyed by ID:
{
"record1": {
"field1": "value1",
"field2": "value2"
},
"record2": {
"field1": "value3",
"field2": "value4"
}
}By default, BarelyDB listens on port 3838. To change this, modify the LISTEN_PORT constant in main.go:
const LISTEN_PORT = ":3838"The root database directory is automatically determined by the getRootDatabaseDirectory() function. Check your implementation for the specific location.
BarelyDB is perfect for:
- Rapid prototyping - Get a database up and running in seconds
- Development environments - No need to install heavy database systems
- Small applications - Personal projects, scripts, and tools
- Learning projects - Understand database concepts without complexity
- Configuration storage - Store app settings and configurations
- Testing - Easily create and teardown test databases
BarelyDB is designed for simplicity, not production scale. Be aware of:
- No built-in authentication or authorization
- Limited query capabilities (currently no filtering, sorting, or pagination)
- File-based storage may not scale to millions of records
- No transaction support
- No concurrent write safety
Future enhancements may include:
- POST/PUT/DELETE operations for creating and modifying data
- Query parameters for filtering and sorting
- Basic authentication
- Indexing for faster lookups
- Backup and restore utilities
Contributions are welcome! Feel free to submit issues and pull requests.
[Add your license here]
Because it's barely a database - and that's exactly the point. Sometimes you don't need the complexity of a full database system. Sometimes you just need something that barely gets the job done, and does it well.
Getting Started in 30 Seconds:
# Build
go build -o barelydb
# Create database
mkdir -p ./barelydb_data/mydb
echo "\{\}" > ./barelydb_data/mydb/users.json
# Run
./barelydb
# Use
curl http://localhost:3838/mydb/usersThat's it. You're running a database.