# aamirnawaz/go_authentication_app architecture

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

- Interactive diagram: https://gitdiagram.com/aamirnawaz/go_authentication_app
- Repository: https://github.com/aamirnawaz/go_authentication_app

## Overview

This is a small Go/Fiber authentication API. Requests enter through Fiber routes and reach handlers for registration, login, logout, user lookup, or a placeholder user endpoint; authentication handlers use the MySQL-backed GORM store and the User model. The README identifies JWT authentication as the product capability, and the sampled controller shows cookie-based token issuance and lookup. MongoDB code is present but its connection is not invoked by the application startup, and the Mongo user route is only a placeholder. The graph reflects sampled code; no Mongo request-to-store flow is shown.

Main entry points: [`routes/routes.go`](https://github.com/aamirnawaz/go_authentication_app/blob/main/routes/routes.go) (Route setup), [`controllers/authController.go`](https://github.com/aamirnawaz/go_authentication_app/blob/main/controllers/authController.go) (Auth handlers), [`db/Connection.go`](https://github.com/aamirnawaz/go_authentication_app/blob/main/db/Connection.go) (GORM connection), [`main.go`](https://github.com/aamirnawaz/go_authentication_app/blob/main/main.go) (Application startup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_startup["Application startup<br/>[main.go]"]
  node_routing["Route setup<br/>[routes.go]"]
  node_user_endpoint["User placeholder<br/>[authController.go]"]
  node_mongo_endpoint["Mongo placeholder"]
end

subgraph group_auth["Authentication"]
  node_auth_handlers["Auth handlers<br/>[authController.go]"]
  node_user_model["User model<br/>[user.go]"]
end

subgraph group_mysql["MySQL persistence"]
  node_gorm_connection["GORM connection<br/>[Connection.go]"]
  node_mysql_store[("MySQL database")]
end

subgraph group_mongo["MongoDB integration"]
  node_mongo_connection["Mongo connection"]
  node_mongo_user_model["Mongo user model<br/>[m_user.go]"]
  node_mongo_store[("MongoDB database")]
end

node_client(("HTTP client"))

node_client -->|"sends requests"| node_routing
node_startup -->|"connects"| node_gorm_connection
node_startup -->|"sets up"| node_routing
node_routing -->|"routes to"| node_user_endpoint
node_routing -->|"routes to"| node_auth_handlers
node_routing -->|"routes to"| node_mongo_endpoint
node_auth_handlers -->|"queries"| node_gorm_connection
node_auth_handlers -->|"uses"| node_user_model
node_gorm_connection -->|"opens"| node_mysql_store
node_mongo_connection -->|"connects"| node_mongo_store
node_mongo_connection -.->|"stores records"| node_mongo_user_model

click node_startup "https://github.com/aamirnawaz/go_authentication_app/blob/main/main.go"
click node_routing "https://github.com/aamirnawaz/go_authentication_app/blob/main/routes/routes.go"
click node_user_endpoint "https://github.com/aamirnawaz/go_authentication_app/blob/main/controllers/authController.go"
click node_mongo_endpoint "https://github.com/aamirnawaz/go_authentication_app/blob/main/controllers/m_authController.go"
click node_auth_handlers "https://github.com/aamirnawaz/go_authentication_app/blob/main/controllers/authController.go"
click node_user_model "https://github.com/aamirnawaz/go_authentication_app/blob/main/models/user.go"
click node_gorm_connection "https://github.com/aamirnawaz/go_authentication_app/blob/main/db/Connection.go"
click node_mongo_connection "https://github.com/aamirnawaz/go_authentication_app/blob/main/db/MongodbConnection.go"
click node_mongo_user_model "https://github.com/aamirnawaz/go_authentication_app/blob/main/models/m_user.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_startup,node_routing,node_user_endpoint,node_mongo_endpoint,node_client toneBlue
class node_auth_handlers,node_user_model toneAmber
class node_gorm_connection,node_mysql_store toneMint
class node_mongo_connection,node_mongo_user_model,node_mongo_store toneRose
```

## Components

### HTTP API

- [Application startup](https://github.com/aamirnawaz/go_authentication_app/blob/main/main.go): `main.go`
- [Route setup](https://github.com/aamirnawaz/go_authentication_app/blob/main/routes/routes.go): `routes/routes.go`
- [User placeholder](https://github.com/aamirnawaz/go_authentication_app/blob/main/controllers/authController.go): `controllers/authController.go`
- [Mongo placeholder](https://github.com/aamirnawaz/go_authentication_app/blob/main/controllers/m_authController.go): `controllers/m_authController.go`

### Authentication

- [Auth handlers](https://github.com/aamirnawaz/go_authentication_app/blob/main/controllers/authController.go): `controllers/authController.go`
- [User model](https://github.com/aamirnawaz/go_authentication_app/blob/main/models/user.go): `models/user.go`

### MySQL persistence

- [GORM connection](https://github.com/aamirnawaz/go_authentication_app/blob/main/db/Connection.go): `db/Connection.go`
- **MySQL database**

### MongoDB integration

- [Mongo connection](https://github.com/aamirnawaz/go_authentication_app/blob/main/db/MongodbConnection.go): `db/MongodbConnection.go`
- [Mongo user model](https://github.com/aamirnawaz/go_authentication_app/blob/main/models/m_user.go): `models/m_user.go`
- **MongoDB database**

### Other components

- **HTTP client**

## Connections

- HTTP client → Route setup: sends requests (evidence: `routes/routes.go`)
- Application startup → GORM connection: connects (evidence: `main.go`)
- Application startup → Route setup: sets up (evidence: `main.go`)
- Route setup → User placeholder: routes to (evidence: `routes/routes.go`)
- Route setup → Auth handlers: routes to (evidence: `routes/routes.go`)
- Route setup → Mongo placeholder: routes to (evidence: `routes/routes.go`)
- Auth handlers → GORM connection: queries (evidence: `controllers/authController.go`)
- Auth handlers → User model: uses (evidence: `controllers/authController.go`)
- GORM connection → MySQL database: opens (evidence: `db/Connection.go`)
- Mongo connection → MongoDB database: connects (evidence: `db/MongodbConnection.go`)
- Mongo connection → Mongo user model: stores records
