# amirovvas/localy architecture

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

- Interactive diagram: https://gitdiagram.com/amirovvas/localy
- Repository: https://github.com/amirovvas/localy

## Overview

This repository implements a community chat product: users register or log in, discover or join communities, then exchange messages in community rooms; supporting capabilities include live updates, image attachments, events, summaries, and moderation. The graph shows the frontend request path into backend controllers and services, plus database and socket/storage integrations. Several important areas are present in the tree but were not sampled, so their internal links are omitted where call evidence is unavailable.

Main entry points: [`backend/src/plugins/pg.ts`](https://github.com/amirovvas/localy/blob/master/backend/src/plugins/pg.ts) (PostgreSQL), [`backend/src/services/message.service.ts`](https://github.com/amirovvas/localy/blob/master/backend/src/services/message.service.ts) (Messaging service), [`frontend/src/hooks/api/api.ts`](https://github.com/amirovvas/localy/blob/master/frontend/src/hooks/api/api.ts) (HTTP client), [`backend/src/services/reaction.service.ts`](https://github.com/amirovvas/localy/blob/master/backend/src/services/reaction.service.ts) (Reactions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["Next.js app<br/>[page.tsx]"]
  node_chatui["Chat interface<br/>[ChatArea.tsx]"]
  node_clienthooks["Chat data hooks<br/>[useGetMessages.ts]"]
  node_apiclient["HTTP client<br/>[api.ts]"]
  node_authhooks["Auth hooks<br/>[useLogin.ts]"]
  node_communityhooks["Community hooks"]
  node_adminui["Admin console<br/>[Admin.tsx]"]
end

subgraph group_api["Backend API"]
  node_routes["API routes<br/>[auth.route.ts]"]
  node_authctl["Auth controllers<br/>[auth.controller.ts]"]
  node_communityctl["Community controllers"]
  node_messagectl["Message controllers"]
end

subgraph group_domain["Product services"]
  node_authsvc["Identity service<br/>[auth.service.ts]"]
  node_communitysvc["Community service"]
  node_messagesvc["Messaging service<br/>[message.service.ts]"]
  node_reaction["Reactions"]
  node_report["Moderation reports<br/>[report.service.ts]"]
  node_events["Community events<br/>[event.service.ts]"]
  node_summary["Room summaries<br/>[summary.service.ts]"]
  node_uploads["Image uploads<br/>[upload.service.ts]"]
end

subgraph group_infra["Persistence and integrations"]
  node_pg[("PostgreSQL<br/>[pg.ts]")]
  node_socket["Realtime sockets<br/>[socket.ts]"]
  node_storage["Supabase Storage<br/>[storage.ts]"]
end

node_user(("Community member"))

node_user -->|"uses"| node_web
node_web -.->|"opens chat"| node_chatui
node_chatui -.->|"loads chat data"| node_clienthooks
node_clienthooks -->|"requests"| node_apiclient
node_authhooks -.->|"requests"| node_apiclient
node_communityhooks -->|"requests"| node_apiclient
node_adminui -.->|"moderates via"| node_apiclient
node_apiclient -.->|"HTTP requests"| node_routes
node_routes -->|"routes auth"| node_authctl
node_authctl -->|"calls"| node_authsvc
node_communityctl -->|"calls"| node_communitysvc
node_messagectl -->|"calls"| node_messagesvc
node_messagectl -->|"calls"| node_reaction
node_authsvc -->|"validates choices"| node_communitysvc
node_authsvc -->|"reads and writes"| node_pg
node_communitysvc -->|"reads and writes"| node_pg
node_messagesvc -->|"reads and writes"| node_pg
node_reaction -->|"reads and writes"| node_pg
node_report -->|"reads and writes"| node_pg
node_events -->|"reads and writes"| node_pg
node_messagesvc -->|"selects reactions"| node_reaction
node_messagesvc -->|"emits room events"| node_socket
node_reaction -->|"emits updates"| node_socket
node_messagesvc -->|"validates and removes attachments"| node_storage
node_uploads -.->|"stores images"| node_storage
node_summary -.->|"reads data"| node_pg

click node_web "https://github.com/amirovvas/localy/blob/master/frontend/src/app/page.tsx"
click node_chatui "https://github.com/amirovvas/localy/blob/master/frontend/src/components/pages/chat/ChatArea.tsx"
click node_clienthooks "https://github.com/amirovvas/localy/blob/master/frontend/src/hooks/messages/useGetMessages.ts"
click node_apiclient "https://github.com/amirovvas/localy/blob/master/frontend/src/hooks/api/api.ts"
click node_authhooks "https://github.com/amirovvas/localy/blob/master/frontend/src/hooks/auth/useLogin.ts"
click node_communityhooks "https://github.com/amirovvas/localy/blob/master/frontend/src/hooks/communities/useDiscoverCommunities.ts"
click node_adminui "https://github.com/amirovvas/localy/blob/master/frontend/src/components/pages/admin/Admin.tsx"
click node_routes "https://github.com/amirovvas/localy/blob/master/backend/src/routes/auth.route.ts"
click node_authctl "https://github.com/amirovvas/localy/blob/master/backend/src/controllers/auth.controller.ts"
click node_communityctl "https://github.com/amirovvas/localy/blob/master/backend/src/controllers/community.controller.ts"
click node_messagectl "https://github.com/amirovvas/localy/blob/master/backend/src/controllers/message.controller.ts"
click node_authsvc "https://github.com/amirovvas/localy/blob/master/backend/src/services/auth.service.ts"
click node_communitysvc "https://github.com/amirovvas/localy/blob/master/backend/src/services/community.service.ts"
click node_messagesvc "https://github.com/amirovvas/localy/blob/master/backend/src/services/message.service.ts"
click node_reaction "https://github.com/amirovvas/localy/blob/master/backend/src/services/reaction.service.ts"
click node_report "https://github.com/amirovvas/localy/blob/master/backend/src/services/report.service.ts"
click node_events "https://github.com/amirovvas/localy/blob/master/backend/src/services/event.service.ts"
click node_summary "https://github.com/amirovvas/localy/blob/master/backend/src/services/summary.service.ts"
click node_uploads "https://github.com/amirovvas/localy/blob/master/backend/src/services/upload.service.ts"
click node_pg "https://github.com/amirovvas/localy/blob/master/backend/src/plugins/pg.ts"
click node_socket "https://github.com/amirovvas/localy/blob/master/backend/src/plugins/socket.ts"
click node_storage "https://github.com/amirovvas/localy/blob/master/backend/src/plugins/storage.ts"

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_web,node_chatui,node_clienthooks,node_apiclient,node_authhooks,node_communityhooks,node_adminui toneBlue
class node_routes,node_authctl,node_communityctl,node_messagectl toneAmber
class node_authsvc,node_communitysvc,node_messagesvc,node_reaction,node_report,node_events,node_summary,node_uploads toneMint
class node_pg,node_socket,node_storage toneRose
class node_user toneIndigo
```

## Components

### Web client

- [Next.js app](https://github.com/amirovvas/localy/blob/master/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Chat interface](https://github.com/amirovvas/localy/blob/master/frontend/src/components/pages/chat/ChatArea.tsx): `frontend/src/components/pages/chat/ChatArea.tsx`
- [Chat data hooks](https://github.com/amirovvas/localy/blob/master/frontend/src/hooks/messages/useGetMessages.ts): `frontend/src/hooks/messages/useGetMessages.ts`
- [HTTP client](https://github.com/amirovvas/localy/blob/master/frontend/src/hooks/api/api.ts): `frontend/src/hooks/api/api.ts`
- [Auth hooks](https://github.com/amirovvas/localy/blob/master/frontend/src/hooks/auth/useLogin.ts): `frontend/src/hooks/auth/useLogin.ts`
- [Community hooks](https://github.com/amirovvas/localy/blob/master/frontend/src/hooks/communities/useDiscoverCommunities.ts): `frontend/src/hooks/communities/useDiscoverCommunities.ts`
- [Admin console](https://github.com/amirovvas/localy/blob/master/frontend/src/components/pages/admin/Admin.tsx): `frontend/src/components/pages/admin/Admin.tsx`

### Backend API

- [API routes](https://github.com/amirovvas/localy/blob/master/backend/src/routes/auth.route.ts): `backend/src/routes/auth.route.ts`
- [Auth controllers](https://github.com/amirovvas/localy/blob/master/backend/src/controllers/auth.controller.ts): `backend/src/controllers/auth.controller.ts`
- [Community controllers](https://github.com/amirovvas/localy/blob/master/backend/src/controllers/community.controller.ts): `backend/src/controllers/community.controller.ts`
- [Message controllers](https://github.com/amirovvas/localy/blob/master/backend/src/controllers/message.controller.ts): `backend/src/controllers/message.controller.ts`

### Product services

- [Identity service](https://github.com/amirovvas/localy/blob/master/backend/src/services/auth.service.ts): `backend/src/services/auth.service.ts`
- [Community service](https://github.com/amirovvas/localy/blob/master/backend/src/services/community.service.ts): `backend/src/services/community.service.ts`
- [Messaging service](https://github.com/amirovvas/localy/blob/master/backend/src/services/message.service.ts): `backend/src/services/message.service.ts`
- [Reactions](https://github.com/amirovvas/localy/blob/master/backend/src/services/reaction.service.ts): `backend/src/services/reaction.service.ts`
- [Moderation reports](https://github.com/amirovvas/localy/blob/master/backend/src/services/report.service.ts): `backend/src/services/report.service.ts`
- [Community events](https://github.com/amirovvas/localy/blob/master/backend/src/services/event.service.ts): `backend/src/services/event.service.ts`
- [Room summaries](https://github.com/amirovvas/localy/blob/master/backend/src/services/summary.service.ts): `backend/src/services/summary.service.ts`
- [Image uploads](https://github.com/amirovvas/localy/blob/master/backend/src/services/upload.service.ts): `backend/src/services/upload.service.ts`

### Persistence and integrations

- [PostgreSQL](https://github.com/amirovvas/localy/blob/master/backend/src/plugins/pg.ts): `backend/src/plugins/pg.ts`
- [Realtime sockets](https://github.com/amirovvas/localy/blob/master/backend/src/plugins/socket.ts): `backend/src/plugins/socket.ts`
- [Supabase Storage](https://github.com/amirovvas/localy/blob/master/backend/src/plugins/storage.ts): `backend/src/plugins/storage.ts`

### Other components

- **Community member**

## Connections

- Community member → Next.js app: uses
- Next.js app → Chat interface: opens chat
- Chat interface → Chat data hooks: loads chat data
- Chat data hooks → HTTP client: requests (evidence: `frontend/src/hooks/messages/useGetMessages.ts`)
- Auth hooks → HTTP client: requests
- Community hooks → HTTP client: requests (evidence: `frontend/src/hooks/communities/useDiscoverCommunities.ts`)
- Admin console → HTTP client: moderates via
- HTTP client → API routes: HTTP requests
- API routes → Auth controllers: routes auth (evidence: `backend/src/routes/auth.route.ts`)
- Auth controllers → Identity service: calls (evidence: `backend/src/controllers/auth.controller.ts`)
- Community controllers → Community service: calls (evidence: `backend/src/controllers/community.controller.ts`)
- Message controllers → Messaging service: calls (evidence: `backend/src/controllers/message.controller.ts`)
- Message controllers → Reactions: calls (evidence: `backend/src/controllers/message.controller.ts`)
- Identity service → Community service: validates choices (evidence: `backend/src/services/auth.service.ts`)
- Identity service → PostgreSQL: reads and writes (evidence: `backend/src/services/auth.service.ts`)
- Community service → PostgreSQL: reads and writes (evidence: `backend/src/services/community.service.ts`)
- Messaging service → PostgreSQL: reads and writes (evidence: `backend/src/services/message.service.ts`)
- Reactions → PostgreSQL: reads and writes (evidence: `backend/src/services/reaction.service.ts`)
- Moderation reports → PostgreSQL: reads and writes (evidence: `backend/src/services/report.service.ts`)
- Community events → PostgreSQL: reads and writes (evidence: `backend/src/services/event.service.ts`)
- Messaging service → Reactions: selects reactions (evidence: `backend/src/services/message.service.ts`)
- Messaging service → Realtime sockets: emits room events (evidence: `backend/src/services/message.service.ts`)
- Reactions → Realtime sockets: emits updates (evidence: `backend/src/services/reaction.service.ts`)
- Messaging service → Supabase Storage: validates and removes attachments (evidence: `backend/src/services/message.service.ts`)
- Image uploads → Supabase Storage: stores images
- Room summaries → PostgreSQL: reads data
