# xynn191/backend_lms architecture

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

- Interactive diagram: https://gitdiagram.com/xynn191/backend_lms
- Repository: https://github.com/xynn191/backend_lms

## Overview

EduLMS is a Go backend for school administration. An admin sends API requests to manage students, teachers, curriculum staff, principals, majors, classes, and subjects; the router applies authentication and admin-role checks before handlers delegate through services to MySQL-backed repositories. Login verifies credentials and issues JWTs, which middleware validates on protected routes. Startup loads configuration, connects to MySQL, migrates and seeds data, then serves the API. The README is empty; capabilities and wiring beyond sampled code are represented only where the source index or router documents them.

Main entry points: [`internal/router/router.go`](https://github.com/xynn191/backend_lms/blob/main/internal/router/router.go) (Route wiring), [`main.go`](https://github.com/xynn191/backend_lms/blob/main/main.go) (Server startup), [`internal/service/admin_service.go`](https://github.com/xynn191/backend_lms/blob/main/internal/service/admin_service.go) (Dashboard logic), [`internal/repository/admin_repository.go`](https://github.com/xynn191/backend_lms/blob/main/internal/repository/admin_repository.go) (Dashboard repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and access"]
  node_router["Route wiring<br/>[router.go]"]
  node_adminhandler["Dashboard API<br/>[admin_handler.go]"]
  node_adminservice["Dashboard logic<br/>[admin_service.go]"]
  node_adminrepo["Dashboard repository"]
end

subgraph group_identity["Identity"]
  node_authmw["JWT and role checks<br/>[auth_middleware.go]"]
  node_authhandler["Login and profile<br/>[auth_handler.go]"]
  node_authservice["Authentication logic<br/>[auth_service.go]"]
  node_authrepo["Account lookup<br/>[auth_repository.go]"]
end

subgraph group_people["People management"]
  node_userhandler["People API<br/>[user_handler.go]"]
  node_userservice["People operations<br/>[user_service.go]"]
  node_userrepo["People repository<br/>[user_repository.go]"]
end

subgraph group_school["School directory"]
  node_masterhandlers["Major, class, subject APIs"]
  node_masterservices["School directory logic"]
  node_masterrepos["School directory repositories"]
end

subgraph group_persistence["Persistence and startup"]
  node_server["Server startup<br/>[main.go]"]
  node_config["Configuration<br/>[config.go]"]
  node_models["Domain models"]
  node_mysql[("MySQL database")]
end

node_admin(("Admin client"))
node_browser(("API caller"))

node_server -->|"loads"| node_config
node_server -->|"migrates and seeds"| node_models
node_server -->|"starts"| node_router
node_server -->|"connects"| node_mysql
node_server -->|"passes settings"| node_config
node_router -->|"routes login and profile"| node_authhandler
node_router -->|"routes admin people"| node_userhandler
node_router -->|"routes directory APIs"| node_masterhandlers
node_router -->|"routes dashboard"| node_adminhandler
node_router -->|"guards protected routes"| node_authmw
node_router -->|"constructs service"| node_authservice
node_router -->|"constructs repository"| node_authrepo
node_router -->|"constructs service"| node_userservice
node_router -->|"constructs repository"| node_userrepo
node_router -->|"constructs services"| node_masterservices
node_router -->|"constructs repositories"| node_masterrepos
node_router -->|"constructs service"| node_adminservice
node_router -->|"constructs repository"| node_adminrepo
node_authhandler -->|"delegates"| node_authservice
node_authservice -->|"looks up accounts"| node_authrepo
node_authrepo -->|"queries"| node_mysql
node_authmw -.->|"validates bearer token"| node_browser
node_userhandler -->|"delegates"| node_userservice
node_userservice -->|"manages people records"| node_userrepo
node_userrepo -->|"reads and writes"| node_mysql
node_masterhandlers -.->|"delegates"| node_masterservices
node_masterservices -.->|"delegates"| node_masterrepos
node_masterrepos -.->|"reads and writes"| node_mysql
node_adminhandler -.->|"delegates"| node_adminservice
node_adminservice -.->|"delegates"| node_adminrepo
node_adminrepo -.->|"accesses"| node_mysql
node_browser -.->|"sends API requests"| node_router

click node_server "https://github.com/xynn191/backend_lms/blob/main/main.go"
click node_config "https://github.com/xynn191/backend_lms/blob/main/internal/config/config.go"
click node_router "https://github.com/xynn191/backend_lms/blob/main/internal/router/router.go"
click node_authmw "https://github.com/xynn191/backend_lms/blob/main/internal/middleware/auth_middleware.go"
click node_authhandler "https://github.com/xynn191/backend_lms/blob/main/internal/handler/auth_handler.go"
click node_authservice "https://github.com/xynn191/backend_lms/blob/main/internal/service/auth_service.go"
click node_authrepo "https://github.com/xynn191/backend_lms/blob/main/internal/repository/auth_repository.go"
click node_userhandler "https://github.com/xynn191/backend_lms/blob/main/internal/handler/user_handler.go"
click node_userservice "https://github.com/xynn191/backend_lms/blob/main/internal/service/user_service.go"
click node_userrepo "https://github.com/xynn191/backend_lms/blob/main/internal/repository/user_repository.go"
click node_masterhandlers "https://github.com/xynn191/backend_lms/tree/main/internal/handler"
click node_masterservices "https://github.com/xynn191/backend_lms/tree/main/internal/service"
click node_masterrepos "https://github.com/xynn191/backend_lms/tree/main/internal/repository"
click node_adminhandler "https://github.com/xynn191/backend_lms/blob/main/internal/handler/admin_handler.go"
click node_adminservice "https://github.com/xynn191/backend_lms/blob/main/internal/service/admin_service.go"
click node_adminrepo "https://github.com/xynn191/backend_lms/blob/main/internal/repository/admin_repository.go"
click node_models "https://github.com/xynn191/backend_lms/tree/main/internal/models"

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_router,node_adminhandler,node_adminservice,node_adminrepo,node_admin toneBlue
class node_authmw,node_authhandler,node_authservice,node_authrepo toneAmber
class node_userhandler,node_userservice,node_userrepo,node_browser toneMint
class node_masterhandlers,node_masterservices,node_masterrepos toneRose
class node_server,node_config,node_models,node_mysql toneIndigo
```

## Components

### API and access

- [Route wiring](https://github.com/xynn191/backend_lms/blob/main/internal/router/router.go): `internal/router/router.go`
- [Dashboard API](https://github.com/xynn191/backend_lms/blob/main/internal/handler/admin_handler.go): `internal/handler/admin_handler.go`
- [Dashboard logic](https://github.com/xynn191/backend_lms/blob/main/internal/service/admin_service.go): `internal/service/admin_service.go`
- [Dashboard repository](https://github.com/xynn191/backend_lms/blob/main/internal/repository/admin_repository.go): `internal/repository/admin_repository.go`

### Identity

- [JWT and role checks](https://github.com/xynn191/backend_lms/blob/main/internal/middleware/auth_middleware.go): `internal/middleware/auth_middleware.go`
- [Login and profile](https://github.com/xynn191/backend_lms/blob/main/internal/handler/auth_handler.go): `internal/handler/auth_handler.go`
- [Authentication logic](https://github.com/xynn191/backend_lms/blob/main/internal/service/auth_service.go): `internal/service/auth_service.go`
- [Account lookup](https://github.com/xynn191/backend_lms/blob/main/internal/repository/auth_repository.go): `internal/repository/auth_repository.go`

### People management

- [People API](https://github.com/xynn191/backend_lms/blob/main/internal/handler/user_handler.go): `internal/handler/user_handler.go`
- [People operations](https://github.com/xynn191/backend_lms/blob/main/internal/service/user_service.go): `internal/service/user_service.go`
- [People repository](https://github.com/xynn191/backend_lms/blob/main/internal/repository/user_repository.go): `internal/repository/user_repository.go`

### School directory

- [Major, class, subject APIs](https://github.com/xynn191/backend_lms/tree/main/internal/handler): `internal/handler`
- [School directory logic](https://github.com/xynn191/backend_lms/tree/main/internal/service): `internal/service`
- [School directory repositories](https://github.com/xynn191/backend_lms/tree/main/internal/repository): `internal/repository`

### Persistence and startup

- [Server startup](https://github.com/xynn191/backend_lms/blob/main/main.go): `main.go`
- [Configuration](https://github.com/xynn191/backend_lms/blob/main/internal/config/config.go): `internal/config/config.go`
- [Domain models](https://github.com/xynn191/backend_lms/tree/main/internal/models): `internal/models`
- **MySQL database**

### Other components

- **Admin client**
- **API caller**

## Connections

- Server startup → Configuration: loads (evidence: `main.go`)
- Server startup → Domain models: migrates and seeds (evidence: `main.go`)
- Server startup → Route wiring: starts (evidence: `main.go`)
- Server startup → MySQL database: connects (evidence: `main.go`)
- Server startup → Configuration: passes settings (evidence: `main.go`)
- Route wiring → Login and profile: routes login and profile (evidence: `internal/router/router.go`)
- Route wiring → People API: routes admin people (evidence: `internal/router/router.go`)
- Route wiring → Major, class, subject APIs: routes directory APIs (evidence: `internal/router/router.go`)
- Route wiring → Dashboard API: routes dashboard (evidence: `internal/router/router.go`)
- Route wiring → JWT and role checks: guards protected routes (evidence: `internal/router/router.go`)
- Route wiring → Authentication logic: constructs service (evidence: `internal/router/router.go`)
- Route wiring → Account lookup: constructs repository (evidence: `internal/router/router.go`)
- Route wiring → People operations: constructs service (evidence: `internal/router/router.go`)
- Route wiring → People repository: constructs repository (evidence: `internal/router/router.go`)
- Route wiring → School directory logic: constructs services (evidence: `internal/router/router.go`)
- Route wiring → School directory repositories: constructs repositories (evidence: `internal/router/router.go`)
- Route wiring → Dashboard logic: constructs service (evidence: `internal/router/router.go`)
- Route wiring → Dashboard repository: constructs repository (evidence: `internal/router/router.go`)
- Login and profile → Authentication logic: delegates (evidence: `internal/handler/auth_handler.go`)
- Authentication logic → Account lookup: looks up accounts (evidence: `internal/service/auth_service.go`)
- Account lookup → MySQL database: queries (evidence: `internal/repository/auth_repository.go`)
- JWT and role checks → API caller: validates bearer token
- People API → People operations: delegates (evidence: `internal/handler/user_handler.go`)
- People operations → People repository: manages people records (evidence: `internal/service/user_service.go`)
- People repository → MySQL database: reads and writes (evidence: `internal/repository/user_repository.go`)
- Major, class, subject APIs → School directory logic: delegates (evidence: `internal/handler/auth_handler.go`)
- School directory logic → School directory repositories: delegates (evidence: `internal/service/auth_service.go`)
- School directory repositories → MySQL database: reads and writes
- Dashboard API → Dashboard logic: delegates
- Dashboard logic → Dashboard repository: delegates
- Dashboard repository → MySQL database: accesses
- API caller → Route wiring: sends API requests
