# programmerzamannow/belajar-typescript-restful-api architecture

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

- Interactive diagram: https://gitdiagram.com/programmerzamannow/belajar-typescript-restful-api
- Repository: https://github.com/programmerzamannow/belajar-typescript-restful-api

## Overview

This is a TypeScript REST API for user accounts, contacts, and contact addresses. Its main workflow is HTTP routing, authentication for protected endpoints, controller handling, service-level validation and domain operations, then Prisma-backed persistence and JSON responses. The graph also includes account registration/login, paginated contact search, address management, and shared error/logging support. Several route, middleware, and runtime links are supported by the source index; the README identifies MySQL configuration, but does not document the API workflow in detail.

Main entry points: [`src/route/api.ts`](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/route/api.ts) (Protected routes), [`src/service/address-service.ts`](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/service/address-service.ts) (Address operations), [`src/application/web.ts`](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/application/web.ts) (Web application), [`src/service/contact-service.ts`](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/service/contact-service.ts) (Contact operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_http["HTTP runtime"]
  node_main["Server entry<br/>[main.ts]"]
  node_web["Web application<br/>[web.ts]"]
  node_publicroutes["Public routes<br/>[public-api.ts]"]
  node_apiroutes["Protected routes<br/>[api.ts]"]
  node_auth["Authentication<br/>[auth-middleware.ts]"]
  node_errors["Error handling"]
end

subgraph group_accounts["User accounts"]
  node_usercontroller["User endpoints<br/>[user-controller.ts]"]
  node_userservice["User operations<br/>[user-service.ts]"]
  node_usermodel["User data model<br/>[user-model.ts]"]
  node_uservalidation["User validation<br/>[user-validation.ts]"]
end

subgraph group_records["Contact records"]
  node_contactcontroller["Contact endpoints"]
  node_contactservice["Contact operations<br/>[contact-service.ts]"]
  node_contactmodel["Contact data model<br/>[contact-model.ts]"]
  node_contactvalidation["Contact validation"]
  node_addresscontroller["Address endpoints"]
  node_addressservice["Address operations<br/>[address-service.ts]"]
  node_addressmodel["Address data model<br/>[address-model.ts]"]
  node_addressvalidation["Address validation"]
  node_validation["Validation helper<br/>[validation.ts]"]
end

subgraph group_infrastructure["Persistence and support"]
  node_database["Prisma client<br/>[database.ts]"]
  node_store[("MySQL database<br/>[schema.prisma]")]
  node_logging["Application logging<br/>[logging.ts]"]
  node_responseerror["Response errors<br/>[response-error.ts]"]
end

node_client(("API client"))

node_client -->|"sends requests"| node_web
node_main -->|"starts"| node_web
node_web -->|"mounts"| node_publicroutes
node_web -->|"mounts"| node_apiroutes
node_web -->|"registers"| node_errors
node_publicroutes -->|"routes to"| node_usercontroller
node_apiroutes -->|"applies"| node_auth
node_apiroutes -->|"routes to"| node_usercontroller
node_apiroutes -->|"routes to"| node_contactcontroller
node_apiroutes -->|"routes to"| node_addresscontroller
node_usercontroller -->|"calls"| node_userservice
node_contactcontroller -->|"calls"| node_contactservice
node_addresscontroller -->|"calls"| node_addressservice
node_userservice -->|"validates with"| node_uservalidation
node_contactservice -->|"validates with"| node_contactvalidation
node_addressservice -->|"validates with"| node_addressvalidation
node_userservice -->|"uses"| node_validation
node_contactservice -->|"uses"| node_validation
node_addressservice -->|"uses"| node_validation
node_userservice -->|"queries"| node_database
node_contactservice -->|"queries"| node_database
node_addressservice -->|"queries"| node_database
node_addressservice -->|"checks contact"| node_contactservice
node_database -->|"logs events"| node_logging
node_database -.->|"persists through"| node_store
node_errors -->|"handles"| node_responseerror
node_main -->|"uses"| node_logging

click node_main "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/main.ts"
click node_web "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/application/web.ts"
click node_publicroutes "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/route/public-api.ts"
click node_apiroutes "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/route/api.ts"
click node_auth "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/middleware/auth-middleware.ts"
click node_errors "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/middleware/error-middleware.ts"
click node_usercontroller "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/controller/user-controller.ts"
click node_userservice "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/service/user-service.ts"
click node_usermodel "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/model/user-model.ts"
click node_uservalidation "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/validation/user-validation.ts"
click node_contactcontroller "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/controller/contact-controller.ts"
click node_contactservice "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/service/contact-service.ts"
click node_contactmodel "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/model/contact-model.ts"
click node_contactvalidation "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/validation/contact-validation.ts"
click node_addresscontroller "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/controller/address-controller.ts"
click node_addressservice "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/service/address-service.ts"
click node_addressmodel "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/model/address-model.ts"
click node_addressvalidation "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/validation/address-validation.ts"
click node_validation "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/validation/validation.ts"
click node_database "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/application/database.ts"
click node_store "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/prisma/schema.prisma"
click node_logging "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/application/logging.ts"
click node_responseerror "https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/error/response-error.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_main,node_web,node_publicroutes,node_apiroutes,node_auth,node_errors,node_client toneBlue
class node_usercontroller,node_userservice,node_usermodel,node_uservalidation toneAmber
class node_contactcontroller,node_contactservice,node_contactmodel,node_contactvalidation,node_addresscontroller,node_addressservice,node_addressmodel,node_addressvalidation,node_validation toneMint
class node_database,node_store,node_logging,node_responseerror toneRose
```

## Components

### HTTP runtime

- [Server entry](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/main.ts): `src/main.ts`
- [Web application](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/application/web.ts): `src/application/web.ts`
- [Public routes](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/route/public-api.ts): `src/route/public-api.ts`
- [Protected routes](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/route/api.ts): `src/route/api.ts`
- [Authentication](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/middleware/auth-middleware.ts): `src/middleware/auth-middleware.ts`
- [Error handling](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/middleware/error-middleware.ts): `src/middleware/error-middleware.ts`

### User accounts

- [User endpoints](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/controller/user-controller.ts): `src/controller/user-controller.ts`
- [User operations](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/service/user-service.ts): `src/service/user-service.ts`
- [User data model](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/model/user-model.ts): `src/model/user-model.ts`
- [User validation](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/validation/user-validation.ts): `src/validation/user-validation.ts`

### Contact records

- [Contact endpoints](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/controller/contact-controller.ts): `src/controller/contact-controller.ts`
- [Contact operations](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/service/contact-service.ts): `src/service/contact-service.ts`
- [Contact data model](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/model/contact-model.ts): `src/model/contact-model.ts`
- [Contact validation](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/validation/contact-validation.ts): `src/validation/contact-validation.ts`
- [Address endpoints](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/controller/address-controller.ts): `src/controller/address-controller.ts`
- [Address operations](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/service/address-service.ts): `src/service/address-service.ts`
- [Address data model](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/model/address-model.ts): `src/model/address-model.ts`
- [Address validation](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/validation/address-validation.ts): `src/validation/address-validation.ts`
- [Validation helper](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/validation/validation.ts): `src/validation/validation.ts`

### Persistence and support

- [Prisma client](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/application/database.ts): `src/application/database.ts`
- [MySQL database](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/prisma/schema.prisma): `prisma/schema.prisma`
- [Application logging](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/application/logging.ts): `src/application/logging.ts`
- [Response errors](https://github.com/programmerzamannow/belajar-typescript-restful-api/blob/main/src/error/response-error.ts): `src/error/response-error.ts`

### Other components

- **API client**

## Connections

- API client → Web application: sends requests
- Server entry → Web application: starts (evidence: `src/main.ts`)
- Web application → Public routes: mounts (evidence: `src/application/web.ts`)
- Web application → Protected routes: mounts (evidence: `src/application/web.ts`)
- Web application → Error handling: registers (evidence: `src/application/web.ts`)
- Public routes → User endpoints: routes to (evidence: `src/route/public-api.ts`)
- Protected routes → Authentication: applies (evidence: `src/route/api.ts`)
- Protected routes → User endpoints: routes to (evidence: `src/route/api.ts`)
- Protected routes → Contact endpoints: routes to (evidence: `src/route/api.ts`)
- Protected routes → Address endpoints: routes to (evidence: `src/route/api.ts`)
- User endpoints → User operations: calls (evidence: `src/controller/user-controller.ts`)
- Contact endpoints → Contact operations: calls (evidence: `src/controller/contact-controller.ts`)
- Address endpoints → Address operations: calls (evidence: `src/controller/address-controller.ts`)
- User operations → User validation: validates with (evidence: `src/service/user-service.ts`)
- Contact operations → Contact validation: validates with (evidence: `src/service/contact-service.ts`)
- Address operations → Address validation: validates with (evidence: `src/service/address-service.ts`)
- User operations → Validation helper: uses (evidence: `src/service/user-service.ts`)
- Contact operations → Validation helper: uses (evidence: `src/service/contact-service.ts`)
- Address operations → Validation helper: uses (evidence: `src/service/address-service.ts`)
- User operations → Prisma client: queries (evidence: `src/service/user-service.ts`)
- Contact operations → Prisma client: queries (evidence: `src/service/contact-service.ts`)
- Address operations → Prisma client: queries (evidence: `src/service/address-service.ts`)
- Address operations → Contact operations: checks contact (evidence: `src/service/address-service.ts`)
- Prisma client → Application logging: logs events (evidence: `src/application/database.ts`)
- Prisma client → MySQL database: persists through (evidence: `README.md`)
- Error handling → Response errors: handles (evidence: `src/middleware/error-middleware.ts`)
- Server entry → Application logging: uses (evidence: `src/main.ts`)
