Skip to content

clutchprotocol/clutch-hub-api

Repository files navigation

Clutch Hub API

Alpha Experimental License Rust

⚠️ ALPHA SOFTWARE - This project is in active development and is considered experimental. Use at your own risk. APIs may change without notice.

Overview

Clutch Hub API is a backend service designed to manage and provide data for the Clutch Hub application. It handles various operations such as user authentication, data retrieval, and data manipulation.

Created and maintained by Mehran Mazhar

Features

  • User authentication and authorization
  • CRUD operations for various resources
  • Data validation and error handling
  • Integration with external services
  • Detailed API documentation
  • Data modeling for resources
  • Example requests and responses

API Documentation

Authentication

POST /auth/register

Registers a new user.

Request Body:

{
  "username": "string",
  "password": "string",
  "email": "string"
}

Response:

{
  "id": "string",
  "username": "string",
  "email": "string",
  "token": "string"
}

POST /auth/login

Logs in a user.

Request Body:

{
  "username": "string",
  "password": "string"
}

Response:

{
  "token": "string"
}

Users

  • GET /users: Retrieve a list of users.
  • POST /users: Create a new user.
  • GET /users/{id}: Retrieve a user by ID.
  • PUT /users/{id}: Update a user by ID.
  • DELETE /users/{id}: Delete a user by ID.

Data Models

User

  • id: string
  • username: string
  • email: string
  • createdAt: Date
  • updatedAt: Date

Installation

Prerequisites

  • Docker and Docker Compose (recommended)
  • OR Rust (1.70+) and Cargo for local development

🐳 Docker Setup (Recommended)

Full Stack (Node + API) - Use clutch-deploy

For the complete Clutch stack (node + API + monitoring), use the clutch-deploy repository:

git clone https://github.com/clutchprotocol/clutch-deploy.git
cd clutch-deploy
cp .env.example .env
docker-compose up -d

API Only - Development

# Copy environment and start (builds from source)
cp env.example .env
docker-compose up --build

Or run a single container:

docker build -t clutch-hub-api .
docker run -p 3000:3000 --env-file .env clutch-hub-api

Pre-built image:

docker pull 9194010019/clutch-hub-api:latest
docker run -p 3000:3000 --env-file .env 9194010019/clutch-hub-api:latest

The API will be available at http://localhost:3000

Development with Docker

# Use the development script (Windows)
.\scripts\docker-dev.ps1 build    # Build image
.\scripts\docker-dev.ps1 up       # Start services
.\scripts\docker-dev.ps1 logs     # View logs
.\scripts\docker-dev.ps1 health   # Check health
.\scripts\docker-dev.ps1 clean    # Clean up

Pre-built Docker Images

docker pull 9194010019/clutch-hub-api:latest
docker run -p 3000:3000 --env-file .env 9194010019/clutch-hub-api:latest

🦀 Local Rust Setup

Prerequisites

  • Rust (1.76+)
  • Cargo

Setup

  1. Clone the repository:
    git clone https://github.com/MehranMazhar/clutch-hub-api.git
  2. Navigate to the project directory:
    cd clutch-hub-api
  3. Copy environment configuration:
    cp env.example .env
  4. Build the project:
    cargo build --release

Usage

  1. Start the API server:
    cargo run
  2. The API will be available at http://localhost:3000 (or configured port).

Example API calls:

  • Register a new user:
    curl -X POST http://localhost:3000/auth/register \
    -H "Content-Type: application/json" \
    -d '{"username": "john_doe", "password": "securepassword", "email": "john@example.com"}'
  • Login:
    curl -X POST http://localhost:3000/auth/login \
    -H "Content-Type: application/json" \
    -d '{"username": "john_doe", "password": "securepassword"}'

Configuration

  • Update the .env file with your environment variables.

Contributing

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Make your changes.
  4. Commit your changes (git commit -m 'Add some feature').
  5. Push to the branch (git push origin feature-branch).
  6. Open a pull request.

Author & Maintainer

Mehran Mazhar

License

This project is licensed under the MIT License.

About

clutch-hub-api

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors