This project provides a backend service for a Multi-Party Computation (MPC) wallet, offering secure key management and transaction signing capabilities.
- Secure MPC-based key generation and management
- Transaction signing using MPC
- RESTful API for wallet operations
- Kafka integration for asynchronous transaction processing
- Docker support for easy deployment
- Go 1.21 or higher
- Docker and Docker Compose
- Make (optional, for using Makefile commands)
This system contains two main components:
api
: RESTful API for wallet operationsworker
: Kafka consumer to process transaction receipts
mpcoin/
├── cmd/
│ ├── api/
│ │ └── main.go
│ └── worker/
│ └── main.go
├── internal/
│ ├── config/
│ ├── delivery/
│ │ └── http/
│ ├── domain/
│ ├── infrastructure/
│ │ ├── db/
│ │ ├── ethereum/
│ │ └── kafka/
│ ├── repository/
│ │ └── postgres/
│ └── usecase/
├── docs/
│ └── swagger/
├── scripts/
├── .env.example
├── docker-compose.yml
├── docker-compose.kafka.yml
├── Dockerfile
├── go.mod
├── go.sum
└── README.md
-
Clone the repository:
git clone https://github.com/vietddude/mpcoin.git cd mpcoin
-
Install dependencies:
go mod download
-
Set up environment variables:
cp .env.example .env
Edit the
.env
file with your configuration.
-
Start the Kafka and PostgreSQL services:
docker-compose -f docker-compose.kafka.yml up -d
-
Build and run the API server:
go run cmd/api/main.go
-
In a separate terminal, run the worker:
go run cmd/worker/main.go
The API will be available at http://localhost:8080
.
If you have Make installed, you can use the following commands:
- Start all services:
make up
- Stop all services:
make down
- Run API server:
make run-api
- Run worker:
make run-worker
- Run tests:
make test
Swagger UI is available at http://localhost:8080/docs
when the API server is running.
- Define the route in
internal/delivery/http/router.go
- Implement the handler in
internal/delivery/http/handlers/
- Update the Swagger documentation in
docs/swagger/
- Update the schema in
internal/infrastructure/db/migrations/
- Run migrations:
make migrate-up
- Update SQLC queries in
internal/infrastructure/db/queries/
- Generate new SQLC code:
make sqlc
Run unit tests:
go test ./...
For integration tests:
make integration-test
- Ensure proper key management practices are followed
- Regularly update dependencies
- Use secure communication channels (HTTPS, SSL/TLS)
- Implement proper authentication and authorization mechanisms
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a new branch:
git checkout -b feature-branch-name
- Make your changes and commit them:
git commit -m 'Add some feature'
- Push to the branch:
git push origin feature-branch-name
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.