Development Guide

This guide covers development practices, contribution guidelines, and technical details for contributing to Shortas.

🀝 Contributing to Shortas
We welcome contributions from the community! This guide will help you get started with development.
πŸš€ Getting Started

Prerequisites

  • Rust 1.75+ (stable channel)
  • Docker & Docker Compose
  • Make
  • Git

Development Setup

# Clone the repository
git clone https://github.com/FlyingCow/shortas.git
cd shortas

# Complete development setup (installs dependencies, starts infrastructure, builds services, runs tests)
make dev-setup

# Start all services
make dev-start

πŸ—οΈ Project Structure

The Shortas project is a monorepo containing several Rust microservices and supporting infrastructure.

.
β”œβ”€β”€ docs/                  # Project documentation (Jekyll)
β”œβ”€β”€ redirect/              # Core URL redirection services
β”‚   β”œβ”€β”€ click-router/      # Main redirect service
β”‚   β”œβ”€β”€ click-tracker/     # Click processing service
β”‚   β”œβ”€β”€ click-aggregator/  # Analytics aggregation
β”‚   β”œβ”€β”€ click-router-api/  # Route management API
β”‚   └── click-aggregator-api/ # Analytics API
β”œβ”€β”€ salvo/                 # Salvo web framework (dependency/fork)
β”œβ”€β”€ infra/                 # Infrastructure setup (Docker, Terraform, AWS)
β”œβ”€β”€ data/                  # Static data (GeoIP, UA parser)
β”œβ”€β”€ docker-compose.yml     # Complete system deployment for local dev
└── makefile               # Enhanced build and development system

Service-Specific Structures

Each Rust service (click-router, click-tracker, etc.) generally follows a similar internal structure:

<service-name>/
β”œβ”€β”€ Cargo.toml             # Rust package manifest
β”œβ”€β”€ src/                   # Source code
β”‚   β”œβ”€β”€ adapters/          # Service integrations (DB, Cache, MQ)
β”‚   β”œβ”€β”€ core/              # Core business logic
β”‚   β”œβ”€β”€ model/             # Data models (structs, enums)
β”‚   β”œβ”€β”€ settings.rs        # Configuration loading
β”‚   └── main.rs            # Application entry point
β”œβ”€β”€ config/                # Configuration files (default.toml, development.toml, etc.)
β”œβ”€β”€ Dockerfile             # Docker build instructions
└── makefile               # Service-specific make commands

πŸ› οΈ Building the Project

Shortas uses cargo for Rust builds and make for an integrated build system.

Building All Services

From the project root:

# Development build (debug mode)
make build

# Release build (optimized for performance)
make build-release

# Build all Docker images
make build-docker

Building a Specific Service

You can build individual services:

make build-click-router
make build-click-router-api
# etc.

πŸ§ͺ Testing

Comprehensive testing is crucial for Shortas.

Running All Tests

From the project root:

make test

Running Tests for a Specific Service

make test-click-router
make test-click-tracker
# etc.

Test Coverage

Generate test coverage reports:

make test-coverage

This typically uses cargo tarpaulin and generates an HTML report.

πŸ“ Code Quality

Maintain high code quality with formatting and linting.

Formatting

make format # Formats all Rust code using rustfmt

Linting

make lint # Runs clippy for linting

Security Audit

Check for known vulnerabilities in dependencies:

cargo audit

🀝 Contributing Guidelines

We welcome contributions! Please follow these guidelines to ensure a smooth collaboration.

1. Fork the Repository

Fork the Shortas GitHub repository to your own GitHub account.

2. Clone Your Fork

git clone https://github.com/YOUR_USERNAME/shortas.git
cd shortas

3. Create a Feature Branch

Always work on a new branch for your features or bug fixes:

git checkout -b feature/your-feature-name
# or
git checkout -b bugfix/issue-description

4. Make Your Changes

5. Run Tests and Checks

Before committing, ensure all tests pass and code quality checks are clean:

make check # Runs lint, test, and build

6. Commit Your Changes

Write clear and concise commit messages.

git commit -m "feat: Add a new amazing feature"
# or
git commit -m "fix: Resolve issue with X"

7. Push to Your Fork

git push origin feature/your-feature-name

8. Open a Pull Request

πŸ› Debugging

Local Debugging

Docker Debugging


Thank you for contributing to Shortas! Your efforts help make this project better.