How vpatel95/go-api-server works
Project type and purpose
• This is a monolithic, backend‐only RESTful API server written in Go.
• It exposes versioned endpoints under /api/v1, with user management and authentication functionality.
• It uses Gorilla Mux for HTTP routing and Gorm for ORM/database interactions.
File structure
• Entry point
• main.go – bootstraps the application.
• env/env.go – reads environment variables and sets up runtime config.
• Application initialization
• app/app.go – constructs the app context (config, router, DB).
• Routing layer
• route/route.go – wires Gorilla Mux router to the app and mounts API routes.
• app/api/api.go – groups versioned APIs.
• Versioned API
• app/api/v1/routes.go – defines common v1 route base.
• app/api/v1/auth – auth.go (handlers), routes.go (login/register).
• app/api/v1/users – user.go (model/handler), routes.go (user CRUD).
• Middleware
• app/api/v1/middleware/middlewares.go – auth checks, logging, etc.
• Business logic & utilities
• app/lib/common/common.go – shared helpers.
• app/lib/validation/validate.go – input validation.
• Data layer
• database/db.go – Gorm setup and connection pooling.
• app/model – Gorm models (user.go), migrations (migrate.go).
• Config files
• configs/database.json – DB connection details.
• configs/jwtsecret.key – secret for signing JWTs.
• configs/session.json – session store config.
README for additional insights
• Confirms use of Gorilla Mux (router) and Gorm (ORM).
• Indicates it’s a “Sample API server,” so extensibility and clarity are priorities.