Skip to main content
Segra is an open-source project, and we welcome contributions from the community! Whether you’re fixing bugs, adding features, or improving documentation, this guide will help you get started.

Before You Start

Segra is built with C#/.NET for the backend and React/TypeScript for the frontend. Familiarity with these technologies is helpful but not required for all contributions.

Ways to Contribute

Report Bugs

Found an issue? Report it on GitHub Issues

Suggest Features

Have an idea? Open a feature request on GitHub

Fix Issues

Browse open issues and submit pull requests

Improve Docs

Help us improve guides and documentation

Development Setup

Requirements

  • Windows 10 (build 17763 / 1809) or newer
  • .NET SDK 9.0.x with Windows targeting
  • Git for version control
  • Bun v1.1+ for frontend tooling and git hooks

Repository Structure

Segra/
├── Segra.sln              # Solution file
├── Segra.csproj           # Main project file
├── Backend/               # C# backend code
│   ├── App/              # Application services
│   ├── Core/             # Core models and types
│   ├── Games/            # Game integrations
│   ├── Media/            # Video/audio processing
│   ├── Recorder/         # OBS integration
│   ├── Services/         # Backend services
│   └── Windows/          # Windows-specific code
├── Frontend/              # React frontend
│   ├── src/
│   ├── package.json
│   └── vite.config.ts
└── .husky/               # Git hooks

First-Time Setup

1

Clone the Repository

git clone https://github.com/Segergren/Segra.git
cd Segra
Or clone your fork if you’re contributing:
git clone https://github.com/YOUR_USERNAME/Segra.git
2

Install Root Dev Tools

Install Husky and lint-staged for git hooks:
bun install
bun run prepare
3

Install Frontend Dependencies

cd Frontend
bun install
cd ..
4

Verify .NET SDK

Ensure .NET SDK 9 is installed:
dotnet --info
Should show Version: 9.x and OS: Windows

Development Workflow

Running the Application

Segra has two parts that run during development:
The frontend dev server runs on http://localhost:2882:Using Bun (recommended):
cd Frontend
bun run dev
Using Node/npm:
cd Frontend
npm run dev

Making Changes

1

Create a Branch

git checkout -b feature/your-feature-name
Branch naming conventions:
  • feature/ - New features
  • fix/ - Bug fixes
  • docs/ - Documentation changes
  • refactor/ - Code refactoring
2

Make Your Changes

Edit code in your preferred IDE:
  • Visual Studio 2022: Open Segra.sln
  • VS Code: Open folder, install C# Dev Kit extension
Hot reload is supported for frontend (Vite) and backend (.NET 9).
3

Test Your Changes

  • Manual testing: Run the application and verify functionality
  • Check logs in %AppData%/Segra/logs/ for errors
  • Test on a clean Windows installation if possible
4

Commit Your Changes

Git hooks will automatically run:
  • Pre-commit: Formats C# code with dotnet format, runs Prettier/ESLint on frontend
  • Pre-push: Verifies no formatting drift in solution
git add .
git commit -m "feat: add new feature"
Commit message format:
  • feat: - New feature
  • fix: - Bug fix
  • docs: - Documentation
  • refactor: - Code refactoring
  • perf: - Performance improvement
  • test: - Test changes

Code Style and Formatting

Code formatting is enforced automatically via EditorConfig and git hooks.

EditorConfig Settings

Global (all files):
  • Line endings: CRLF
  • Indent: 2 spaces
C# files:
  • Line endings: CRLF
  • Indent: 4 spaces

C# Formatting

Formatting is handled by dotnet format:
Formats staged *.cs files automatically before commit

Frontend Formatting

The frontend uses Prettier + ESLint with Bun:
cd Frontend

# Check formatting
bun run format:check

# Auto-fix formatting
bun run format

# Check linting
bun run lint

# Auto-fix linting
bun run lint:fix

Building for Release

Backend Build

# Debug build
dotnet build -c Debug

# Release build
dotnet build -c Release

# Publish (self-contained)
dotnet publish -c Release

Frontend Build

cd Frontend
bun run build
This creates optimized production files in Frontend/dist/.

Key Architecture Concepts

Backend Architecture

Located in Backend/Recorder/OBSService.csResponsibilities:
  • OBS context initialization
  • Scene and source management
  • Encoder configuration
  • Recording/replay buffer outputs
