Skip to content

First Go project structure template#6

Merged
jojo2504 merged 3 commits intomainfrom
backend
Nov 12, 2025
Merged

First Go project structure template#6
jojo2504 merged 3 commits intomainfrom
backend

Conversation

@jojo2504
Copy link
Owner

No description provided.

@jojo2504 jojo2504 requested a review from Copilot November 12, 2025 09:43
@jojo2504 jojo2504 merged commit dfd28fc into main Nov 12, 2025
7 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR restructures the Go backend by breaking down a monolithic models.go file into a well-organized package structure following Go best practices. The changes improve code maintainability and modularity by separating concerns into distinct packages.

  • Deleted the monolithic backend/models.go file (166 lines)
  • Created organized type packages under backend/api/types/ with domain-specific subdirectories
  • Established empty package files for internal API handlers and database clients to support future implementation

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
backend/models.go Removed monolithic models file containing all type definitions
backend/api/types/base/base.go Added common BaseModel struct with ID and timestamp fields
backend/api/types/user/*.go Split user-related types (User, Role, Organisation) into dedicated files
backend/api/types/problem/*.go Organized problem domain types (Problem, TestCase, ProblemSet, Language, Difficulty)
backend/api/types/submission/*.go Separated submission-related types (Verdict, TestCaseResult)
backend/api/types/session/session.go Isolated session/authentication model
backend/internal/api/auth/*.go Created auth package structure with placeholder files
backend/internal/api/submission/*.go Created submission API package structure
backend/internal/api/internal/judge/*.go Created internal judge API package structure
backend/internal/database/postgres.go Added database package placeholder
backend/internal/redis/client.go Added Redis client package placeholder
backend/.air.toml Updated build command to reference new main.go location
backend/cmd/server/main.go Minor comment update (hotload → hotreload)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

UserID int64 `json:"user_id"`
Token string `json:"token"` // refresh token UUID
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The CreatedAt field is duplicated - it's already part of the embedded base.BaseModel struct (which includes ID, CreatedAt, and UpdatedAt). Remove this duplicate field declaration.

Suggested change
CreatedAt time.Time `json:"created_at"`

Copilot uses AI. Check for mistakes.
args_bin = []
bin = "./tmp/main"
cmd = "go build -o ./tmp/main ."
cmd = "go build -o ./tmp/main /app/cmd/server/."
Copy link

Copilot AI Nov 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The path /app/cmd/server/. appears incorrect. It should likely be ./cmd/server or ./cmd/server/main.go to be consistent with standard Go project structures and relative paths used elsewhere in the config.

Suggested change
cmd = "go build -o ./tmp/main /app/cmd/server/."
cmd = "go build -o ./tmp/main ./cmd/server"

Copilot uses AI. Check for mistakes.
@jojo2504 jojo2504 deleted the backend branch November 12, 2025 22:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants