This is a repository consisting of a Go backend and a React frontend. It supports both an internal web application that is public facing, an internal admin web application, internal-only APIs for powering these web interfaces, and a set of APIs for third parties to take advantage of.
| Task | Command |
|---|---|
| Build backend | go build -o owncast . |
| Run backend | go run main.go |
| Run frontend dev server | cd web && npm run dev |
| Run Go tests | go test ./... |
| Run JS tests | cd web && npm test |
| Lint Go | make lint |
| Format Go | make fmt |
| Lint JS/CSS | cd web && npm run lint |
| Format JS/CSS | cd web && npm run format |
| Full web CI check | cd web && npm run check |
| Build Storybook | cd web && npm run build-storybook |
| Generate API code | make api-generate |
| Generate DB code | make sqlc |
| Install dev tools | make install-tools |
| Install git hooks | make install-hooks |
| Start test stream | ./test/ocTestStream.sh |
- UI component standards can be found in https://docs.owncast.dev/develop-frontend-components
- Ensure all code is formatted using
golangci-lintfor Go,stylelintfor CSS, andprettierfor JavaScript/React. - Fix any formatting or linting errors.
- Build: Ensure the code builds successfully using
go buildfor Go andnpm run buildfor React in thewebdirectory. - Tests: Write unit tests for Go code and Javascript logic. Use
go testandnpm run test. - UI components: Components should be standalone and reusable and show up in Storybook to enable testing, prototyping, and iteration.
- API: All APIs should be documented using OpenAPI specifications. Use
build/gen-api.shto generate the stubs, and then fill them in with your actual API implementation. - If you made new UI components or made changes ensure that Storybook still builds by running
npm run build-storybook.
web/: The web source code for the React frontend.- Root of the repo: Go source code for the backend.
static/web/: Generated static files for the web application. Do not edit or commit files in this directory directly; they are generated from thewebdirectory. Ignore this.test/automated/api/: A series of automated integration tests for API endpoints written in Javascript.test/automated/browser/: A series of automated browser UI tests for actual real-world browser interaction.build/: Build and code generation scripts.
main.go: Entry point. Initializes logging, database, config, core services, metrics, and the HTTP router.webserver/router/: Chi (v5) HTTP router with HTTP/2 support. Routes organized under/api/,/api/admin/, federation endpoints,/hls/, and/ws.webserver/handlers/: Request handlers for web, admin, static files, HLS streaming.webserver/handlers/generated/: Auto-generated API types and Chi server stubs from OpenAPI spec. Do not hand-edit.webserver/router/middleware/: Authentication (RequireAdminAuth()for admin endpoints via HTTP Basic Auth) and ActivityPub content negotiation middleware.persistence/: Repository pattern implementations (ConfigRepository, UserRepository, ChatMessageRepository, WebhookRepository, AuthRepository). All database access goes through these.db/: sqlc-generated type-safe database code. Schema indb/schema.sql, queries indb/query.sql. Runmake sqlcafter modifying.core/: Core streaming logic including transcoder, chat, webhooks, storage providers, playlist management.core/storageproviders/: Video storage backends (local filesystem and S3).core/transcoder/: FFmpeg-based video transcoding.activitypub/: Federation support (controllers, inbox/outbox, HTTP signatures, WebFinger, NodeInfo, worker pool).models/: Shared data models.config/: Configuration package with defaults and constants.tools/: Separatego.modfor development tool dependencies installed to./bin/.
web/pages/: Next.js 14 pages with static export.web/components/: React components organized by domain (admin/,chat/,common/,layouts/,modals/,ui/,video/,action-buttons/).web/components/stores/: Recoil state management stores.web/interfaces/: TypeScript interfaces.web/i18n/: Localization files (next-export-i18n).web/style-definitions/: Design token definitions.
- Go version: 1.24+ (see
go.mod) - Database: SQLite (single file, no external DB server needed)
- Frontend framework: Next.js 14, React 18, TypeScript, static export
- UI library: Ant Design v4 with Less theming
- State management: Recoil
- Styling: SCSS with component-scoped files, Less for Ant Design
- API spec: OpenAPI 3.1 at
openapi.yaml - Commit style: Conventional Commits (
type(scope): description) - Branches:
developis the development branch;masteris the production/release branch - CI: GitHub Actions for Go tests, JS linting/testing, browser tests, Storybook builds, Chromatic visual regression, CodeQL security scanning
- Go linting: golangci-lint with cyclop (max complexity 15), dupl (threshold 200), gosec, gocritic, forbidigo (no
fmt.Print*,print,println, orpanic), and others. Full config in.golangci.yml. - JS linting: ESLint with airbnb config, Prettier, Stylelint, knip for unused code detection
- Makefile: For common tasks like building, testing, linting, code generation, and installing dev tools/hooks. Run
make helpfor a list of functions.
Testing the web frontend requires running the frontend development server and the backend service together. The frontend development server must be started using npm run dev in the web directory, which will serve the web application at http://localhost:3000. The backend service can be started using go run main.go in the root of the repository.
Do not access the web application via http://localhost:8080 or build the web project to copy files to the static/web directory for local development.
- All APIs are to be documented using OpenAPI specifications and code is to be generated using
build/gen-api.sh. Additional details can be found at https://docs.owncast.dev/api-web-routing. - Write API tests for all new endpoints in the
test/automated/apidirectory. - Use the
test/automated/browserdirectory for browser-based tests for new functionality that simulate user interactions. - All user-facing frontend UI strings need to support localization. Use the
Translationcomponent to show most displayable strings. To create dynamic translated strings use thenext-export-i18nlibrary and thet()function. But use theTranslationcomponent unless there is a reason not to as it allows you to set default text. Read https://docs.owncast.dev/web-translations for more details. Test localization by adding "?lang=XX" with XX being a country code, such as "de" for German. Strings that have not yet been translated will not show as changed, but it's good to test anyway to make sure that previously translated strings have not been broken or regressed in any way. - A link to the PR's Storybook on Chromatic via the PR's Chromatic job should be included to help with review.
- For API changes a before and after example of the API response should be added to the pull request to help with review.
- For backend changes, a before and after example of logs to demonstrate the change should be added to the pull request to help with review.
- Do not build the web project or copy the files to the
static/webdirectory for local development. - When running the frontend development server, the local backend service must also be running. You can run the backend service using
go run main.goin the root of the repository. - The credentials for the backend development backend are username: admin and password: abc123 and uses HTTP Basic Auth. This is used for the admin web application and the admin APIs.
- The admin is found at
/admin. - If a live stream video is needed to run, you can run
./test/ocTestStream.shto start an actual stream that will begin streaming from the local development server. - You should never commit the
static/webdirectory to the repository. It is generated from thewebdirectory and should be ignored in your commits. - Don't use emoji in code comments or commit messages. That's lame.
- User interface components should use Ant Design v4 components, not Ant Design v5.
- Database access should be through the repository patterns.
- Any substantial new features or changes around Federation or ActivityPub should be documented in FEDERATION.md.
- Project documentation: https://docs.owncast.dev
- Frontend component guide: https://docs.owncast.dev/develop-frontend-components
- API and routing: https://docs.owncast.dev/api-web-routing
- Localization: https://docs.owncast.dev/web-translations
- Contributing guide: https://docs.owncast.dev/contributor-guide
- Federation protocol:
FEDERATION.md