# govtechmy/sekolahku-mod-api architecture

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

- Interactive diagram: https://gitdiagram.com/govtechmy/sekolahku-mod-api
- Repository: https://github.com/govtechmy/sekolahku-mod-api

## Overview

Sekolahku Mod API is a Fastify backend for Malaysian school data and related content. Requests enter through the server and registered API routes; the documented protected endpoints cover school search/catalog, events, broadcasts, and revalidation, with additional map, analytics, calendar, and visitor APIs. The shown school flow authenticates requests, runs controller logic and searches MongoDB-backed school records. The README documents broader features, but most domain route/controller wiring was not sampled, so those links are omitted rather than inferred.

Main entry points: [`src/routes/index.route.ts`](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/index.route.ts) (Route registry), [`src/server.ts`](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/server.ts) (Fastify server), [`src/routes/schools.routes.ts`](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/schools.routes.ts) (School routes), [`src/controllers/schools.controller.ts`](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/controllers/schools.controller.ts) (School handlers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["API Runtime"]
  node_server["Fastify server<br/>[server.ts]"]
  node_api_routes["Route registry<br/>[index.route.ts]"]
  node_auth["API key auth<br/>[auth.middleware.ts]"]
  node_schemas["Zod schemas"]
  node_plugins["Server plugins<br/>[index.plugin.ts]"]
end

subgraph group_schools["School Catalog"]
  node_school_routes["School routes<br/>[schools.routes.ts]"]
  node_school_controller["School handlers"]
  node_school_search["School search"]
end

subgraph group_content["Content APIs"]
  node_acara["Events API<br/>[acara.route.ts]"]
  node_siaran["Broadcast API<br/>[siaran.route.ts]"]
  node_takwim["Calendar API<br/>[takwim.route.ts]"]
  node_analytics["Analytics API<br/>[analitik.route.ts]"]
  node_maps["Maps API<br/>[map.route.ts]"]
  node_revalidate["Revalidation API"]
  node_visitors["Visitor API<br/>[pelawat.route.ts]"]
end

subgraph group_data["Persistence"]
  node_school_model[("School records")]
  node_db_config[("DB connections<br/>[db.config.ts]")]
  node_content_models[("Content records")]
end

node_client(("API client"))

node_client -->|"sends requests"| node_server
node_server -->|"registers plugins"| node_plugins
node_server -->|"registers routes"| node_api_routes
node_server -->|"connects database"| node_db_config
node_api_routes -->|"registers"| node_school_routes
node_api_routes -->|"registers"| node_acara
node_api_routes -->|"registers"| node_siaran
node_api_routes -->|"registers"| node_takwim
node_api_routes -->|"registers"| node_analytics
node_api_routes -->|"registers"| node_maps
node_api_routes -->|"registers"| node_revalidate
node_api_routes -->|"registers"| node_visitors
node_school_routes -->|"guards requests"| node_auth
node_school_routes -->|"dispatches handlers"| node_school_controller
node_school_controller -->|"uses search logic"| node_school_search
node_school_controller -->|"queries records"| node_school_model
node_school_model -->|"uses connection"| node_db_config

click node_server "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/server.ts"
click node_api_routes "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/index.route.ts"
click node_auth "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/middleware/auth.middleware.ts"
click node_schemas "https://github.com/govtechmy/sekolahku-mod-api/tree/main/src/schemas"
click node_plugins "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/plugins/index.plugin.ts"
click node_school_routes "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/schools.routes.ts"
click node_school_controller "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/controllers/schools.controller.ts"
click node_school_search "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/services/school-search.svc.ts"
click node_school_model "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/models/entiti-sekolah.model.ts"
click node_db_config "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/config/db.config.ts"
click node_acara "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/acara.route.ts"
click node_siaran "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/siaran.route.ts"
click node_takwim "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/takwim.route.ts"
click node_analytics "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/analitik.route.ts"
click node_maps "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/map.route.ts"
click node_revalidate "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/revalidate.route.ts"
click node_visitors "https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/pelawat.route.ts"
click node_content_models "https://github.com/govtechmy/sekolahku-mod-api/tree/main/src/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_server,node_api_routes,node_auth,node_schemas,node_plugins,node_client toneBlue
class node_school_routes,node_school_controller,node_school_search toneAmber
class node_acara,node_siaran,node_takwim,node_analytics,node_maps,node_revalidate,node_visitors toneMint
class node_school_model,node_db_config,node_content_models toneRose
```

## Components

### API Runtime

- [Fastify server](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/server.ts): `src/server.ts`
- [Route registry](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/index.route.ts): `src/routes/index.route.ts`
- [API key auth](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/middleware/auth.middleware.ts): `src/middleware/auth.middleware.ts`
- [Zod schemas](https://github.com/govtechmy/sekolahku-mod-api/tree/main/src/schemas): `src/schemas`
- [Server plugins](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/plugins/index.plugin.ts): `src/plugins/index.plugin.ts`

### School Catalog

- [School routes](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/schools.routes.ts): `src/routes/schools.routes.ts`
- [School handlers](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/controllers/schools.controller.ts): `src/controllers/schools.controller.ts`
- [School search](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/services/school-search.svc.ts): `src/services/school-search.svc.ts`

### Content APIs

- [Events API](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/acara.route.ts): `src/routes/acara.route.ts`
- [Broadcast API](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/siaran.route.ts): `src/routes/siaran.route.ts`
- [Calendar API](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/takwim.route.ts): `src/routes/takwim.route.ts`
- [Analytics API](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/analitik.route.ts): `src/routes/analitik.route.ts`
- [Maps API](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/map.route.ts): `src/routes/map.route.ts`
- [Revalidation API](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/revalidate.route.ts): `src/routes/revalidate.route.ts`
- [Visitor API](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/routes/pelawat.route.ts): `src/routes/pelawat.route.ts`

### Persistence

- [School records](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/models/entiti-sekolah.model.ts): `src/models/entiti-sekolah.model.ts`
- [DB connections](https://github.com/govtechmy/sekolahku-mod-api/blob/main/src/config/db.config.ts): `src/config/db.config.ts`
- [Content records](https://github.com/govtechmy/sekolahku-mod-api/tree/main/src/models): `src/models`

### Other components

- **API client**

## Connections

- API client → Fastify server: sends requests (evidence: `README.md`)
- Fastify server → Server plugins: registers plugins (evidence: `src/server.ts`)
- Fastify server → Route registry: registers routes (evidence: `src/server.ts`)
- Fastify server → DB connections: connects database (evidence: `src/server.ts`)
- Route registry → School routes: registers (evidence: `src/routes/index.route.ts`)
- Route registry → Events API: registers (evidence: `src/routes/index.route.ts`)
- Route registry → Broadcast API: registers (evidence: `src/routes/index.route.ts`)
- Route registry → Calendar API: registers (evidence: `src/routes/index.route.ts`)
- Route registry → Analytics API: registers (evidence: `src/routes/index.route.ts`)
- Route registry → Maps API: registers (evidence: `src/routes/index.route.ts`)
- Route registry → Revalidation API: registers (evidence: `src/routes/index.route.ts`)
- Route registry → Visitor API: registers (evidence: `src/routes/index.route.ts`)
- School routes → API key auth: guards requests (evidence: `src/routes/schools.routes.ts`)
- School routes → School handlers: dispatches handlers (evidence: `src/routes/schools.routes.ts`)
- School handlers → School search: uses search logic (evidence: `src/controllers/schools.controller.ts`)
- School handlers → School records: queries records (evidence: `src/controllers/schools.controller.ts`)
- School records → DB connections: uses connection (evidence: `src/models/entiti-sekolah.model.ts`)
