# go-park-mail-ru/2026_2_totallyswipes architecture

> Architecture diagram of the GitHub repository go-park-mail-ru/2026_2_totallyswipes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/go-park-mail-ru/2026_2_totallyswipes
- Repository: https://github.com/go-park-mail-ru/2026_2_totallyswipes

## Overview

This is a Go backend for a Tinder-style dating product. Its principal workflow is account registration/login, profile and photo creation, authenticated personality-test submission, then profile-based feed generation with compatibility scores. The graph also includes profile retrieval, refreshable sessions, and supporting middleware and persistence. Several test, profile-short, and storage implementations were not excerpted; their presence and some wiring are supported by the entry-point routes, but their internal behavior is not inferred.

Main entry points: [`cmd/api/main.go`](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/cmd/api/main.go) (HTTP Server), [`internal/service/auth_service.go`](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/service/auth_service.go) (Authentication), [`internal/service/profile_service.go`](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/service/profile_service.go) (Profiles and Feed), [`internal/handler/post_auth_register_handler.go`](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/handler/post_auth_register_handler.go) (Auth Handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["HTTP Server<br/>[main.go]"]
  node_auth_routes["Auth Routes<br/>[main.go]"]
  node_auth_handlers["Auth Handlers"]
  node_feed_handler["Feed Handler"]
  node_test_handlers["Test Handlers"]
  node_profile_handler["Short Profile Handler"]
end

subgraph group_domain["Dating Services"]
  node_auth_service["Authentication<br/>[auth_service.go]"]
  node_profile_service["Profiles and Feed<br/>[profile_service.go]"]
  node_compatibility["Compatibility Scoring"]
  node_test_service["Personality Tests"]
  node_validation["Input Validation<br/>[validate.go]"]
end

subgraph group_persistence["Persistence"]
  node_auth_repo["User Repository"]
  node_profile_repo["Profile Repository"]
  node_session_repo["Session Repository"]
  node_postgres[("PostgreSQL<br/>[postgres.go]")]
  node_redis[("Redis<br/>[redis.go]")]
  node_photo_storage["Photo Storage<br/>[photo.go]"]
end

subgraph group_security["Auth Security"]
  node_auth_middleware["JWT Middleware<br/>[auth.go]"]
  node_token_issuer["JWT Tokens<br/>[token.go]"]
  node_password_hash["Password Hashing<br/>[hasher.go]"]
  node_config["Configuration<br/>[config.go]"]
end

node_client(("API Client"))

node_client -->|"sends requests"| node_server
node_server -->|"routes auth"| node_auth_routes
node_auth_routes -->|"dispatches"| node_auth_handlers
node_server -->|"routes feed"| node_feed_handler
node_server -->|"routes tests"| node_test_handlers
node_server -->|"routes profile"| node_profile_handler
node_auth_handlers -->|"calls"| node_auth_service
node_auth_handlers -->|"validates input"| node_validation
node_auth_service -->|"creates and finds users"| node_auth_repo
node_auth_service -->|"manages sessions"| node_session_repo
node_auth_service -->|"checks completion"| node_profile_service
node_auth_service -->|"hashes passwords"| node_password_hash
node_auth_service -->|"issues access tokens"| node_token_issuer
node_auth_service -->|"deletes orphan photos"| node_photo_storage
node_auth_repo -->|"queries"| node_postgres
node_session_repo -->|"stores sessions"| node_redis
node_feed_handler -->|"requests feed"| node_profile_service
node_profile_handler -->|"requests profile"| node_profile_service
node_profile_service -->|"loads profiles"| node_profile_repo
node_profile_service -->|"calculates compatibility"| node_compatibility
node_profile_repo -.->|"reads and writes"| node_postgres
node_test_handlers -->|"submits and reads tests"| node_test_service
node_test_service -.->|"updates profile results"| node_profile_service
node_server -->|"protects routes"| node_auth_middleware
node_auth_middleware -->|"parses tokens"| node_token_issuer
node_server -->|"loads settings"| node_config

click node_server "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/cmd/api/main.go"
click node_auth_routes "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/cmd/api/main.go"
click node_auth_handlers "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/handler/post_auth_register_handler.go"
click node_feed_handler "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/handler/get_feed_handler.go"
click node_test_handlers "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/handler/get_tests_current_handler.go"
click node_profile_handler "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/handler/get_profile_short_handler.go"
click node_auth_service "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/service/auth_service.go"
click node_profile_service "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/service/profile_service.go"
click node_compatibility "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/service/compatibility_service.go"
click node_test_service "https://github.com/go-park-mail-ru/2026_2_totallyswipes/tree/main/internal/service"
click node_validation "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/validate/validate.go"
click node_auth_repo "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/repository/auth_user_repository.go"
click node_profile_repo "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/repository/profile_repository.go"
click node_session_repo "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/repository/session_repository.go"
click node_postgres "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/storage/postgres.go"
click node_redis "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/storage/redis.go"
click node_photo_storage "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/storage/photo.go"
click node_auth_middleware "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/middleware/auth.go"
click node_token_issuer "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/auth/token.go"
click node_password_hash "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/auth/hasher.go"
click node_config "https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/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_auth_routes,node_auth_handlers,node_feed_handler,node_test_handlers,node_profile_handler,node_client toneBlue
class node_auth_service,node_profile_service,node_compatibility,node_test_service,node_validation toneAmber
class node_auth_repo,node_profile_repo,node_session_repo,node_postgres,node_redis,node_photo_storage toneMint
class node_auth_middleware,node_token_issuer,node_password_hash,node_config toneRose
```

## Components

### HTTP API

- [HTTP Server](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/cmd/api/main.go): `cmd/api/main.go`
- [Auth Routes](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/cmd/api/main.go): `cmd/api/main.go`
- [Auth Handlers](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/handler/post_auth_register_handler.go): `internal/handler/post_auth_register_handler.go`
- [Feed Handler](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/handler/get_feed_handler.go): `internal/handler/get_feed_handler.go`
- [Test Handlers](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/handler/get_tests_current_handler.go): `internal/handler/get_tests_current_handler.go`
- [Short Profile Handler](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/handler/get_profile_short_handler.go): `internal/handler/get_profile_short_handler.go`

### Dating Services

- [Authentication](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/service/auth_service.go): `internal/service/auth_service.go`
- [Profiles and Feed](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/service/profile_service.go): `internal/service/profile_service.go`
- [Compatibility Scoring](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/service/compatibility_service.go): `internal/service/compatibility_service.go`
- [Personality Tests](https://github.com/go-park-mail-ru/2026_2_totallyswipes/tree/main/internal/service): `internal/service`
- [Input Validation](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/validate/validate.go): `internal/validate/validate.go`

### Persistence

- [User Repository](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/repository/auth_user_repository.go): `internal/repository/auth_user_repository.go`
- [Profile Repository](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/repository/profile_repository.go): `internal/repository/profile_repository.go`
- [Session Repository](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/repository/session_repository.go): `internal/repository/session_repository.go`
- [PostgreSQL](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/storage/postgres.go): `internal/storage/postgres.go`
- [Redis](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/storage/redis.go): `internal/storage/redis.go`
- [Photo Storage](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/storage/photo.go): `internal/storage/photo.go`

### Auth Security

- [JWT Middleware](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/middleware/auth.go): `internal/middleware/auth.go`
- [JWT Tokens](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/auth/token.go): `internal/auth/token.go`
- [Password Hashing](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/auth/hasher.go): `internal/auth/hasher.go`
- [Configuration](https://github.com/go-park-mail-ru/2026_2_totallyswipes/blob/main/internal/config/config.go): `internal/config/config.go`

### Other components

- **API Client**

## Connections

- API Client → HTTP Server: sends requests (evidence: `cmd/api/main.go`)
- HTTP Server → Auth Routes: routes auth (evidence: `cmd/api/main.go`)
- Auth Routes → Auth Handlers: dispatches (evidence: `cmd/api/main.go`)
- HTTP Server → Feed Handler: routes feed (evidence: `cmd/api/main.go`)
- HTTP Server → Test Handlers: routes tests (evidence: `cmd/api/main.go`)
- HTTP Server → Short Profile Handler: routes profile (evidence: `cmd/api/main.go`)
- Auth Handlers → Authentication: calls (evidence: `internal/handler/post_auth_register_handler.go`)
- Auth Handlers → Input Validation: validates input (evidence: `internal/handler/post_auth_register_handler.go`)
- Authentication → User Repository: creates and finds users (evidence: `internal/service/auth_service.go`)
- Authentication → Session Repository: manages sessions (evidence: `internal/service/auth_service.go`)
- Authentication → Profiles and Feed: checks completion (evidence: `internal/service/auth_service.go`)
- Authentication → Password Hashing: hashes passwords (evidence: `internal/service/auth_service.go`)
- Authentication → JWT Tokens: issues access tokens (evidence: `internal/service/auth_service.go`)
- Authentication → Photo Storage: deletes orphan photos (evidence: `internal/service/auth_service.go`)
- User Repository → PostgreSQL: queries (evidence: `internal/repository/auth_user_repository.go`)
- Session Repository → Redis: stores sessions (evidence: `internal/repository/session_repository.go`)
- Feed Handler → Profiles and Feed: requests feed
- Short Profile Handler → Profiles and Feed: requests profile
- Profiles and Feed → Profile Repository: loads profiles (evidence: `internal/service/profile_service.go`)
- Profiles and Feed → Compatibility Scoring: calculates compatibility (evidence: `internal/service/profile_service.go`)
- Profile Repository → PostgreSQL: reads and writes
- Test Handlers → Personality Tests: submits and reads tests
- Personality Tests → Profiles and Feed: updates profile results
- HTTP Server → JWT Middleware: protects routes (evidence: `cmd/api/main.go`)
- JWT Middleware → JWT Tokens: parses tokens (evidence: `internal/middleware/auth.go`)
- HTTP Server → Configuration: loads settings (evidence: `cmd/api/main.go`)
