# fnuritdinov/namaztime architecture

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

- Interactive diagram: https://gitdiagram.com/fnuritdinov/namaztime
- Repository: https://github.com/fnuritdinov/namaztime

## Overview

nTime is a prayer-times and Islamic-calendar service, with city lookup, official timetable support, Hijri month and Ramadan data, and device registration/push preferences. The main request flow is an API request routed through Gin to handlers; prayer-time requests are resolved by the schedule service using city, official timetable, and Aladhan sources. Separate commands import or fetch official data. The README is empty, and several handler and server-wiring files were not sampled, so some likely links are marked unverified rather than asserted.

Main entry points: [`internal/handler/api.gen.go`](https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/api.gen.go) (API operations), [`internal/schedule/service.go`](https://github.com/fnuritdinov/namaztime/blob/main/internal/schedule/service.go) (Schedule service), [`internal/hijrimonth/service.go`](https://github.com/fnuritdinov/namaztime/blob/main/internal/hijrimonth/service.go) (Hijri month service), [`internal/city/repository.go`](https://github.com/fnuritdinov/namaztime/blob/main/internal/city/repository.go) (City lookup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_server["HTTP server<br/>[server.go]"]
  node_routes["Gin routes<br/>[routes.go]"]
  node_api_handlers["API operations<br/>[api.gen.go]"]
  node_prayer_handler["Prayer handler<br/>[prayer_times.go]"]
  node_city_handler["City handler<br/>[cities.go]"]
  node_hijri_handler["Hijri handler<br/>[hijri.go]"]
  node_device_handler["Device handler<br/>[device.go]"]
  node_config_handler["Config handler<br/>[config.go]"]
end

subgraph group_schedule["Prayer Schedules"]
  node_schedule_service["Schedule service<br/>[service.go]"]
  node_city_repository["City lookup<br/>[repository.go]"]
  node_official_repository["Official timetable<br/>[repository.go]"]
  node_aladhan["Aladhan client<br/>[client.go]"]
  node_aladhan_service["Aladhan cache<br/>[cache.go]"]
  node_prayer_calculation["Prayer calculations<br/>[calc.go]"]
end

subgraph group_calendar["Calendar Data"]
  node_hijri_calendar["Hijri calendar<br/>[hijri.go]"]
  node_hijri_month_service["Hijri month service<br/>[service.go]"]
  node_hijri_month_repository["Month records<br/>[repository.go]"]
end

subgraph group_devices["Device Management"]
  node_device_service["Device service<br/>[service.go]"]
  node_device_repository["Device records<br/>[repository.go]"]
end

subgraph group_ingest["Official Data Ingestion"]
  node_csv_import["CSV import<br/>[main.go]"]
  node_hijri_import["Month import<br/>[main.go]"]
  node_shuro_sync_command["Sync command<br/>[main.go]"]
  node_shuro_client["Shuro client<br/>[client.go]"]
  node_shuro_store["Shuro store<br/>[store.go]"]
  node_shuro_worker["Sync worker<br/>[worker.go]"]
end

node_user(("API client"))
node_postgres[("Postgres")]
node_shuro_site["Shuro website"]

node_user -.->|"requests"| node_server
node_server -.->|"serves"| node_routes
node_routes -->|"registers"| node_api_handlers
node_api_handlers -.->|"dispatches"| node_prayer_handler
node_api_handlers -.->|"dispatches"| node_city_handler
node_api_handlers -.->|"dispatches"| node_hijri_handler
node_api_handlers -.->|"dispatches"| node_device_handler
node_api_handlers -.->|"dispatches"| node_config_handler
node_prayer_handler -.->|"requests schedule"| node_schedule_service
node_city_handler -.->|"searches cities"| node_city_repository
node_schedule_service -.->|"loads city"| node_city_repository
node_schedule_service -.->|"loads timetable"| node_official_repository
node_schedule_service -.->|"gets monthly times"| node_aladhan_service
node_aladhan_service -.->|"fetches month"| node_aladhan
node_schedule_service -.->|"loads month starts"| node_hijri_month_repository
node_schedule_service -.->|"reads"| node_postgres
node_city_repository -->|"queries"| node_postgres
node_official_repository -->|"queries"| node_postgres
node_hijri_handler -.->|"requests calendar data"| node_hijri_month_service
node_hijri_month_service -.->|"loads months"| node_hijri_month_repository
node_hijri_month_service -.->|"calculates dates"| node_hijri_calendar
node_hijri_month_repository -.->|"reads"| node_postgres
node_device_handler -.->|"manages device"| node_device_service
node_device_service -.->|"stores device"| node_device_repository
node_device_repository -.->|"reads and writes"| node_postgres
node_csv_import -.->|"imports rows"| node_postgres
node_hijri_import -->|"saves month"| node_postgres
node_shuro_sync_command -->|"fetches month"| node_shuro_client
node_shuro_sync_command -->|"saves month"| node_shuro_store
node_shuro_client -->|"fetches timetable"| node_shuro_site
node_shuro_store -.->|"writes"| node_postgres
node_shuro_worker -.->|"syncs month"| node_shuro_client
node_shuro_worker -.->|"stores results"| node_shuro_store

click node_server "https://github.com/fnuritdinov/namaztime/blob/main/cmd/server/server.go"
click node_routes "https://github.com/fnuritdinov/namaztime/blob/main/cmd/server/routes.go"
click node_api_handlers "https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/api.gen.go"
click node_prayer_handler "https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/prayer_times.go"
click node_city_handler "https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/cities.go"
click node_hijri_handler "https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/hijri.go"
click node_device_handler "https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/device.go"
click node_config_handler "https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/config.go"
click node_schedule_service "https://github.com/fnuritdinov/namaztime/blob/main/internal/schedule/service.go"
click node_city_repository "https://github.com/fnuritdinov/namaztime/blob/main/internal/city/repository.go"
click node_official_repository "https://github.com/fnuritdinov/namaztime/blob/main/internal/official/repository.go"
click node_aladhan "https://github.com/fnuritdinov/namaztime/blob/main/internal/aladhan/client.go"
click node_aladhan_service "https://github.com/fnuritdinov/namaztime/blob/main/internal/aladhan/cache.go"
click node_prayer_calculation "https://github.com/fnuritdinov/namaztime/blob/main/internal/prayertime/calc.go"
click node_hijri_calendar "https://github.com/fnuritdinov/namaztime/blob/main/internal/hijri/hijri.go"
click node_hijri_month_service "https://github.com/fnuritdinov/namaztime/blob/main/internal/hijrimonth/service.go"
click node_hijri_month_repository "https://github.com/fnuritdinov/namaztime/blob/main/internal/hijrimonth/repository.go"
click node_device_service "https://github.com/fnuritdinov/namaztime/blob/main/internal/device/service.go"
click node_device_repository "https://github.com/fnuritdinov/namaztime/blob/main/internal/device/repository.go"
click node_csv_import "https://github.com/fnuritdinov/namaztime/blob/main/cmd/import-timetable/main.go"
click node_hijri_import "https://github.com/fnuritdinov/namaztime/blob/main/cmd/hijri-month/main.go"
click node_shuro_sync_command "https://github.com/fnuritdinov/namaztime/blob/main/cmd/shuro-sync/main.go"
click node_shuro_client "https://github.com/fnuritdinov/namaztime/blob/main/internal/shuro/client.go"
click node_shuro_store "https://github.com/fnuritdinov/namaztime/blob/main/internal/shuro/store.go"
click node_shuro_worker "https://github.com/fnuritdinov/namaztime/blob/main/internal/shuro/worker.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_server,node_routes,node_api_handlers,node_prayer_handler,node_city_handler,node_hijri_handler,node_device_handler,node_config_handler,node_user toneBlue
class node_schedule_service,node_city_repository,node_official_repository,node_aladhan,node_aladhan_service,node_prayer_calculation,node_postgres toneAmber
class node_hijri_calendar,node_hijri_month_service,node_hijri_month_repository toneMint
class node_device_service,node_device_repository toneRose
class node_csv_import,node_hijri_import,node_shuro_sync_command,node_shuro_client,node_shuro_store,node_shuro_worker,node_shuro_site toneIndigo
```

## Components

### HTTP API

- [HTTP server](https://github.com/fnuritdinov/namaztime/blob/main/cmd/server/server.go): `cmd/server/server.go`
- [Gin routes](https://github.com/fnuritdinov/namaztime/blob/main/cmd/server/routes.go): `cmd/server/routes.go`
- [API operations](https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/api.gen.go): `internal/handler/api.gen.go`
- [Prayer handler](https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/prayer_times.go): `internal/handler/prayer_times.go`
- [City handler](https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/cities.go): `internal/handler/cities.go`
- [Hijri handler](https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/hijri.go): `internal/handler/hijri.go`
- [Device handler](https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/device.go): `internal/handler/device.go`
- [Config handler](https://github.com/fnuritdinov/namaztime/blob/main/internal/handler/config.go): `internal/handler/config.go`

### Prayer Schedules

- [Schedule service](https://github.com/fnuritdinov/namaztime/blob/main/internal/schedule/service.go): `internal/schedule/service.go`
- [City lookup](https://github.com/fnuritdinov/namaztime/blob/main/internal/city/repository.go): `internal/city/repository.go`
- [Official timetable](https://github.com/fnuritdinov/namaztime/blob/main/internal/official/repository.go): `internal/official/repository.go`
- [Aladhan client](https://github.com/fnuritdinov/namaztime/blob/main/internal/aladhan/client.go): `internal/aladhan/client.go`
- [Aladhan cache](https://github.com/fnuritdinov/namaztime/blob/main/internal/aladhan/cache.go): `internal/aladhan/cache.go`
- [Prayer calculations](https://github.com/fnuritdinov/namaztime/blob/main/internal/prayertime/calc.go): `internal/prayertime/calc.go`

### Calendar Data

- [Hijri calendar](https://github.com/fnuritdinov/namaztime/blob/main/internal/hijri/hijri.go): `internal/hijri/hijri.go`
- [Hijri month service](https://github.com/fnuritdinov/namaztime/blob/main/internal/hijrimonth/service.go): `internal/hijrimonth/service.go`
- [Month records](https://github.com/fnuritdinov/namaztime/blob/main/internal/hijrimonth/repository.go): `internal/hijrimonth/repository.go`

### Device Management

- [Device service](https://github.com/fnuritdinov/namaztime/blob/main/internal/device/service.go): `internal/device/service.go`
- [Device records](https://github.com/fnuritdinov/namaztime/blob/main/internal/device/repository.go): `internal/device/repository.go`

### Official Data Ingestion

- [CSV import](https://github.com/fnuritdinov/namaztime/blob/main/cmd/import-timetable/main.go): `cmd/import-timetable/main.go`
- [Month import](https://github.com/fnuritdinov/namaztime/blob/main/cmd/hijri-month/main.go): `cmd/hijri-month/main.go`
- [Sync command](https://github.com/fnuritdinov/namaztime/blob/main/cmd/shuro-sync/main.go): `cmd/shuro-sync/main.go`
- [Shuro client](https://github.com/fnuritdinov/namaztime/blob/main/internal/shuro/client.go): `internal/shuro/client.go`
- [Shuro store](https://github.com/fnuritdinov/namaztime/blob/main/internal/shuro/store.go): `internal/shuro/store.go`
- [Sync worker](https://github.com/fnuritdinov/namaztime/blob/main/internal/shuro/worker.go): `internal/shuro/worker.go`

### Other components

- **API client**
- **Postgres**
- **Shuro website**

## Connections

- API client → HTTP server: requests
- HTTP server → Gin routes: serves
- Gin routes → API operations: registers (evidence: `cmd/server/routes.go`)
- API operations → Prayer handler: dispatches
- API operations → City handler: dispatches
- API operations → Hijri handler: dispatches
- API operations → Device handler: dispatches
- API operations → Config handler: dispatches
- Prayer handler → Schedule service: requests schedule
- City handler → City lookup: searches cities
- Schedule service → City lookup: loads city
- Schedule service → Official timetable: loads timetable
- Schedule service → Aladhan cache: gets monthly times
- Aladhan cache → Aladhan client: fetches month
- Schedule service → Month records: loads month starts
- Schedule service → Postgres: reads
- City lookup → Postgres: queries (evidence: `internal/city/repository.go`)
- Official timetable → Postgres: queries (evidence: `internal/official/repository.go`)
- Hijri handler → Hijri month service: requests calendar data
- Hijri month service → Month records: loads months
- Hijri month service → Hijri calendar: calculates dates
- Month records → Postgres: reads
- Device handler → Device service: manages device
- Device service → Device records: stores device
- Device records → Postgres: reads and writes
- CSV import → Postgres: imports rows
- Month import → Postgres: saves month (evidence: `cmd/hijri-month/main.go`)
- Sync command → Shuro client: fetches month (evidence: `cmd/shuro-sync/main.go`)
- Sync command → Shuro store: saves month (evidence: `cmd/shuro-sync/main.go`)
- Shuro client → Shuro website: fetches timetable (evidence: `internal/shuro/client.go`)
- Shuro store → Postgres: writes
- Sync worker → Shuro client: syncs month
- Sync worker → Shuro store: stores results
