Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: platform setup docs #32

Merged
merged 5 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .astro/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,13 +332,27 @@ declare module 'astro:content' {
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".md"] };
"en/contributorsguide/setup/prerequisites/postgres.md": {
id: "en/contributorsguide/setup/prerequisites/postgres.md";
slug: "en/contributorsguide/setup/prerequisites/postgres";
body: string;
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".md"] };
"en/contributorsguide/setup/prerequisites/prerequisitesoftwares.md": {
id: "en/contributorsguide/setup/prerequisites/prerequisitesoftwares.md";
slug: "en/contributorsguide/setup/prerequisites/prerequisitesoftwares";
body: string;
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".md"] };
"en/contributorsguide/setup/prerequisites/redis.md": {
id: "en/contributorsguide/setup/prerequisites/redis.md";
slug: "en/contributorsguide/setup/prerequisites/redis";
body: string;
collection: "docs";
data: InferEntrySchema<"docs">
} & { render(): Render[".md"] };
"en/contributorsguide/setup/studio/basicsetup/docker.md": {
id: "en/contributorsguide/setup/studio/basicsetup/docker.md";
slug: "en/contributorsguide/setup/studio/basicsetup/docker";
Expand Down
6 changes: 2 additions & 4 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ export default defineConfig({
{ label: "Prerequisites", "link": "/en/contributorsguide/setup/prerequisites/prerequisitesoftwares/" },
{ label: "Keycloak", "link": "/en/contributorsguide/setup/prerequisites/keycloak/" },
{ label: "NATS", "link": "/en/contributorsguide/setup/prerequisites/nats/" },

{ label: "REDIS", "link": "/en/contributorsguide/setup/prerequisites/redis/" },
{ label: "PostgreSQL", "link": "/en/contributorsguide/setup/prerequisites/postgres/" },
]
},


{
label: "Platform",
items: [
Expand All @@ -106,7 +105,6 @@ export default defineConfig({

]
},

{
label: "Agent",
items: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ title: Local setup using Docker
description: A reference page in my new CREDEBL docs site.
---


## Platform API

Clones the platform repository from GitHub:

```bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ title: Local setup using NPM
description: A reference page in my new CREDEBL docs site.
---

## Platform API

Clone the platform repository from GitHub:

```bash
Expand Down
97 changes: 94 additions & 3 deletions src/content/docs/en/contributorsguide/setup/platform/envsetup.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,97 @@
---
title: .env setup
description: .env setup
title: Environment Configuration
description: A guide to setting up environment variables for the CREDEBL platform.
---

- Coming soon
# `.env.sample` Configuration Documentation

This document outlines the configuration variables used in the `.env.sample` file. Each environment variable has been described to guide users on how to set up their environment correctly. These variables are critical for the functioning of the CREDEBL platform and must be configured with appropriate values.

## General Configuration

- **MODE**: Defines the operating mode of the application. Example: `DEV`, `PROD`, or `STAGING`.

## API Gateway Configuration

- **API_GATEWAY_PROTOCOL**: Protocol used for the API Gateway, typically `http` or `https`.
- **API_GATEWAY_HOST**: The host address of the API Gateway, often `0.0.0.0` for development.
- **API_GATEWAY_PORT**: The port on which the API Gateway will run. Example: `5000`.
- **API_GATEWAY_PROTOCOL_SECURE**: Security protocol for the API Gateway, typically `http` or `https`.

## Platform Settings

- **PLATFORM_NAME**: The name of the platform that will be displayed in the UI.
- **PLATFORM_LOGO**: The URL of the platform logo to be used in the UI.
- **PUBLIC_PLATFORM_SUPPORT_EMAIL**: The support email for users to contact in case of issues.
- **POWERED_BY**: The name of the organization powering the platform.
- **PLATFORM_WEB_URL**: The base URL of the platform's web interface.
- **POWERED_BY_URL**: The URL of the powered-by organization's website.

## Upload and File Hosting Settings

- **UPLOAD_LOGO_HOST**: Domain or URL where the logo files will be hosted.
- **FILE_SERVER**: URL or IP address of the file server.
- **FILE_SERVER_PORT**: Port on which the file server is running. Example: `8081`.
- **FILE_SERVER_USER**: Username for file server access.
- **FILE_SERVER_HOST**: Host IP address of the file server.

## Environment-Specific API URLs

- **PUBLIC_LOCALHOST_URL**: The localhost URL for the platform in development.
- **PUBLIC_DEV_API_URL**: API URL for the development environment.
- **PUBLIC_QA_API_URL**: API URL for the QA environment.
- **PUBLIC_PRODUCTION_API_URL**: API URL for the production environment.
- **PUBLIC_SANDBOX_API_URL**: API URL for the sandbox environment used for testing.

## AWS Configuration

- **AWS_ACCOUNT_ID**: Your AWS account ID.
- **S3_BUCKET_ARN**: The Amazon Resource Name (ARN) of the S3 bucket.
- **AWS_PUBLIC_ACCESS_KEY**: AWS access key for public resources.
- **AWS_PUBLIC_SECRET_KEY**: AWS secret key for public resources.
- **AWS_PUBLIC_REGION**: The AWS region where your resources are hosted.
- **AWS_PUBLIC_BUCKET_NAME**: The name of your public AWS S3 bucket.

## NATS Messaging Configuration

- **NATS_HOST**: Host IP address of the NATS server. Example: `0.0.0.0`.
- **NATS_PORT**: Port on which NATS messaging service is running. Example: `4222`.
- **NATS_URL**: Complete URL for connecting to the NATS server. Example: `nats://0.0.0.0:4222`.

## Redis Configuration

- **REDIS_HOST**: Host IP address of the Redis server.
- **REDIS_PORT**: Port on which Redis is running. Example: `6379`.

## PostgreSQL Configuration

- **POSTGRES_HOST**: Host IP address of the PostgreSQL server.
- **POSTGRES_PORT**: Port for PostgreSQL access. Default is `5432`.
- **POSTGRES_USER**: Username for PostgreSQL access. Default is `postgres`.
- **POSTGRES_PASSWORD**: Password for the PostgreSQL user.
- **POSTGRES_DATABASE**: Name of the PostgreSQL database to connect to.

## Socket and API Configuration

- **SOCKET_HOST**: URL for the socket connection to the API Gateway. Example: `http://localhost:5000`.
- **API_ENDPOINT**: URL and port of the API Gateway. Example: `localhost:5000`.
- **API_ENDPOINT_PORT**: Port on which the API Gateway is running. Example: `5000`.

## Prisma Configuration

- **DATABASE_URL**: Full PostgreSQL connection string for Prisma. Example: `postgresql://postgres:xxxxxx@localhost:5432/postgres?schema=public`.
- **POOL_DATABASE_URL**: URL for the pooled database connection.

## Additional Services Configuration

- **SENDGRID_API_KEY**: API key for SendGrid email service.
- **FRONT_END_URL**: The base URL for the front-end application. Example: `http://localhost:3000`.
- **KEYCLOAK_DOMAIN**: Base URL for Keycloak authentication. Example: `http://localhost:8080/`.

---

### Key Guidelines:
- Replace all placeholder values (e.g., `xxxxx`) with actual values.
- Ensure that sensitive information, such as API keys and passwords, are securely stored.
- For production environments, consider using a secrets manager instead of keeping values in the `.env` file.

47 changes: 35 additions & 12 deletions src/content/docs/en/contributorsguide/setup/prerequisites/nats.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,38 @@
title: NATS Messaging
description: NATS Messaging
---
CREDEBL Platform uses [NATS](https://nats.io) for message-driven data exchange between CREDEBL microservices.
The CREDEBL platform utilizes [NATS](https://nats.io/) for message-driven data exchange between its microservices. NATS serves as a lightweight and high-performance "message-oriented middleware," allowing services to communicate seamlessly in real-time.

CREDEBL Platform services need to exchange data. NATS is an infrastructure that allows such data exchange, segmented in the form of messages. It is called as "message oriented middleware".
With NATS, application developers can:
- Effortlessly build distributed and scalable client-server applications.
- Store and distribute data in realtime in a general manner. This can flexibly be achieved across various environments, languages, cloud providers and on-premises systems.
### Why NATS?
NATS enables CREDEBL platform services to exchange data effectively by breaking down communication into discrete messages. With NATS, application developers can:

## Setup a NATS Server:
- Build distributed and scalable client-server applications effortlessly.
- Store and distribute data in real time, making it adaptable across various environments, languages, cloud providers, and on-premises systems.

### Create NATS config `nats-server.conf`
## Setting Up a NATS Server

Follow the steps below to set up a NATS server for the CREDEBL platform using a configuration file and Docker.

### Create the NATS Configuration File (`nats-server.conf`)

The configuration file defines how the NATS server operates, including port assignments and WebSocket support.

```yaml
port: 4222
max_payload: 4194304 # 4 MB in bytes
websocket:
websocket {
port: 443
no_tls: true
no_tls: true
}

```
- **port:** The main port for NATS communication is set to 4222.
- **max_payload:** Sets the maximum message payload size to 4 MB.
- **websocket:** Enables WebSocket support on port 443 without TLS (for unsecured communication).

### Create the `docker-compose.yml` File

### Create `docker-compose`
The docker-compose.yml file will define the NATS service, map the necessary ports, and bind the configuration file.

``` yaml
version: '3'
Expand All @@ -39,9 +50,21 @@ services:
- ./nats-server.conf:/nats-server.conf:ro

```
- **container_name:** Sets the name of the container to nats.
- **image:** Uses the official NATS Docker image.
- **command:** Passes the NATS configuration file to the container at startup.
- **ports:** Exposes three key ports:
- `4222`: Main NATS client communication port.
- `6222`: Routing port for NATS clusters.
- `8222`: HTTP monitoring port for server statistics and health checks.
- **volumes:** Mounts the nats-server.conf configuration file into the container as read-only (ro).

### Start NATS Server
### Start the NATS Server

To start the NATS server, run the following command from the directory containing the docker-compose.yml file:

```yaml
docker compose up
```
```

This command will bring up the NATS container, configured to handle messaging for the CREDEBL platform's microservices.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
---
title: PostgreSQL Database
description: A reference page in my new CREDEBL docs site.
---

### Setting Up PostgreSQL Locally

[PostgreSQL](https://www.postgresql.org/) is a powerful, open-source object-relational database system known for its robustness and advanced features. This guide provides instructions for installing and configuring PostgreSQL both natively and using Docker.
Installing PostgreSQL

```bash
sudo apt install postgresql
```

To verify the status of the PostgreSQL service, use:

```bash
sudo systemctl status postgresql
```

#### Configuring PostgreSQL

1. Access the PostgreSQL command line interface:

```bash
sudo -u postgres psql
```

2. Create a new user:

```bash
CREATE USER your_user;
```

3. Create a new database:

```bash
CREATE DATABASE your_db_name;
```
4. Set a password for the user:

```bash
CREATE USER your_user WITH ENCRYPTED PASSWORD 'your_password';
```

5. Grant all privileges on the database to the user:

```bash
GRANT ALL PRIVILEGES ON DATABASE your_db_name TO your_user;
```

### Installing PostgreSQL Using Docker

1. Pull the PostgreSQL Docker image:

```bash
docker pull postgres
```

2. Create a Docker volume to persist PostgreSQL data:

```bash
docker volume create CREDEBL
```
3. Run the PostgreSQL Docker container:

```bash
docker run --name CREDEBL -e POSTGRES_PASSWORD=credebl_password -d -p 5432:5432 -v CREDEBL:/var/lib/postgresql/data postgres
```

4. Verify that the Docker container is running:

```bash
docker ps
```

You should see the container named CREDEBL listed.

Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ Before you begin with the project, make sure the following software's are instal

**Docker Compose:** Install the **latest version** of [Docker-Compose](https://docs.docker.com/compose/install).

**NATS:** Download and install [NATS](/en/guides/nats/).
**NATS:** Download and install [NATS](/en/contributorsguide/setup/prerequisites/nats/).

**REDIS:** Download and install [REDIS](https://redis.io/docs/install/install-stack/docker/).
**REDIS:** Download and install [REDIS](/en/contributorsguide/setup/prerequisites/redis/).

**PostgreSQL:** Download and install [PostgreSQL](/en/contributorsguide/setup/prerequisites/postgres/).

#### Authentication and Database

Expand Down
46 changes: 46 additions & 0 deletions src/content/docs/en/contributorsguide/setup/prerequisites/redis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
title: REDIS Transporter
description: REDIS Transporter
---
The CREDEBL platform leverages [Redis](https://redis.io/) as an in-memory data store, primarily for caching and queuing. By storing bulk data in memory, CREDEBL services can achieve high performance, making it easier to manage real-time workloads and handle large volumes of data efficiently.

## Setting Up a REDIS Server:

To set up Redis for the CREDEBL platform, follow the steps below to create and launch a Redis instance using Docker.

### Create the `docker-compose.yml` File

The docker-compose.yml file is used to define and configure the Redis container for the platform.

``` yaml
version: '3'
services:
redis:
image: redis:6.2-alpine
restart: always
ports:
- '6379:6379'
command: redis-server --save 20 1 --loglevel warning
volumes:
- cache:/data

volumes:
cache:

```

- **Image:** This specifies the version of Redis to be used. In this case, we are using **redis:6.2-alpine** for a lightweight and fast setup.
- **Restart Policy:** The restart always directive ensures that the Redis service restarts automatically in case of failure.
- **Ports:** The Redis server is mapped to the host machine’s port 6379.
- **Command:** Configures the Redis server to save data after 20 changes within 1 second and limits logging to warnings.
- **Volumes:** Data is persisted in a Docker volume named cache.


### Start REDIS Server
Once the docker-compose.yml file is in place, start the Redis service by running the following command:

```yaml
docker compose up
```

This command will bring up the Redis container, which is now ready to handle caching and queuing for the CREDEBL platform.