How pavansiddapuram/makerble-assessment works
Project type and purpose
• This is a monolithic RESTful API server for a hospital management system, written in Go.
• It exposes HTTP endpoints (Gin) for two user roles (receptionist, doctor), uses JWT for auth, GORM/MySQL for persistence, and provides Swagger UI for documentation.
File structure
• cmd/server/main.go – application entrypoint, loads config, runs migrations, starts Gin HTTP server.
• internal/config – reads .env and initializes the database connection.
• internal/middleware – JWT validation and role‐based access control.
• internal/handler – HTTP controllers organized by feature (auth, patient).
• internal/service – business logic layer (auth workflows, patient operations).
• internal/repository – data access layer (GORM queries for user and patient tables).
• internal/model – domain models reflecting DB schema.
• migrations – schema migrations code.
• docs – Swagger definitions (JSON/YAML) and generated docs.go.
• generate_hash.go – password hashing utility.
• internal/test – unit tests for patient operations.
README for additional insights
• Tech stack: Go 1.24, Gin web framework, GORM ORM, MySQL, JWT auth, Swagger UI.
• Two distinct endpoint groups with URL prefixes (/api/receptionist, /api/doctor).
• Requests flow through middleware, handlers, services, repositories.
• Uses .env for configuration and go migrations for schema setup.
a. Main components
– Clients: Swagger UI, cURL/Postman, browser
– API Server (Gin router)
– Auth subsystem (login endpoint, JWT token issuer, auth middleware)
– HTTP Handlers (receptionist controller, doctor controller)
– Service layer (auth service, patient service)
– Repository layer (user repo, patient repo)
– MySQL database
– Migrations tool
– Configuration (.env)
– Documentation (Swagger definitions)
b. Relationships and interactions
1) Client sends HTTP request → Gin router
2) Router invokes JWT middleware (if protected) → validates token
3) Validated request → appropriate handler
4) Handler calls service layer for business logic
5) Service calls repository to read/write via GORM → MySQL
6) Response bubbles back through handler → client
7) At startup: main.go reads .env → runs migrations → serves Swagger UI
c. Architectural patterns and principles
– Layered (Controller → Service → Repository)
– Separation of concerns (auth vs. business logic vs. data access)
– Dependency injection via config and function parameters
– Single binary monolith
d. Key technologies
– Gin (HTTP routing)
– jwt-go (authentication middleware)
– GORM (ORM)
– MySQL (relational DB)
– Swagger (API documentation)