# morozkoart/codecollab architecture

> Architecture diagram of the GitHub repository morozkoart/codecollab, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/morozkoart/codecollab
- Repository: https://github.com/morozkoart/codecollab

## Overview

CodeCollab is presented as a collaborative-code-editor API, but the sampled runtime implements user registration, login, JWT authentication, and health checks; protected collaboration routes are explicitly TODO. The main workflow is an HTTP auth request through routing and validation to the auth service, then user persistence or credential verification and a token response. The graph covers the evidenced startup and auth layers; database repository internals and other unsampled features are not expanded into assumed flows.

Main entry points: [`backend/internal/services/auth.go`](https://github.com/morozkoart/codecollab/blob/master/backend/internal/services/auth.go) (Auth service), [`backend/cmd/server/main.go`](https://github.com/morozkoart/codecollab/blob/master/backend/cmd/server/main.go) (Server startup), [`backend/internal/api/http/v1/router.go`](https://github.com/morozkoart/codecollab/blob/master/backend/internal/api/http/v1/router.go) (V1 router), [`backend/internal/api/http/v1/auth.go`](https://github.com/morozkoart/codecollab/blob/master/backend/internal/api/http/v1/auth.go) (Auth handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["HTTP runtime"]
  node_server["Server startup<br/>[main.go]"]
  node_httpapp["HTTP app<br/>[app.go]"]
  node_router["V1 router<br/>[router.go]"]
  node_response["JSON responses<br/>[response.go]"]
  node_config["Configuration<br/>[config.go]"]
end

subgraph group_auth["Authentication"]
  node_handlers["Auth handlers<br/>[auth.go]"]
  node_middleware["JWT middleware<br/>[auth.go]"]
  node_service["Auth service<br/>[auth.go]"]
  node_jwt["JWT service<br/>[jwt.go]"]
  node_password["Password checks<br/>[password.go]"]
end

subgraph group_data["User data"]
  node_domain["User models<br/>[user.go]"]
  node_repository["User repository<br/>[user.go]"]
  node_postgres[("PostgreSQL")]
end

node_client(("API client"))

node_client -->|"HTTP requests"| node_httpapp
node_httpapp -->|"dispatches"| node_router
node_router -->|"routes auth"| node_handlers
node_router -->|"protects routes"| node_middleware
node_handlers -->|"calls"| node_service
node_handlers -->|"writes responses"| node_response
node_service -->|"reads and writes users"| node_repository
node_service -->|"checks password"| node_password
node_service -->|"generates token"| node_jwt
node_middleware -->|"validates token"| node_jwt
node_server -->|"loads settings"| node_config
node_server -->|"connects"| node_postgres
node_server -->|"constructs"| node_repository
node_server -->|"constructs"| node_service
node_server -->|"starts and stops"| node_httpapp
node_service -->|"uses user models"| node_domain

click node_server "https://github.com/morozkoart/codecollab/blob/master/backend/cmd/server/main.go"
click node_httpapp "https://github.com/morozkoart/codecollab/blob/master/backend/internal/app/app.go"
click node_router "https://github.com/morozkoart/codecollab/blob/master/backend/internal/api/http/v1/router.go"
click node_handlers "https://github.com/morozkoart/codecollab/blob/master/backend/internal/api/http/v1/auth.go"
click node_response "https://github.com/morozkoart/codecollab/blob/master/backend/pkg/response/response.go"
click node_middleware "https://github.com/morozkoart/codecollab/blob/master/backend/internal/api/http/middleware/auth.go"
click node_service "https://github.com/morozkoart/codecollab/blob/master/backend/internal/services/auth.go"
click node_jwt "https://github.com/morozkoart/codecollab/blob/master/backend/pkg/jwt/jwt.go"
click node_password "https://github.com/morozkoart/codecollab/blob/master/backend/pkg/password/password.go"
click node_domain "https://github.com/morozkoart/codecollab/blob/master/backend/internal/domain/user.go"
click node_repository "https://github.com/morozkoart/codecollab/blob/master/backend/internal/repository/user.go"
click node_config "https://github.com/morozkoart/codecollab/blob/master/backend/internal/config/config.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_server,node_httpapp,node_router,node_response,node_config,node_client toneBlue
class node_handlers,node_middleware,node_service,node_jwt,node_password toneAmber
class node_domain,node_repository,node_postgres toneMint
```

## Components

### HTTP runtime

- [Server startup](https://github.com/morozkoart/codecollab/blob/master/backend/cmd/server/main.go): `backend/cmd/server/main.go`
- [HTTP app](https://github.com/morozkoart/codecollab/blob/master/backend/internal/app/app.go): `backend/internal/app/app.go`
- [V1 router](https://github.com/morozkoart/codecollab/blob/master/backend/internal/api/http/v1/router.go): `backend/internal/api/http/v1/router.go`
- [JSON responses](https://github.com/morozkoart/codecollab/blob/master/backend/pkg/response/response.go): `backend/pkg/response/response.go`
- [Configuration](https://github.com/morozkoart/codecollab/blob/master/backend/internal/config/config.go): `backend/internal/config/config.go`

### Authentication

- [Auth handlers](https://github.com/morozkoart/codecollab/blob/master/backend/internal/api/http/v1/auth.go): `backend/internal/api/http/v1/auth.go`
- [JWT middleware](https://github.com/morozkoart/codecollab/blob/master/backend/internal/api/http/middleware/auth.go): `backend/internal/api/http/middleware/auth.go`
- [Auth service](https://github.com/morozkoart/codecollab/blob/master/backend/internal/services/auth.go): `backend/internal/services/auth.go`
- [JWT service](https://github.com/morozkoart/codecollab/blob/master/backend/pkg/jwt/jwt.go): `backend/pkg/jwt/jwt.go`
- [Password checks](https://github.com/morozkoart/codecollab/blob/master/backend/pkg/password/password.go): `backend/pkg/password/password.go`

### User data

- [User models](https://github.com/morozkoart/codecollab/blob/master/backend/internal/domain/user.go): `backend/internal/domain/user.go`
- [User repository](https://github.com/morozkoart/codecollab/blob/master/backend/internal/repository/user.go): `backend/internal/repository/user.go`
- **PostgreSQL**

### Other components

- **API client**

## Connections

- API client → HTTP app: HTTP requests
- HTTP app → V1 router: dispatches
- V1 router → Auth handlers: routes auth
- V1 router → JWT middleware: protects routes
- Auth handlers → Auth service: calls
- Auth handlers → JSON responses: writes responses
- Auth service → User repository: reads and writes users
- Auth service → Password checks: checks password
- Auth service → JWT service: generates token
- JWT middleware → JWT service: validates token
- Server startup → Configuration: loads settings
- Server startup → PostgreSQL: connects
- Server startup → User repository: constructs
- Server startup → Auth service: constructs
- Server startup → HTTP app: starts and stops
- Auth service → User models: uses user models
