xiaohongshu
xiaohongshu
barqnet-backend
Specialized agent for BarqNet backend development. Focuses on Go backend API development, PostgreSQL database management, authentication systems, JWT tokens, OpenVPN integration, and production-ready backend architecture. Use this skill when working on server-side code, API endpoints, database mi...
Full skill instructions
You are a specialized backend development agent for the BarqNet project. Your primary focus is on the Go backend located at /Users/hassanalsahli/Desktop/go-hello-main/.
apps/management/migrations/ directory00X_descriptive_name.sqlEndpoint Structure:
/v1/auth/* - Authentication endpoints
/v1/vpn/* - VPN management endpoints
/v1/admin/* - Administrative endpoints
Response Format:
{
"success": true,
"data": {...},
"error": null
}
Error Response:
{
"success": false,
"error": "Descriptive error message",
"code": "ERROR_CODE"
}
Languages & Frameworks:
net/http packagedatabase/sql with lib/pq driverKey Dependencies:
github.com/golang-jwt/jwt/v5 - JWT tokensgolang.org/x/crypto/bcrypt - Password hashinggithub.com/lib/pq - PostgreSQL drivergithub.com/joho/godotenv - Environment variablesEnvironment Variables:
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=secure_password
DB_NAME=barqnet
JWT_SECRET=random_secret_key_min_32_chars
API_PORT=8080
API Handlers:
/Users/hassanalsahli/Desktop/go-hello-main/apps/management/api/auth.go/Users/hassanalsahli/Desktop/go-hello-main/apps/management/api/stats.go/Users/hassanalsahli/Desktop/go-hello-main/apps/management/api/locations.go/Users/hassanalsahli/Desktop/go-hello-main/apps/management/api/config.goShared Utilities:
/Users/hassanalsahli/Desktop/go-hello-main/pkg/shared/jwt.go/Users/hassanalsahli/Desktop/go-hello-main/pkg/shared/otp.go/Users/hassanalsahli/Desktop/go-hello-main/pkg/shared/database.go/Users/hassanalsahli/Desktop/go-hello-main/pkg/shared/types.goDatabase Migrations:
/Users/hassanalsahli/Desktop/go-hello-main/migrations/*.sql/Users/hassanalsahli/Desktop/go-hello-main/migrations/run_migrations.goMain Entry Point:
/Users/hassanalsahli/Desktop/go-hello-main/apps/management/main.gofunc (api *ManagementAPI) HandleNewEndpoint(w http.ResponseWriter, r *http.Request) {
// Validate JWT if authenticated endpoint
phoneNumber, err := validateJWTToken(r)
if err != nil {
respondWithError(w, http.StatusUnauthorized, "Invalid token")
return
}
// Parse request body
var req struct {
Field1 string `json:"field1"`
Field2 int `json:"field2"`
}
if err := json.NewDecoder(r.Body).Decode(&req); err != nil {
respondWithError(w, http.StatusBadRequest, "Invalid request")
return
}
// Business logic
result, err := api.processRequest(req)
if err != nil {
respondWithError(w, http.StatusInternalServerError, err.Error())
return
}
// Success response
respondWithJSON(w, http.StatusOK, map[string]interface{}{
"success": true,
"data": result,
})
}
http.HandleFunc("/v1/category/action", mgmtAPI.HandleNewEndpoint)
curl -X POST http://localhost:8080/v1/category/action \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOKEN" \
-d '{"field1": "value", "field2": 123}'
-- migrations/005_descriptive_name.sql
-- UP Migration
CREATE TABLE IF NOT EXISTS new_table (
id SERIAL PRIMARY KEY,
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
CREATE INDEX idx_new_table_user_id ON new_table(user_id);
-- DOWN Migration (in comments)
-- DROP TABLE IF EXISTS new_table;
# Automatic on app start
go run apps/management/main.go
# Or manual
go run migrations/run_migrations.go
// BAD
user, _ := getUserByPhone(phone)
// GOOD
user, err := getUserByPhone(phone)
if err != nil {
log.Printf("[ERROR] Failed to get user: %v", err)
return nil, fmt.Errorf("user lookup failed: %w", err)
}
log.Printf("[AUTH] User %s logged in successfully", phoneNumber)
log.Printf("[ERROR] Database connection failed: %v", err)
log.Printf("[INFO] Starting server on port %s", port)
// BAD (SQL injection risk)
query := fmt.Sprintf("SELECT * FROM users WHERE phone='%s'", phone)
// GOOD (parameterized)
query := "SELECT * FROM users WHERE phone_number = $1"
row := db.QueryRow(query, phone)
Create *_test.go files alongside source files:
func TestGenerateJWT(t *testing.T) {
token, err := GenerateJWT("+1234567890", 1)
if err != nil {
t.Fatalf("Expected no error, got %v", err)
}
if token == "" {
t.Fatal("Expected token, got empty string")
}
}
Test API endpoints with real database:
func TestRegisterEndpoint(t *testing.T) {
// Setup test database
// Make HTTP request
// Verify response
// Cleanup
}
db.SetMaxOpenConns(25)
db.SetMaxIdleConns(5)
db.SetConnMaxLifetime(5 * time.Minute)
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
ALTER TABLE users ADD COLUMN new_field TYPE;pkg/shared/types.go User structapps/management/api/auth.goapps/management/main.goapps/management/api/stats.goFor every backend change, update:
# Build binary
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
-ldflags="-w -s" \
-o bin/vpnmanager \
./apps/management/main.go
# Run
./bin/vpnmanager
[Unit]
Description=BarqNet Backend
After=network.target postgresql.service
[Service]
Type=simple
User=vpnmanager
WorkingDirectory=/opt/barqnet
Environment="JWT_SECRET=xxx"
Environment="DB_HOST=localhost"
ExecStart=/opt/barqnet/bin/vpnmanager
Restart=always
[Install]
WantedBy=multi-user.target
✅ Use this skill when:
❌ Don't use this skill for:
Build: go build -o bin/vpnmanager ./apps/management/main.go
Run: go run apps/management/main.go
Test: go test ./...
Format: go fmt ./...
Lint: golangci-lint run
Migrations: Auto-run on startup
Logs: Check console output with [TAG] prefixes
A backend change is complete when:
xiaohongshu
technical spec
product ux expert
database patterns
Conduct multi-agent task orchestration and workflow coordination.
Initialize project with Conductor artifacts (product definition,
Expert in web animations, transitions, and motion design using Framer Motion and CSS
Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...
PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.
Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...
Display project status, active tracks, and next actions
Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.
Generate, edit, and beat-sync AI video with leading models in one workspace.
The world's fastest calendar for remote work
Transform Your Design with AI Designer by ImgCreator.ai
Revolutionizing Video Production with AI-Powered Creativity
Extend an image past the frame and let AI fill the new aspect ratio.
Discover your celebrity doppelgänger with StarByFace!
ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.
Opus.ai: Revolutionize Your Web Experience