Go + PostgreSQL backend for CTF01D training platform.
Roadmap | Concept | Experemental Frontend
- REST API (OpenAPI 3)
- User/team management
- Game and scoreboard logic
- PostgreSQL migrations
# 1. ΠΠ°ΠΏΡΡΠΊ ΠΠ (PostgreSQL)
docker run -d --name ctf01d-postgres -e POSTGRES_DB=ctf01d -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 postgres
# 2. Π£ΡΡΠ°Π½ΠΎΠ²ΠΊΠ° Π·Π°Π²ΠΈΡΠΈΠΌΠΎΡΡΠ΅ΠΉ
go mod download && go mod tidy
# 3. Π‘Π±ΠΎΡΠΊΠ° ΠΈ Π·Π°ΠΏΡΡΠΊ
go build -o main cmd/main.go
./main
Π‘Π΅ΡΠ²Π΅Ρ Π±ΡΠ΄Π΅Ρ Π΄ΠΎΡΡΡΠΏΠ΅Π½ Π½Π° http://localhost:4102
Default admin credentials: admin/admin
- Go 1.24+
- Docker (Π΄Π»Ρ Π»ΠΎΠΊΠ°Π»ΡΠ½ΠΎΠΉ ΠΠ)
oapi-codegen -generate models,gin -o internal/server/httpserver.gen.go --package routers api/openapi.yaml
go run scripts/create-migration.go
- ΠΠΎΠ½ΡΠΈΠ³:
configs/config.*.yml
- ΠΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅:
db: driver: postgres data_source: postgres://postgres@localhost:5432/ctf01d
- ΠΠΎΠ΄ΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΊ ΠΊΠΎΠ½ΡΠ΅ΠΉΠ½Π΅ΡΡ:
docker exec -it ctf01d-postgres psql -U postgres
.
βββ api # openapi schema
β βββ openapi.yaml
βββ build # docker files
βββ cmd # main app
β βββ main.go
βββ configs # app config and other config (linter)
β βββ config.*.yml
β βββ golangci
β β βββ golangci.yml
β βββ spectral
β βββ spectral.yaml
βββ docs # project documentation
β βββ *.md
βββ html # current frontend
βββ internal
β βββ config
β β βββ config.go
β βββ handler # backend handlers
β β βββ *.go
β βββ helper # shared code
β β βββ helper.go
β βββ logger
β β βββ logger.go
β βββ migrations # sql migrations
β β βββ psql
β β βββ struct_updater.go
β β βββ update*.go
β βββ model # api json template
β β βββ *.go
β βββ repository # work with db, query ...
β β βββ *.go
β βββ httpserver # autogenerated code from oapi-codegen
β β βββ html_spa.go
β β βββ httpserver.gen.go
β βββ view
β βββ session.go
βββ pkg
β βββ avatar # uniq pic for user
β βββ avatar.go
βββ scripts
β βββ create-migration.go # make new file for migration
βββ test
βββ server_integration_test.go