# holygoose17/petreactback architecture

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

- Interactive diagram: https://gitdiagram.com/holygoose17/petreactback
- Repository: https://github.com/holygoose17/petreactback

## Overview

This is a football-club management API with user registration, login and protected account access, plus CRUD workflows for players, clubs, leagues, owners, agents and positions. Requests enter through Express routing, are handled by controllers and delegated to services; services use TypeORM entities and a MySQL data source. The graph keeps authentication separate from football-management operations. Source excerpts chiefly cover player, club, user and authentication behavior; other domain links rely on the SOURCE INDEX, and the README provides no additional capability details.

Main entry points: [`src/controllers`](https://github.com/holygoose17/petreactback/tree/main/src/controllers) (Request controllers), [`src/config/data-source.ts`](https://github.com/holygoose17/petreactback/blob/main/src/config/data-source.ts) (TypeORM data source), [`src/entities`](https://github.com/holygoose17/petreactback/tree/main/src/entities) (Domain entities), [`src/app.ts`](https://github.com/holygoose17/petreactback/blob/main/src/app.ts) (Express application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API request handling"]
  node_application["Express application<br/>[app.ts]"]
  node_routes["Domain routes"]
  node_controllers["Request controllers"]
  node_errorhandler["Error middleware"]
end

subgraph group_identity["Identity and access"]
  node_authmiddleware["JWT middleware"]
  node_authservice["Authentication service<br/>[auth.service.ts]"]
  node_userservice["User service<br/>[user.service.ts]"]
end

subgraph group_football["Football management"]
  node_footballservices["Football services"]
  node_models["Domain entities"]
end

subgraph group_persistence["Persistence"]
  node_datasource["TypeORM data source<br/>[data-source.ts]"]
  node_mysql[("MySQL database")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_application
node_application -->|"mounts routes"| node_routes
node_application -->|"registers errors"| node_errorhandler
node_routes -->|"dispatches to"| node_controllers
node_routes -->|"protects routes"| node_authmiddleware
node_controllers -->|"handles auth"| node_authservice
node_controllers -->|"handles users"| node_userservice
node_controllers -->|"delegates requests"| node_footballservices
node_authservice -->|"looks up users"| node_userservice
node_authmiddleware -->|"checks user roles"| node_models
node_authservice -->|"issues user claims"| node_models
node_userservice -->|"gets repository"| node_datasource
node_footballservices -->|"gets repositories"| node_datasource
node_footballservices -->|"queries entities"| node_models
node_datasource -->|"registers entities"| node_models
node_datasource -->|"connects to"| node_mysql

click node_application "https://github.com/holygoose17/petreactback/blob/main/src/app.ts"
click node_routes "https://github.com/holygoose17/petreactback/tree/main/src/routes"
click node_controllers "https://github.com/holygoose17/petreactback/tree/main/src/controllers"
click node_authmiddleware "https://github.com/holygoose17/petreactback/blob/main/src/middlewares/auth.middlewares.ts"
click node_authservice "https://github.com/holygoose17/petreactback/blob/main/src/services/auth.service.ts"
click node_userservice "https://github.com/holygoose17/petreactback/blob/main/src/services/user.service.ts"
click node_footballservices "https://github.com/holygoose17/petreactback/tree/main/src/services"
click node_models "https://github.com/holygoose17/petreactback/tree/main/src/entities"
click node_datasource "https://github.com/holygoose17/petreactback/blob/main/src/config/data-source.ts"
click node_errorhandler "https://github.com/holygoose17/petreactback/blob/main/src/middlewares/error.middleware.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_application,node_routes,node_controllers,node_errorhandler,node_client toneBlue
class node_authmiddleware,node_authservice,node_userservice toneAmber
class node_footballservices,node_models toneMint
class node_datasource,node_mysql toneRose
```

## Components

### API request handling

- [Express application](https://github.com/holygoose17/petreactback/blob/main/src/app.ts): `src/app.ts`
- [Domain routes](https://github.com/holygoose17/petreactback/tree/main/src/routes): `src/routes`
- [Request controllers](https://github.com/holygoose17/petreactback/tree/main/src/controllers): `src/controllers`
- [Error middleware](https://github.com/holygoose17/petreactback/blob/main/src/middlewares/error.middleware.ts): `src/middlewares/error.middleware.ts`

### Identity and access

- [JWT middleware](https://github.com/holygoose17/petreactback/blob/main/src/middlewares/auth.middlewares.ts): `src/middlewares/auth.middlewares.ts`
- [Authentication service](https://github.com/holygoose17/petreactback/blob/main/src/services/auth.service.ts): `src/services/auth.service.ts`
- [User service](https://github.com/holygoose17/petreactback/blob/main/src/services/user.service.ts): `src/services/user.service.ts`

### Football management

- [Football services](https://github.com/holygoose17/petreactback/tree/main/src/services): `src/services`
- [Domain entities](https://github.com/holygoose17/petreactback/tree/main/src/entities): `src/entities`

### Persistence

- [TypeORM data source](https://github.com/holygoose17/petreactback/blob/main/src/config/data-source.ts): `src/config/data-source.ts`
- **MySQL database**

### Other components

- **API client**

## Connections

- API client → Express application: sends requests (evidence: `src/app.ts`)
- Express application → Domain routes: mounts routes (evidence: `src/app.ts`)
- Express application → Error middleware: registers errors (evidence: `src/app.ts`)
- Domain routes → Request controllers: dispatches to (evidence: `src/routes/auth.router.ts`)
- Domain routes → JWT middleware: protects routes (evidence: `src/routes/auth.router.ts`)
- Request controllers → Authentication service: handles auth (evidence: `src/controllers/auth.controller.ts`)
- Request controllers → User service: handles users (evidence: `src/controllers/user.controller.ts`)
- Request controllers → Football services: delegates requests (evidence: `src/controllers/player.controller.ts`)
- Authentication service → User service: looks up users (evidence: `src/services/auth.service.ts`)
- JWT middleware → Domain entities: checks user roles (evidence: `src/middlewares/auth.middlewares.ts`)
- Authentication service → Domain entities: issues user claims (evidence: `src/services/auth.service.ts`)
- User service → TypeORM data source: gets repository (evidence: `src/services/user.service.ts`)
- Football services → TypeORM data source: gets repositories (evidence: `src/services/player.service.ts`)
- Football services → Domain entities: queries entities (evidence: `src/services/player.service.ts`)
- TypeORM data source → Domain entities: registers entities (evidence: `src/config/data-source.ts`)
- TypeORM data source → MySQL database: connects to (evidence: `src/config/data-source.ts`)
