This guide will help you set up PostgreSQL and Redis containers, configure JWT authentication, test the authentication flow using different tools, and log into Kubestellar UI.
- Prerequisites
- Setup PostgreSQL and Redis with Docker Compose
- Alternative: Setup Individual Containers
- Verify Services are Running
- Setting Up JWT Authentication
- Set Up Environment Variables
- Export Environment Variables
- Running the Go Backend
- Testing JWT Authentication
- Stopping and Removing Containers
- Login to Kubestellar UI
- Docker Compose Development Cycle
- Docker Image Versioning and Pulling
- Installing GolangCI-Lint
- Linting & Fixing Code
- Imp Note
- Contribution Commands Guide
Before proceeding, ensure you have the following installed:
- Docker (For running PostgreSQL and Redis containers)
- PostgreSQL (Optional - if not using Docker)
- Redis (Optional - if not using Docker)
- Postman or cURL (For API testing)
- Go (For running the backend)
- OpenSSL (For generating JWT secrets securely)
- Make (For running backend scripts via makefile)
- Air (For hot reloading - optional but recommended)
Note
Recommended Setup: Use Docker Compose for the easiest setup experience. This automatically handles PostgreSQL and Redis containers with proper configuration.
Recommended approach for the best contributor experience
Navigate to the backend directory and start PostgreSQL and Redis services:
# Navigate to the backend directory
cd backend
# Start PostgreSQL and Redis services in detached mode
docker compose up -d
# Verify that services are running
docker psThis will start:
- PostgreSQL on port 5432 (for persistent data storage)
- Redis on port 6379 (for caching WebSocket updates)
Both services are configured with appropriate volumes to persist data between restarts.
There are multiple ways to generate a secure JWT secret key.
openssl rand -base64 32This generates a random 32-byte secret key.
python3 -c "import secrets; print(secrets.token_hex(32))"JWT_SECRET=mysecurekeygeneratedhereCreate a .env file in the /backend directory (where main.go is located):
# PostgreSQL Configuration
POSTGRES_HOST=localhost
POSTGRES_PORT=5432
POSTGRES_DB=kubestellar
POSTGRES_USER=postgres
POSTGRES_PASSWORD=postgres
# Redis Configuration
REDIS_HOST=localhost
REDIS_PORT=6379
# JWT Secret Key (Replace with your generated key)
JWT_SECRET=mysecurekeygeneratedhereIf you prefer not to use a .env file, you can export variables manually in your terminal:
export POSTGRES_HOST=localhost
export POSTGRES_PORT=5432
export POSTGRES_DB=kubestellar
export POSTGRES_USER=postgres
export POSTGRES_PASSWORD=postgres
export REDIS_HOST=localhost
export REDIS_PORT=6379
export JWT_SECRET=mysecurekeygeneratedhereEnsure you have Go installed, then run:
# Navigate to backend directory
cd backend
# Download dependencies
go mod download
# Option 1: Start backend with hot reloading (recommended)
make dev
# Option 2: Start backend without hot reloading
go run main.goYour API is now running on port 4000!
Tip
The make dev command uses Air for hot reloading, which automatically restarts the server when you make code changes.
You can either generate your JWT Token with Postman or cURL:
- Method:
POST - Endpoint:
http://localhost:4000/login - Headers:
Content-Type: application/json - Body:
{ "username": "admin", "password": "admin" }
{
"token": "your_generated_jwt_token"
}- Method:
GET - Endpoint:
http://localhost:4000/protected - Headers:
Authorization: Bearer <your_generated_jwt_token>
{
"message": "Welcome to the protected route!",
"user": "admin"
}{
"error": "Missing token"
}{
"error": "Invalid token"
}-
Login and Get a Token
- Open Postman and make a
POSTrequest tohttp://localhost:4000/login - Add the JSON payload:
{ "username": "admin", "password": "admin" } - Click Send, and copy the
tokenfrom the response.
- Open Postman and make a
-
Access Protected Route
- Make a
GETrequest tohttp://localhost:4000/protected - Go to the Headers section and add:
Authorization: Bearer <your_token> - Click Send and verify the response.
- Make a
If you prefer using the terminal, you can use cURL:
curl -X POST http://localhost:4000/login \
-H "Content-Type: application/json" \
-d '{
"username": "admin",
"password": "admin"
}'curl -X GET http://localhost:4000/protected \
-H "Authorization: Bearer <your_token>"# Stop and remove containers
docker compose down
# To also remove volumes (this will delete all data)
docker compose down -vStop the containers:
docker stop postgres redisRemove the containers:
docker rm postgres redisRemove volumes (optional - this will delete all data):
docker volume rm postgres_dataRun the Frontend if you haven't already:
# Navigate to project root
cd ..
# Install dependencies
npm install
# Start development server
npm run devLogin with these credentials:
- Username:
admin - Password:
admin
Note
You can input any word or strings of letters and numbers. Just as long as you have the username admin.
For ongoing development with Docker Compose, follow these steps:
docker compose downgit pull origin maindocker compose up --buildThis will:
- Stop the running containers.
- Pull the latest source code changes.
- Rebuild and restart the application.
If you'd like to work with the Docker images for the KubestellarUI project, here's how you can use the latest and versioned tags:
-
Frontend Image:
- Tag:
quay.io/kubestellar/ui:frontend - Latest Version:
latest - Specific Version (Commit Hash):
frontend-<commit-hash>
- Tag:
-
Backend Image:
- Tag:
quay.io/kubestellar/ui:backend - Latest Version:
latest - Specific Version (Commit Hash):
backend-<commit-hash>
- Tag:
-
Frontend Image:
docker pull quay.io/kubestellar/ui:frontend
-
Backend Image:
docker pull quay.io/kubestellar/ui:backend
If you want to pull an image for a specific version (e.g., commit hash), use:
-
Frontend Image with Version:
docker pull quay.io/kubestellar/ui:frontend-abcd1234
-
Backend Image with Version:
docker pull quay.io/kubestellar/ui:backend-abcd1234
To install GolangCI-Lint for code quality checks, follow these steps:
Run the following command:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.54.2Ensure $(go env GOPATH)/bin is in your PATH:
export PATH=$(go env GOPATH)/bin:$PATHUse scoop (recommended):
scoop install golangci-lintOr Go install:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latestRun:
golangci-lint --versionMaintaining code quality is essential for collaboration. Use these commands to check and fix linting issues:
make check-lintmake fix-lintmake lintThis project uses Husky to run pre-commit hooks that automatically:
- Format frontend code with Prettier
- Run ESLint checks
- Format Go code with gofmt
- Run Go linting and security checks
If you need to skip the pre-commit hooks (e.g., for a quick fix or emergency commit), use the --no-verify or -n flag:
# Skip all pre-commit hooks
git commit -n -m "fix: emergency hotfix"
Warning
Only skip pre-commit hooks when absolutely necessary. The hooks ensure code quality and consistency across the project.
If you're adding any new string in the frontend UI:
- Localize the string using our existing localization setup.
- Add the string to the appropriate language file (
locales/strings.en.json).
- Open
strings.en.jsonlocated under/locales/(or appropriate path). - Add your new string as a key-value pair. Example:
{
"greeting": "Hello, welcome!"
}- In your component, use the localization[+] hook.[/+][-] hook or method (depending on your i18n setup). Example using
react-i18next:[/-]
const { t } = useTranslation();
<p>{t("greeting")}</p>AI tools (like GitHub Copilot or ChatGPT) are helpful but not always context-aware. Please DO NOT blindly copy-paste AI-generated code. Before committing:
- Double-check if the code aligns with our project’s architecture.
- Test thoroughly to ensure it doesn’t break existing functionality.
- Refactor and adapt it as per the codebase standards.
This guide helps contributors manage issue assignments and request helpful labels via GitHub comments. These commands are supported through GitHub Actions or bots configured in the repository.
-
To assign yourself to an issue, comment:
/assign -
To remove yourself from an issue, comment:
/unassign
You can also request labels to be automatically added to issues using the following commands:
-
To request the
help wantedlabel, comment:/help-wanted -
To request the
good first issuelabel, comment:/good-first-issue
These commands help maintainers manage community contributions effectively and allow newcomers to find suitable issues to work on.
We use Playwright for comprehensive end-to-end testing of the KubeStellar UI. All contributors should ensure their changes don't break existing functionality by running tests locally.
# Navigate to frontend directory
cd frontend
# Install Playwright browsers (one-time setup)
npx playwright install
# Set up environment configuration
cp .env.playwright.example .env.local
# Run all E2E tests
npm run test:e2e
# Run tests with visual UI
npm run test:e2e:uiBefore running tests, customize your environment settings:
# Edit .env.local to configure:
# - PLAYWRIGHT_HEADED=true # Show browsers while testing
# - PLAYWRIGHT_VIDEO=true # Record test videos
# - PLAYWRIGHT_BROWSER=all # Test all browsers locally
# - PLAYWRIGHT_SLOW_MO=true # Slow motion for debuggingKey environment variables:
PLAYWRIGHT_HEADED- Show browser windows (great for debugging)PLAYWRIGHT_BROWSER- Choose browsers:chromium,firefox,webkit, orallPLAYWRIGHT_VIDEO- Record videos of test runsPLAYWRIGHT_SLOW_MO- Slow down execution for easier observation
- Run tests before submitting PRs: Always execute the full test suite locally
- Add tests for new features: Include E2E tests for new UI components or workflows
- Update tests for changes: Modify existing tests when changing UI behavior
- Use Page Object Model: Follow the established pattern for maintainable tests
# Debug mode (step through tests)
npm run test:e2e:debug
# Test specific browsers
npx playwright test --project=chromium
npx playwright test --project=firefox
# Run specific test file
npx playwright test e2e/auth.spec.ts
# Generate test code from interactions
npm run test:e2e:codegene2e/basic-navigation.spec.ts- Core app navigatione2e/auth.spec.ts- Authentication flowse2e/performance.spec.ts- Performance & accessibilitye2e/page-object-tests.spec.ts- Page Object Model examples
- Use
data-testidattributes for reliable element selection - Follow the Page Object Model pattern for reusable components
- Mock API responses for consistent test data
- Include both positive and negative test scenarios
Tests run automatically on:
- Push to
devbranches - Pull requests to
dev - Changes in
frontend/directory
For detailed documentation, see: frontend/PLAYWRIGHT.md