# artesia0528/porto-backend-golang architecture

> Architecture diagram of the GitHub repository artesia0528/porto-backend-golang, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/artesia0528/porto-backend-golang
- Repository: https://github.com/artesia0528/porto-backend-golang

## Overview

Portfolio Backend is a Go REST API for public portfolio content and authenticated administration. Visitors can retrieve projects, blogs, and experiences or submit contact messages; administrators log in for a JWT and use protected endpoints to manage content and messages. The runtime wires HTTP handlers, business services, repositories, and PostgreSQL persistence. Project, blog, experience, and message modules are included because the route registration exposes those capabilities, though their unsampled internal calls are not inferred. Evidence is limited to the README and the excerpted/indexed source files.

Main entry points: [`cmd/api/main.go`](https://github.com/artesia0528/porto-backend-golang/blob/master/cmd/api/main.go) (API Server), [`internal/routes/routes.go`](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/routes/routes.go) (Route Registration), [`internal/services/auth_service.go`](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/services/auth_service.go) (Authentication), [`internal/services/experience_service.go`](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/services/experience_service.go) (Experience Management)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP API"]
  node_entry["API Server<br/>[main.go]"]
  node_routes["Route Registration<br/>[routes.go]"]
  node_authmw["JWT Guard<br/>[auth_middleware.go]"]
  node_authh["Auth Handler<br/>[auth_handler.go]"]
  node_projecth["Project Handler<br/>[project_handler.go]"]
  node_blogh["Blog Handler<br/>[blog_handler.go]"]
  node_experienceh["Experience Handler"]
  node_messageh["Message Handler<br/>[message_handler.go]"]
end

subgraph group_domain["Portfolio Features"]
  node_auths["Authentication<br/>[auth_service.go]"]
  node_projects["Project Management<br/>[project_service.go]"]
  node_blogs["Blog Management<br/>[blog_service.go]"]
  node_experiences["Experience Management"]
  node_messages["Contact Messages<br/>[message_service.go]"]
end

subgraph group_data["Persistence"]
  node_users["User Repository<br/>[user_repository.go]"]
  node_projectrepo["Project Repository"]
  node_blogrepo["Blog Repository<br/>[blog_repository.go]"]
  node_experiencerepo["Experience Repository"]
  node_messagerepo["Message Repository"]
  node_postgres[("PostgreSQL")]
end

subgraph group_runtime["Runtime Services"]
  node_config["Configuration<br/>[config.go]"]
  node_database["Database Setup<br/>[database.go]"]
  node_seeder["Admin Seeder<br/>[seeder.go]"]
  node_fileupload["Upload Utilities<br/>[fileupload.go]"]
  node_jwt["JWT Utilities<br/>[jwt.go]"]
end

node_visitor(("Visitor / Admin"))

node_visitor -->|"sends requests"| node_routes
node_entry -->|"loads settings"| node_config
node_entry -->|"connects database"| node_database
node_entry -->|"seeds admin"| node_seeder
node_entry -->|"registers routes"| node_routes
node_entry -->|"enables CORS"| node_authmw
node_entry -->|"opens connection"| node_postgres
node_database -->|"migrates models"| node_postgres
node_entry -->|"wires repository"| node_users
node_entry -->|"wires repository"| node_projectrepo
node_entry -->|"wires repository"| node_blogrepo
node_entry -->|"wires repository"| node_experiencerepo
node_entry -->|"wires repository"| node_messagerepo
node_entry -->|"constructs service"| node_auths
node_entry -->|"constructs service"| node_projects
node_entry -->|"constructs service"| node_blogs
node_entry -->|"constructs service"| node_experiences
node_entry -->|"constructs service"| node_messages
node_routes -->|"guards admin routes"| node_authmw
node_routes -->|"routes login"| node_authh
node_routes -->|"routes project API"| node_projecth
node_routes -->|"routes blog API"| node_blogh
node_routes -->|"routes experience API"| node_experienceh
node_routes -->|"routes contact API"| node_messageh
node_authh -->|"delegates login"| node_auths
node_experienceh -->|"delegates operations"| node_experiences
node_auths -->|"looks up users"| node_users
node_auths -->|"creates token"| node_jwt
node_experiences -->|"reads and writes"| node_experiencerepo
node_experiences -->|"stores logos"| node_fileupload
node_authmw -->|"validates token"| node_jwt

click node_entry "https://github.com/artesia0528/porto-backend-golang/blob/master/cmd/api/main.go"
click node_routes "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/routes/routes.go"
click node_authmw "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/middleware/auth_middleware.go"
click node_authh "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/handlers/auth_handler.go"
click node_projecth "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/handlers/project_handler.go"
click node_blogh "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/handlers/blog_handler.go"
click node_experienceh "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/handlers/experience_handler.go"
click node_messageh "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/handlers/message_handler.go"
click node_auths "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/services/auth_service.go"
click node_projects "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/services/project_service.go"
click node_blogs "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/services/blog_service.go"
click node_experiences "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/services/experience_service.go"
click node_messages "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/services/message_service.go"
click node_users "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/repositories/user_repository.go"
click node_projectrepo "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/repositories/project_repository.go"
click node_blogrepo "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/repositories/blog_repository.go"
click node_experiencerepo "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/repositories/experience_repository.go"
click node_messagerepo "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/repositories/message_repository.go"
click node_config "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/config/config.go"
click node_database "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/database/database.go"
click node_seeder "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/database/seeder.go"
click node_fileupload "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/utils/fileupload.go"
click node_jwt "https://github.com/artesia0528/porto-backend-golang/blob/master/internal/utils/jwt.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_routes,node_authmw,node_authh,node_projecth,node_blogh,node_experienceh,node_messageh toneBlue
class node_auths,node_projects,node_blogs,node_experiences,node_messages toneAmber
class node_users,node_projectrepo,node_blogrepo,node_experiencerepo,node_messagerepo,node_postgres toneMint
class node_config,node_database,node_seeder,node_fileupload,node_jwt toneRose
class node_visitor toneIndigo
```

## Components

### HTTP API

- [API Server](https://github.com/artesia0528/porto-backend-golang/blob/master/cmd/api/main.go): `cmd/api/main.go`
- [Route Registration](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/routes/routes.go): `internal/routes/routes.go`
- [JWT Guard](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/middleware/auth_middleware.go): `internal/middleware/auth_middleware.go`
- [Auth Handler](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/handlers/auth_handler.go): `internal/handlers/auth_handler.go`
- [Project Handler](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/handlers/project_handler.go): `internal/handlers/project_handler.go`
- [Blog Handler](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/handlers/blog_handler.go): `internal/handlers/blog_handler.go`
- [Experience Handler](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/handlers/experience_handler.go): `internal/handlers/experience_handler.go`
- [Message Handler](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/handlers/message_handler.go): `internal/handlers/message_handler.go`

### Portfolio Features

- [Authentication](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/services/auth_service.go): `internal/services/auth_service.go`
- [Project Management](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/services/project_service.go): `internal/services/project_service.go`
- [Blog Management](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/services/blog_service.go): `internal/services/blog_service.go`
- [Experience Management](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/services/experience_service.go): `internal/services/experience_service.go`
- [Contact Messages](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/services/message_service.go): `internal/services/message_service.go`

### Persistence

- [User Repository](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/repositories/user_repository.go): `internal/repositories/user_repository.go`
- [Project Repository](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/repositories/project_repository.go): `internal/repositories/project_repository.go`
- [Blog Repository](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/repositories/blog_repository.go): `internal/repositories/blog_repository.go`
- [Experience Repository](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/repositories/experience_repository.go): `internal/repositories/experience_repository.go`
- [Message Repository](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/repositories/message_repository.go): `internal/repositories/message_repository.go`
- **PostgreSQL**

### Runtime Services

- [Configuration](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/config/config.go): `internal/config/config.go`
- [Database Setup](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/database/database.go): `internal/database/database.go`
- [Admin Seeder](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/database/seeder.go): `internal/database/seeder.go`
- [Upload Utilities](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/utils/fileupload.go): `internal/utils/fileupload.go`
- [JWT Utilities](https://github.com/artesia0528/porto-backend-golang/blob/master/internal/utils/jwt.go): `internal/utils/jwt.go`

### Other components

- **Visitor / Admin**

## Connections

- Visitor / Admin → Route Registration: sends requests (evidence: `README.md`)
- API Server → Configuration: loads settings (evidence: `cmd/api/main.go`)
- API Server → Database Setup: connects database (evidence: `cmd/api/main.go`)
- API Server → Admin Seeder: seeds admin (evidence: `cmd/api/main.go`)
- API Server → Route Registration: registers routes (evidence: `cmd/api/main.go`)
- API Server → JWT Guard: enables CORS (evidence: `cmd/api/main.go`)
- API Server → PostgreSQL: opens connection
- Database Setup → PostgreSQL: migrates models (evidence: `internal/database/database.go`)
- API Server → User Repository: wires repository (evidence: `cmd/api/main.go`)
- API Server → Project Repository: wires repository (evidence: `cmd/api/main.go`)
- API Server → Blog Repository: wires repository (evidence: `cmd/api/main.go`)
- API Server → Experience Repository: wires repository (evidence: `cmd/api/main.go`)
- API Server → Message Repository: wires repository (evidence: `cmd/api/main.go`)
- API Server → Authentication: constructs service (evidence: `cmd/api/main.go`)
- API Server → Project Management: constructs service (evidence: `cmd/api/main.go`)
- API Server → Blog Management: constructs service (evidence: `cmd/api/main.go`)
- API Server → Experience Management: constructs service (evidence: `cmd/api/main.go`)
- API Server → Contact Messages: constructs service (evidence: `cmd/api/main.go`)
- Route Registration → JWT Guard: guards admin routes (evidence: `internal/routes/routes.go`)
- Route Registration → Auth Handler: routes login (evidence: `internal/routes/routes.go`)
- Route Registration → Project Handler: routes project API (evidence: `internal/routes/routes.go`)
- Route Registration → Blog Handler: routes blog API (evidence: `internal/routes/routes.go`)
- Route Registration → Experience Handler: routes experience API (evidence: `internal/routes/routes.go`)
- Route Registration → Message Handler: routes contact API (evidence: `internal/routes/routes.go`)
- Auth Handler → Authentication: delegates login (evidence: `internal/handlers/auth_handler.go`)
- Experience Handler → Experience Management: delegates operations (evidence: `internal/handlers/experience_handler.go`)
- Authentication → User Repository: looks up users (evidence: `internal/services/auth_service.go`)
- Authentication → JWT Utilities: creates token (evidence: `internal/services/auth_service.go`)
- Experience Management → Experience Repository: reads and writes (evidence: `internal/services/experience_service.go`)
- Experience Management → Upload Utilities: stores logos (evidence: `internal/services/experience_service.go`)
- JWT Guard → JWT Utilities: validates token (evidence: `internal/middleware/auth_middleware.go`)
