A simple document database written from scratch in Python. It stores data as JSON documents and provides a basic HTTP API for interaction. This project utilizes the webserver library, also written from scratch.
- JSON document storage.
- HTTP API for CRUD operations.
- Basic API key authentication.
- Simple query mechanism (currently supports exact match).
-
Install uv:
-
Install dependencies:
uv venv && uv sync
-
Generate an API Key: Run the utility script to create an API key for accessing the database. You'll be prompted for details like allowed IPs and expiry.
uv run utils/generate_api_key.py
Keep the generated
Secretsafe, as it's needed for API requests. The key details are stored indata/access.json. -
Start the Database Server:
uv run database/database.py
Or use the VS Code debugger configuration provided in
.vscode/launch.json. -
Interact with the API: Use an HTTP client (like
curl, Postman, or Python'srequestslibrary) to send requests to the server (default:http://localhost:8080). Remember to include theAuthorizationheader with your generated key (KeyID+Secret).Example using
curlto insert a document:curl -X POST http://localhost:8080/my_collection/insert_one \ -H "Authorization: <Your_KeyID>+<Your_Secret>" \ -H "Content-Type: application/json" \ -d '{"name": "Alice", "age": 30}'
- API Endpoints: Details on available HTTP routes.
- Configuration: Information about the
config.jsonandaccess.jsonfiles. - Query Syntax: Explanation of how to structure queries (currently basic).
Contributions are welcome! Please feel free to open an issue or submit a pull request.
(Consider adding a license file and specifying it here, e.g., MIT License)