The Account Service is a crucial component of the Gateway suite, enabling easy interaction with DSNP accounts on Frequency. This document provides an overview of the service, its architecture, and guides for setup and usage.
- 📖 About the Project
- 🔍 Architecture Overview
- 🔑 Key Features
- 💻 Getting Started
- 🚀 API Documentation
- 🛠 Development
- 🤝 Contributing
- ❓ FAQ
- 📝 License
The Account Service simplifies the management of user accounts, defined by a user's handle and MSA Id (Message Source Account Identifier) on the Frequency blockchain using DSNP protocols.
The Account Service is built using NestJS and is divided into two main components:
- API: Handles incoming HTTP requests
- Worker: Processes jobs that require blockchain interaction
- Account creation using SIWF (Sign-In With Frequency)
- User and Provider Account management
- Handle (username) claiming and management
- Key management (adding and retrieving keys)
- Delegation info retrieval for MSA Id
- Seamless integration with Web3 wallets
This section will guide you through setting up the Account Service for both quick start and local development.
Ensure you have the following installed:
-
Clone the repository and navigate to the project directory:
git clone https://github.com/ProjectLibertyLabs/gateway.git cd gateway
-
Copy the environment template:
cp env-files/account.template.env .env.account
Ensure that the
.env.account
file is correctly configured for your environment. For more information, refer to the Environment Variables section in the full documentation. Specifically, you will need to set theFREQUENCY_API_WS_URL
, etc., to the correct network (e.g.,wss://0.rpc.testnet.amplica.io
). -
Install dependencies:
npm install
-
Start supporting services (local frequency node, redis) using Docker:
./scripts/account/restart-chain-docker.sh
-
Start account service api and worker applications using Docker:
docker compose -f docker-compose.yaml -f docker-compose-e2e.account.yaml --profile account up -d
If you prefer to run services locally for development:
-
Start Redis and Frequency:
./scripts/account/restart-local-dev.sh
-
Start the mock webhook server (in a new terminal):
cd webhook-servers && cargo run
-
Start the API (in a new terminal):
npm run start:account-api:dev
-
Start the Worker (in another new terminal):
npm run start:account-worker:dev
- Access Swagger UI: http://localhost:3000/api/docs/swagger
- View and manage queues: http://localhost:3000/queues
After setting up the Account Service, you can:
- Explore the API using the Swagger UI
- Run the test suite to ensure everything is working correctly
- Start integrating the Account Service into your application
For more detailed setup instructions, environment variable configuration, and advanced usage, please refer to our comprehensive documentation.
Explore our Live API Documentation for detailed information on endpoints and usage.
This section covers testing, debugging, linting, and information about the technologies used in the Account Service.
Run E2E tests:
make test-e2e-account
Access Swagger UI: http://localhost:3000/api/docs/swagger
Manage queues: http://localhost:3000/queues
To run the linter:
npm run lint
To automatically fix linting issues:
npm run format
To stop containers, networks, volumes, and images created by docker compose up
, run:
docker compose down
Note: You may need to manually remove containers using the Docker Desktop app.
-
Follow step 1 from the Development Environment section above to set up the Redis and Frequency containers.
-
Use the debug panel and start the
Debug Api (NestJS via ts-node)
configuration to debug the API.Use the debug panel and start the
Debug Worker (NestJS via ts-node)
configuration to debug the worker. -
Set breakpoints in the code and debug your code.
-
Monitor the service worker jobs in BullUI.
Any API functions that require an extrinsic to be submitted to the blockchain will be queued here. The queue will manage the amount of
capacity
this service is allowed to use. -
Use Swagger to test the API.
Reference the Frequency Docs for more information about extrinsics and capacity.
Note: Reference .vscode/launch.json
for more details on the debug configurations and apply the concepts to your preferred debugger.
- Framework: NestJS
- Language: TypeScript
- Testing: Jest, Supertest
- Data Store: ioredis
- API Documentation: Swagger
- Containerization: Docker, Docker Compose
For a complete list of technologies used, please refer to the Tech Stack section in the full documentation.
We welcome contributions! Please check our Contributing Guidelines and open issues.
Q: Can I use this service in my production social app?
Yes, Gateway Services are designed to be ready-to-use out of the box for social media apps using DSNP on Frequency.
Q: Will the Account Service scale for large applications?
The service is designed to support small-to-medium-sized social apps. For larger use cases, custom solutions may be necessary.
This project is licensed under the Apache 2.0 License.