Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wryte

golang

A tiny JSON-file-backed key/value store, written from scratch in Go to understand storage-layer basics (atomic writes, per-collection locking, generic read/write APIs) without pulling in a real database engine.

Each collection is a directory; each resource inside it is one JSON file. Writes go to a temp file and are then renamed into place, so a crash mid-write can never leave a half-written record.

Project layout

store/            the storage engine itself (no HTTP, no CLI — just Go)
  driver.go
  driver_test.go
models/           shared data types (User, Address)
cmd/server/       HTTP API that puts the store online
cmd/seed/         loads sample JSON files into the store
testdata/         sample user records used by cmd/seed

Running it

# start the API (writes data into ./data by default)
go run ./cmd/server

# in another terminal, load the sample users
go run ./cmd/seed

API

Method Path Description
POST /users create a user
GET /users list all users
GET /users?company=Google filter users by company
GET /users/{name} fetch one user
PUT /users/{name} partially update a user
DELETE /users/{name} delete a user

Example:

curl -X POST localhost:8080/users -d '{
  "name": "Darshan", "age": 23, "contact": "7775047254",
  "company": "Google",
  "address": {"city": "mumbai", "state": "maharashtra", "country": "india", "pincode": "400001"}
}'

curl localhost:8080/users
curl localhost:8080/users/Darshan
curl -X PUT localhost:8080/users/Darshan -d '{"age": 24}'
curl -X DELETE localhost:8080/users/Darshan

Tests

go test ./... -v
go test ./... -race   # check for data races under concurrent writes

About

A tiny JSON-file-backed key/value store, written from scratch in Go to understand storage-layer basics (atomic writes, per-collection locking, generic read/write APIs) without pulling in a real database engine.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages