diff --git a/developer-docs/content-publishing/README.md b/developer-docs/content-publishing/README.md index 9093d03e..25d818e1 100644 --- a/developer-docs/content-publishing/README.md +++ b/developer-docs/content-publishing/README.md @@ -1,289 +1,172 @@ -# Content Publisher +# Content Publisher Service - +The Content Publisher Service is a crucial component of the Gateway suite, providing a familiar REST API for uploading content and publishing announcements to the Frequency blockchain. This document provides an overview of the service, its architecture, and guides for setup and usage. -# 📗 Table of Contents +## 📗 Table of Contents - [📖 About the Project](#about-project) -- [🔍 Arch Map](#-arch-maps) -- [🛠 Built With](#built-with) - - [Tech Stack](#tech-stack) - - [Key Features](#key-features) -- [🚀 Live OpenAPI Docs](#-live-docs) -- [💻 Getting Started](#-getting-started) - - [Prerequisites](#prerequisites) - - [Environment Variables](#environment-variables) - - [Setup](#setup) - - [Install](#install) - - [Usage](#usage) - - [Swagger](#swagger-ui) - - [Queue Management](#queue-management) - - [Run tests](#run-tests) - - [Linting](#linting) - - [Formatting](#auto-format) -- [🤝 Contributing](#-contributing) -- [⭐️ Show your support](#support) -- [🙏 Acknowledgements](#-acknowledgements) -- [❓FAQ](#faq) -- [📝 License](#-license) - - - -# 📖 Content Publishing Service - -The Content Publishing Service is part of the "Social Gateway" collection of services that provides a familiar REST API to allow uploading content and publishing announcements to the Frequency chain. The service handles all of the necessary blockchain interaction and allows clients to interact using a familiar, Web2-friendly interface. - - - -## 🔭 Arch Maps - -The Content Publishing Service consists of two applications: an API controller, and one (or more) Worker processes. The API and Worker processes communicate via a shared BullMQ message queue. The API controller handles incoming requests and enqueues content publishing tasks for the Worker(s). - -![Content Publishing Service Arch](./content_publishing_service_arch.drawio.png) - -

(back to top)

- -## 🛠 Built With - -### Tech Stack - -
- Server - -
- -
- Data store - -
- -
- Frameworks and Libraries - -
- -
- Polkadot and DSNP Integration - -
- -
- Testing - -
- -
- Formatting - -
- -
- Build and Deployment - -
- - - -### Key Features - -#### API +- [🔍 Architecture Overview](#architecture-overview) +- [🔑 Key Features](#key-features) +- [💻 Getting Started](#getting-started) +- [🚀 API Documentation](#api-documentation) +- [🛠 Development](#development) +- [🤝 Contributing](#contributing) +- [❓ FAQ](#faq) +- [📝 License](#license) -- **Upload asset files** -- **Create a broadcast(post)** -- **Create a reply** -- **Create a reaction** -- **Update existing content** -- **Delete existing content (tombstones)** -- **Update a user profile** +## 📖 About the Project -#### Development API +The Content Publisher Service is part of the Gateway suite that provides a Web2-friendly interface for blockchain content operations. It handles all necessary blockchain interactions, allowing clients to use familiar REST API patterns for publishing and managing content on the Frequency chain. -- **Get the details of a job** -- **Get asset** -- **Populate a queue with dummy announcement data** +## 🔍 Architecture Overview -

(back to top)

+The Content Publisher Service consists of two main components: - +1. **API Controller**: Handles incoming HTTP requests and enqueues content publishing tasks +2. **Worker Process**: Processes queued tasks and interacts with the blockchain -## 🚀 Live Docs +The API and Worker processes communicate via a shared BullMQ message queue. -- [Live Docs](https://projectlibertylabs.github.io/content-publishing-service/) -- [API Documentation](https://projectlibertylabs.github.io/content-publishing-service/) -- [GitHub](https://github.com/ProjectLibertyLabs/gateway) - -

(back to top)

- - - -## 💻 Getting Started - -This guide is tailored for developers working in the code base for the Content Publishing Service itself. For a more tutorial tailored more for developers wanting to deploy the Content Publishing Service as part of the broader Social Gateway in order to develop their own Social Gateway app, visit [Live Docs](https://projectlibertylabs.github.io/gateway/). - -To prepare and run a local instance of the Content Publishing Service for local development, follow the guide below. +![Content Publishing Service Architecture](./content_publishing_service_arch.drawio.png) -### Prerequisites - -In order to run this project you need: - -- [Nodejs](https://nodejs.org) -- [Docker](https://www.docker.com) or Docker-compatible container system for running Gateway Services - - (note, Docker is not strictly required; all of the services described below may be installed or built & run locally, but that is outside the scope of this guide) - -### Environment Variables +## 🔑 Key Features -Use the provided [env.template](../../env-files/content-publishing.template.env) file to create an initial environment for the application, and edit as desired. Additional documentation on the complete set of environment variables is provided in the [ENVIRONMENT.md](./ENVIRONMENT.md) file. - -1. For running the application under Docker, copy the environment template to `.env.docker.dev`; for running bare-metal, copy to `.env`. - -```sh -cp env-files/content-publishing.template.env .env -``` +### Content Management +- **Upload asset files**: Handle file uploads to the system +- **Create broadcasts**: Publish new posts to the network +- **Create replies**: Respond to existing content +- **Create reactions**: Add reactions to content +- **Update content**: Modify existing content +- **Delete content**: Remove content (via tombstones) +- **Update profiles**: Manage user profile information -2. Configure the environment variable values according to your environment. +### Development Features +- **Job management**: Monitor and manage publishing jobs +- **Asset retrieval**: Access stored assets +- **Test data**: Generate sample announcement data -### Install +## 💻 Getting Started -Install NPM Dependencies: +This section guides you through setting up the Content Publisher Service for both development and deployment. -```sh - npm install -``` +### Prerequisites -### Usage +Ensure you have the following installed: +- [Node.js](https://nodejs.org) +- [Docker](https://docs.docker.com/get-docker/) -To run the project, execute the following command: +### Quick Start -#### 1. Start the required auxiliary services +1. Clone the repository and navigate to the project directory: + ```bash + git clone https://github.com/ProjectLibertyLabs/gateway.git + cd gateway + ``` -Frequency node, Redis, IPFS +2. Install dependencies: + ```bash + npm install + ``` -```sh -docker compose up -d frequency redis ipfs -``` +3. Set up environment variables: + ```bash + cp env-files/content-publishing.template.env .env + ``` + Configure the environment variables according to your needs. -#### 2. Start the application services +4. Start auxiliary services: + ```bash + docker compose up -d frequency redis ipfs + ``` -Each of the application services may be run either under Docker or bare-metal, depending on your preferred development workflow. +5. Start the application services: -The instructions are the same for running both the API service and the worker service: + API Service: + ```bash + npm run start:content-publishing-api:dev + ``` -- **Substitute "content-publishing-api" or "content-publishing-worker" for the "< service >" tag in the commands below.** + Worker Service: + ```bash + npm run start:content-publishing-worker:dev + ``` -#### Running bare metal +6. Set up with account data: + ```bash + make setup-account + ``` -```sh -npm run start:::dev -``` +### Alternative: Docker Setup --- or -- +1. Run services using Docker: + ```bash + docker compose up -d frequency content-publishing-service-api content-publishing-service-worker + ``` -#### Running under Docker +2. Set up with account data: + ```bash + make setup-account + ``` -```sh -docker compose up [-d] content-publishing-service- -``` +### Verification -#### 3. Check the job in BullUI, to monitor job progress based on defined tests +### Verification -### Swagger UI +#### Docker Setup +- Access Swagger UI: [http://localhost:3012/docs/swagger](http://localhost:3012/docs/swagger) +- View and manage queues: [http://localhost:3012/queues](http://localhost:3012/queues) -Check out the Swagger UI hosted on the app instance at to view the API documentation and submit requests to the service. +#### Local Development Setup +- Access Swagger UI: [http://localhost:3000/docs/swagger](http://localhost:3000/docs/swagger) +- View and manage queues: [http://localhost:3000/queues](http://localhost:3000/queues) -### Queue Management +## 🚀 API Documentation -You may also view and manage the application's queue at . +- [Live API Documentation](https://projectlibertylabs.github.io/gateway) -### Run tests +## 🛠 Development -To run tests, run the following command: +### Testing -```sh - npm test +Run the test suite: +```bash +npm test:content-publising ``` -### Linting +### Linting and Formatting -```sh - npm run lint +Run linter: +```bash +npm run lint ``` -### Auto-format - -```sh - npm run format +Auto-format code: +```bash +npm run format ``` -

(back to top)

- - - -## 🤝 Contributing - -Contributions, issues, and feature requests are welcome! - -- [Contributing Guidelines](./CONTRIBUTING.md) -- [Open Issues](https://github.com/ProjectLibertyLabs/gateway/issues) - -

(back to top)

- - - -## ⭐️ Show your support - -If you would like to explore contributing bug fixes or enhancements, issues with the label `good-first-issue` can be a good place to start. - -

(back to top)

- - - -## 🙏 Acknowledgements - -Thank you to [Frequency](https://www.frequency.xyz) for assistance and documentation making this possible. +### Built With - +- **Server Framework**: NestJS, Node.js, TypeScript +- **Data Store**: Redis (ioredis) +- **Queue System**: BullMQ +- **Blockchain Integration**: Polkadot API, DSNP +- **Testing**: Jest, Supertest +- **Documentation**: Swagger +- **Containerization**: Docker, Docker Compose -## ❓FAQ +## 🤝 Contributing -- **Can I use this service in my production social app?** +We welcome contributions! Please check our [Contributing Guidelines](./CONTRIBUTING.md) and [open issues](https://github.com/ProjectLibertyLabs/gateway/issues). - - Yes. All the Gateway Services are intended to be ready-to-use out of the box as part of the fabric of your own social media app using DSNP on Frequency. +## ❓ FAQ -

(back to top)

+**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 as part of your own social media app using DSNP on Frequency.* -## 📝 License +## 📝 License -This project is [Apache 2.0](./LICENSE) licensed. +This project is licensed under the [Apache 2.0 License](./LICENSE). -

(back to top)

+

(back to top)

\ No newline at end of file