Key Methods:
  • InitializeAsync() - Initialize OBS
  • StartRecording() - Start recording session
  • StopRecording() - Stop and cleanup
  • SaveReplayBuffer() - Save replay buffer
Located in Backend/Services/GameDetectionService.csResponsibilities:
  • Monitor Windows processes
  • Detect game launches
  • Auto-start recording
Uses WMI event watchers for process monitoring.
Located in Backend/Services/SettingsService.csResponsibilities:
  • Load/save user settings
  • Content folder management
  • Display/audio device enumeration
Located in Backend/Media/ContentService.csResponsibilities:
  • Metadata file creation
  • Thumbnail generation
  • Waveform generation
  • Content library management

Frontend Architecture

The frontend is built with:
  • React 18 - UI framework
  • TypeScript - Type safety
  • Vite - Build tool and dev server
  • Tailwind CSS - Styling
  • DaisyUI - Component library
Communication with backend uses:
  • WebSockets for real-time updates
  • IPC for Photino.NET integration

Common Development Tasks

Adding a New OBS Source Type

1

Add Source Creation

In OBSService.cs, create the source:
var customSource = new Source("source_id", "Source Name");
customSource.Update(s => {
    s.Set("property", value);
});
2

Add to Scene

var sceneItem = _mainScene.AddSource(customSource);
3

Cleanup on Stop

Add disposal in DisposeSources() method

Adding a New Game Integration

1

Create Integration Class

Create new file in Backend/Games/YourGame/YourGameIntegration.cs:
public class YourGameIntegration : Integration
{
    // Implementation
}
2

Implement Integration Logic

Override methods from Integration base class for event detection
3

Register in GameIntegrationService

Add your integration to the service initialization

Adding a New Setting

1

Add Property to Settings Model

In Backend/Core/Models/Settings.cs:
[JsonPropertyName("yourSetting")]
public bool YourSetting
{
    get => _yourSetting;
    set
    {
        _yourSetting = value;
        SendToFrontend("YourSetting changed");
    }
}
2

Add UI in Frontend

Create settings component in Frontend/src/components/Settings/
3

Wire Up Setting

Connect frontend UI to backend setting via IPC

Debugging

Backend Debugging

  1. Open Segra.sln
  2. Set breakpoints in code
  3. Press F5 to start debugging
  4. Debugger attaches automatically

Frontend Debugging

  • Browser DevTools: Inspect elements, console, network
  • React DevTools: Install browser extension for component inspection
  • Vite HMR: Hot Module Replacement for instant feedback

Git Hooks

Segra uses Husky + lint-staged for automated code quality:
Runs on git commit:
  • Formats staged *.cs files with dotnet format
  • Runs Prettier on frontend staged files
  • Runs ESLint on frontend staged files
If hooks don’t run, ensure Bun is on PATH in your Git shell:
bun install
bun run prepare

Pull Request Guidelines

Before Submitting

1

Keep PRs Focused

  • One feature or fix per PR
  • Small, reviewable changes
  • Avoid mixing refactoring with features
2

Run Format and Lint

# Backend
dotnet format

# Frontend
cd Frontend
bun run format
bun run lint:fix
3

Test Thoroughly

  • Test your changes manually
  • Verify no regressions in existing features
  • Include steps to reproduce in PR description
4

Update Documentation

If your change affects user-facing features, update docs

PR Description Template

## Description
Brief description of changes

## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update

## Testing
- How were these changes tested?
- What edge cases were considered?

## Screenshots (if applicable)
Add screenshots for UI changes

## Checklist
- [ ] Code follows project style
- [ ] Tests pass locally
- [ ] Documentation updated
- [ ] No console errors/warnings

Community

Code of Conduct

Segra follows the Contributor Covenant Code of Conduct. Be respectful, inclusive, and collaborative.

License

By contributing to Segra, you agree that your contributions will be licensed under the GPLv2 License.
Segra is licensed under GPLv2, which means:
  • You can use, modify, and distribute the software
  • Modifications must also be GPLv2
  • Source code must be made available

Getting Help

If you need help contributing:
  1. Check existing documentation and guides
  2. Search GitHub Issues for similar questions
  3. Ask in GitHub Discussions
  4. Join the Discord community
Thank you for contributing to Segra!