Skip to content

ra4nd0m/merchshop-go

Repository files navigation

Avito Backend Trainee Assignment (Winter 2025)

The assignment description is available here:

Stack

  • Go
  • PostgreSQL
  • JWT auth

Run Service Locally

This repository is configured to run against a local database via environment variables in .env.local.

  1. Start dependencies your preferred way (local DB or existing environment).
  2. Run API:
make run

Service endpoint by default:

  • http://localhost:8080

Testing

Run all tests:

make test

Run coverage report:

make test-coverage

Business and Integration Coverage

Unit tests

Business scenarios are covered in unit tests for:

  • handlers
  • security
  • auth service
  • wallet service
  • postgres repositories and transaction manager

Integration tests

Implemented scenarios:

  • Purchase merch flow
    • test/integration/buy_integration_test.go
  • Coin transfer flow with sender and receiver history assertions
    • test/integration/transfer_integration_test.go
  • Remaining routes (/health, /api/auth, /api/info)
    • test/integration/auth_info_health_integration_test.go

Linting

Linter configuration is provided in:

  • .golangci.yaml

Load Testing

Load testing is prepared with k6 script:

  • test/load/k6.js

Run load test:

make load-test

Tunable parameters:

  • BASE_URL (default http://localhost:8080)
  • RATE (default 1000)
  • DURATION (default 30s)
  • PRE_ALLOCATED_VUS (default 200)
  • MAX_VUS (default 2000)

Example custom run:

BASE_URL=http://localhost:8080 RATE=800 DURATION=60s make load-test

Results template:

  • test/load/RESULTS.md

UNFINISHED!!!

Assignment Checklist

  • JWT auth with auto-registration on first login: implemented
  • Unit tests for business scenarios: implemented
  • Coverage > 40%: implemented
  • Integration test for purchase scenario: implemented
  • Integration test for coin transfer scenario: implemented
  • Integration/E2E tests for remaining scenarios (optional): implemented
  • Linter config (optional): implemented
  • Load testing with results (optional): script and report template added, run and fill results required

About

Avito Backend Trainee Assignment (Winter 2025)

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages