# gnelshahnazaryan/eventhub-api architecture

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

- Interactive diagram: https://gitdiagram.com/gnelshahnazaryan/eventhub-api
- Repository: https://github.com/gnelshahnazaryan/eventhub-api

## Overview

EventHub is an Express API for account access and event participation: clients authenticate, browse or manage events, join or leave them, and submit or manage attendee reviews. Requests pass through API routing and middleware to controllers, services, repositories, and MongoDB models. The sampled source supports detailed authentication, event, and review flows; user-management internals and some route wiring are represented only at their tree-supported module level.

Main entry points: [`src/repositories/user.repository.js`](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/repositories/user.repository.js) (User repository), [`src/routes/index.js`](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/routes/index.js) (API routes), [`src/repositories/event.repository.js`](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/repositories/event.repository.js) (Event repository), [`src/routes/auth.routes.js`](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/routes/auth.routes.js) (Auth routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API Entry"]
  node_app["Express app<br/>[app.js]"]
  node_routes["API routes<br/>[index.js]"]
  node_dbconfig["Database connection<br/>[db.js]"]
end

subgraph group_identity["Identity"]
  node_authroutes["Auth routes<br/>[auth.routes.js]"]
  node_authctrl["Auth controller<br/>[auth.controller.js]"]
  node_authsvc["Auth service<br/>[auth.service.js]"]
  node_authmw["Authentication middleware<br/>[auth.middleware.js]"]
  node_useroutes["User routes<br/>[user.routes.js]"]
  node_userctrl["User controller<br/>[user.controller.js]"]
  node_usersvc["User service<br/>[user.service.js]"]
end

subgraph group_events["Events"]
  node_eventroutes["Event routes<br/>[event.routes.js]"]
  node_eventctrl["Event controller"]
  node_eventsvc["Event service<br/>[event.service.js]"]
end

subgraph group_reviews["Reviews"]
  node_reviewctrl["Review controller"]
  node_reviewroutes["Review routes<br/>[review.routes.js]"]
  node_reviewservice["Review service<br/>[review.service.js]"]
end

subgraph group_data["Persistence"]
  node_userrepo["User repository<br/>[user.repository.js]"]
  node_eventrepo["Event repository"]
  node_reviewrepo["Review repository"]
  node_usermodel["User model<br/>[user.model.js]"]
  node_eventmodel["Event model<br/>[event.model.js]"]
  node_attendeemodel["Attendance model"]
  node_reviewmodel["Review model<br/>[review.model.js]"]
end

node_client(("API client"))
node_database[("MongoDB")]

node_client -->|"sends requests"| node_app
node_app -->|"mounts API"| node_routes
node_routes -->|"dispatches"| node_authroutes
node_routes -->|"dispatches"| node_eventroutes
node_routes -->|"dispatches"| node_useroutes
node_eventroutes -->|"dispatches reviews"| node_reviewctrl
node_authroutes -->|"dispatches"| node_authctrl
node_authroutes -->|"authenticates logout"| node_authmw
node_authctrl -->|"calls"| node_authsvc
node_authsvc -->|"reads and updates"| node_userrepo
node_authmw -->|"checks user"| node_userrepo
node_useroutes -->|"dispatches"| node_userctrl
node_userctrl -->|"calls"| node_usersvc
node_usersvc -->|"uses"| node_userrepo
node_eventroutes -->|"dispatches"| node_eventctrl
node_eventctrl -->|"calls"| node_eventsvc
node_eventsvc -->|"reads and changes events"| node_eventrepo
node_eventsvc -->|"checks organizer"| node_userrepo
node_eventrepo -->|"queries"| node_eventmodel
node_eventrepo -->|"manages attendance"| node_attendeemodel
node_reviewroutes -->|"dispatches"| node_reviewctrl
node_reviewctrl -->|"calls"| node_reviewservice
node_reviewservice -->|"checks event attendance"| node_eventrepo
node_reviewservice -->|"reads and changes reviews"| node_reviewrepo
node_reviewrepo -->|"queries"| node_reviewmodel
node_userrepo -->|"queries"| node_usermodel
node_dbconfig -->|"connects"| node_database

click node_app "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/app.js"
click node_routes "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/routes/index.js"
click node_authroutes "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/routes/auth.routes.js"
click node_authctrl "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/controllers/auth.controller.js"
click node_authsvc "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/services/auth.service.js"
click node_authmw "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/middlewares/auth.middleware.js"
click node_useroutes "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/routes/user.routes.js"
click node_userctrl "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/controllers/user.controller.js"
click node_usersvc "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/services/user.service.js"
click node_eventroutes "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/routes/event.routes.js"
click node_eventctrl "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/controllers/event.controller.js"
click node_eventsvc "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/services/event.service.js"
click node_reviewctrl "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/controllers/review.controller.js"
click node_reviewroutes "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/routes/review.routes.js"
click node_reviewservice "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/services/review.service.js"
click node_userrepo "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/repositories/user.repository.js"
click node_eventrepo "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/repositories/event.repository.js"
click node_reviewrepo "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/repositories/review.repository.js"
click node_usermodel "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/models/user.model.js"
click node_eventmodel "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/models/event.model.js"
click node_attendeemodel "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/models/eventAttendee.model.js"
click node_reviewmodel "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/models/review.model.js"
click node_dbconfig "https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/config/db.js"

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_app,node_routes,node_dbconfig,node_client toneBlue
class node_authroutes,node_authctrl,node_authsvc,node_authmw,node_useroutes,node_userctrl,node_usersvc,node_database toneAmber
class node_eventroutes,node_eventctrl,node_eventsvc toneMint
class node_reviewctrl,node_reviewroutes,node_reviewservice toneRose
class node_userrepo,node_eventrepo,node_reviewrepo,node_usermodel,node_eventmodel,node_attendeemodel,node_reviewmodel toneIndigo
```

## Components

### API Entry

- [Express app](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/app.js): `src/app.js`
- [API routes](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/routes/index.js): `src/routes/index.js`
- [Database connection](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/config/db.js): `src/config/db.js`

### Identity

- [Auth routes](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/routes/auth.routes.js): `src/routes/auth.routes.js`
- [Auth controller](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/controllers/auth.controller.js): `src/controllers/auth.controller.js`
- [Auth service](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/services/auth.service.js): `src/services/auth.service.js`
- [Authentication middleware](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/middlewares/auth.middleware.js): `src/middlewares/auth.middleware.js`
- [User routes](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/routes/user.routes.js): `src/routes/user.routes.js`
- [User controller](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/controllers/user.controller.js): `src/controllers/user.controller.js`
- [User service](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/services/user.service.js): `src/services/user.service.js`

### Events

- [Event routes](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/routes/event.routes.js): `src/routes/event.routes.js`
- [Event controller](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/controllers/event.controller.js): `src/controllers/event.controller.js`
- [Event service](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/services/event.service.js): `src/services/event.service.js`

### Reviews

- [Review controller](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/controllers/review.controller.js): `src/controllers/review.controller.js`
- [Review routes](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/routes/review.routes.js): `src/routes/review.routes.js`
- [Review service](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/services/review.service.js): `src/services/review.service.js`

### Persistence

- [User repository](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/repositories/user.repository.js): `src/repositories/user.repository.js`
- [Event repository](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/repositories/event.repository.js): `src/repositories/event.repository.js`
- [Review repository](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/repositories/review.repository.js): `src/repositories/review.repository.js`
- [User model](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/models/user.model.js): `src/models/user.model.js`
- [Event model](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/models/event.model.js): `src/models/event.model.js`
- [Attendance model](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/models/eventAttendee.model.js): `src/models/eventAttendee.model.js`
- [Review model](https://github.com/gnelshahnazaryan/eventhub-api/blob/main/src/models/review.model.js): `src/models/review.model.js`

### Other components

- **API client**
- **MongoDB**

## Connections

- API client → Express app: sends requests
- Express app → API routes: mounts API
- API routes → Auth routes: dispatches
- API routes → Event routes: dispatches
- API routes → User routes: dispatches
- Event routes → Review controller: dispatches reviews
- Auth routes → Auth controller: dispatches
- Auth routes → Authentication middleware: authenticates logout
- Auth controller → Auth service: calls
- Auth service → User repository: reads and updates
- Authentication middleware → User repository: checks user
- User routes → User controller: dispatches
- User controller → User service: calls
- User service → User repository: uses
- Event routes → Event controller: dispatches
- Event controller → Event service: calls
- Event service → Event repository: reads and changes events
- Event service → User repository: checks organizer
- Event repository → Event model: queries
- Event repository → Attendance model: manages attendance
- Review routes → Review controller: dispatches
- Review controller → Review service: calls
- Review service → Event repository: checks event attendance
- Review service → Review repository: reads and changes reviews
- Review repository → Review model: queries
- User repository → User model: queries
- Database connection → MongoDB: connects
