# udinjmng/desapintar architecture

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

- Interactive diagram: https://gitdiagram.com/udinjmng/desapintar
- Repository: https://github.com/udinjmng/desapintar

## Overview

Desa Pintar is a village-services portal for discovering local places and businesses, reading community news, and submitting or tracking public reports; administrators review and manage village activity. The visible report-submission flow runs from the citizen portal to the reports API and database. The repository also documents AI recommendations, chat, business-performance analysis, and administrative telemetry. Source excerpts establish only some runtime links, so uncertain connections are omitted; paths for unsampled capabilities use their existing route directories.

Main entry points: [`lib/db.ts`](https://github.com/udinjmng/desapintar/blob/master/lib/db.ts) (MySQL Store), [`app/page.tsx`](https://github.com/udinjmng/desapintar/blob/master/app/page.tsx) (Village Home), [`lib/ai.ts`](https://github.com/udinjmng/desapintar/blob/master/lib/ai.ts) (AI Gateway), [`app/api/ai/admin-telemetry/route.ts`](https://github.com/udinjmng/desapintar/blob/master/app/api/ai/admin-telemetry/route.ts) (Telemetry Analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_citizen["Citizen Portal"]
  node_home["Village Home<br/>[page.tsx]"]
  node_places["Featured Places<br/>[FeaturedPlaces.tsx]"]
  node_news["Community News<br/>[CommunityNews.tsx]"]
  node_reportsui["Report Submission<br/>[page.tsx]"]
  node_newsview["News Reader"]
  node_auth["Account Access<br/>[page.tsx]"]
  node_profile["User Profile<br/>[page.tsx]"]
  node_businessreg["Business Registration<br/>[page.tsx]"]
end

subgraph group_admin["Administration"]
  node_adminui["Admin Dashboard<br/>[page.tsx]"]
  node_telemetryui["Admin Telemetry<br/>[page.tsx]"]
end

subgraph group_api["Service Routes"]
  node_placesapi["Places API<br/>[route.ts]"]
  node_reportsapi["Reports API<br/>[route.ts]"]
  node_businessapi["Business API<br/>[route.ts]"]
  node_newsapi["News API<br/>[route.ts]"]
  node_authapi["Authentication API<br/>[route.ts]"]
  node_profileapi["Profile API<br/>[route.ts]"]
  node_recommendapi["AI Recommendations<br/>[route.ts]"]
  node_chatapi["AI Chat<br/>[route.ts]"]
  node_performanceapi["Business Analysis<br/>[route.ts]"]
  node_telemetryapi["Telemetry Analysis<br/>[route.ts]"]
end

subgraph group_core["Data And AI"]
  node_mysql[("MySQL Store<br/>[db.ts]")]
  node_claude["AI Gateway<br/>[ai.ts]"]
  node_alerts["Alert Context<br/>[AlertContext.tsx]"]
  node_types["Domain Types<br/>[types.ts]"]
end

node_visitor(("Resident"))

node_visitor -->|"opens portal"| node_home
node_visitor -->|"submits report"| node_reportsui
node_home -->|"renders"| node_places
node_home -->|"renders"| node_news
node_home -->|"posts report"| node_reportsapi
node_reportsui -->|"posts report"| node_reportsapi
node_places -->|"uses types"| node_types
node_news -->|"uses types"| node_types
node_home -->|"opens reader"| node_newsview
node_newsview -->|"uses alerts"| node_alerts
node_visitor -->|"signs in"| node_auth
node_visitor -->|"manages profile"| node_profile
node_visitor -->|"registers business"| node_businessreg
node_adminui -->|"updates status"| node_businessapi
node_adminui -.->|"shows analytics"| node_telemetryui
node_telemetryui -.->|"requests analysis"| node_telemetryapi
node_placesapi -->|"queries places"| node_mysql
node_reportsapi -->|"stores reports"| node_mysql
node_businessapi -->|"queries businesses"| node_mysql
node_newsapi -->|"queries news"| node_mysql
node_profileapi -->|"accesses profiles"| node_mysql
node_authapi -.->|"accesses accounts"| node_mysql
node_recommendapi -.->|"reads records"| node_mysql
node_recommendapi -.->|"requests AI"| node_claude
node_chatapi -.->|"requests AI"| node_claude
node_performanceapi -.->|"requests analysis"| node_claude
node_telemetryapi -->|"reads reports"| node_mysql
node_telemetryapi -->|"summarizes data"| node_claude

click node_home "https://github.com/udinjmng/desapintar/blob/master/app/page.tsx"
click node_places "https://github.com/udinjmng/desapintar/blob/master/components/dashboard/FeaturedPlaces.tsx"
click node_news "https://github.com/udinjmng/desapintar/blob/master/components/dashboard/CommunityNews.tsx"
click node_reportsui "https://github.com/udinjmng/desapintar/blob/master/app/laporan/page.tsx"
click node_newsview "https://github.com/udinjmng/desapintar/blob/master/components/modals/SlideReaderDrawer.tsx"
click node_auth "https://github.com/udinjmng/desapintar/blob/master/app/login/page.tsx"
click node_profile "https://github.com/udinjmng/desapintar/blob/master/app/profil/page.tsx"
click node_businessreg "https://github.com/udinjmng/desapintar/blob/master/app/umkm/daftar/page.tsx"
click node_adminui "https://github.com/udinjmng/desapintar/blob/master/app/admin/page.tsx"
click node_telemetryui "https://github.com/udinjmng/desapintar/blob/master/app/admin/page.tsx"
click node_placesapi "https://github.com/udinjmng/desapintar/blob/master/app/api/places/route.ts"
click node_reportsapi "https://github.com/udinjmng/desapintar/blob/master/app/api/reports/route.ts"
click node_businessapi "https://github.com/udinjmng/desapintar/blob/master/app/api/businesses/route.ts"
click node_newsapi "https://github.com/udinjmng/desapintar/blob/master/app/api/news/route.ts"
click node_authapi "https://github.com/udinjmng/desapintar/blob/master/app/api/auth/login/route.ts"
click node_profileapi "https://github.com/udinjmng/desapintar/blob/master/app/api/users/profile/route.ts"
click node_recommendapi "https://github.com/udinjmng/desapintar/blob/master/app/api/ai/recommend/route.ts"
click node_chatapi "https://github.com/udinjmng/desapintar/blob/master/app/api/ai/chat/route.ts"
click node_performanceapi "https://github.com/udinjmng/desapintar/blob/master/app/api/ai/business-performance/route.ts"
click node_telemetryapi "https://github.com/udinjmng/desapintar/blob/master/app/api/ai/admin-telemetry/route.ts"
click node_mysql "https://github.com/udinjmng/desapintar/blob/master/lib/db.ts"
click node_claude "https://github.com/udinjmng/desapintar/blob/master/lib/ai.ts"
click node_alerts "https://github.com/udinjmng/desapintar/blob/master/context/AlertContext.tsx"
click node_types "https://github.com/udinjmng/desapintar/blob/master/data/types.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_home,node_places,node_news,node_reportsui,node_newsview,node_auth,node_profile,node_businessreg toneBlue
class node_adminui,node_telemetryui toneAmber
class node_placesapi,node_reportsapi,node_businessapi,node_newsapi,node_authapi,node_profileapi,node_recommendapi,node_chatapi,node_performanceapi,node_telemetryapi toneMint
class node_mysql,node_claude,node_alerts,node_types toneRose
class node_visitor toneIndigo
```

## Components

### Citizen Portal

- [Village Home](https://github.com/udinjmng/desapintar/blob/master/app/page.tsx): `app/page.tsx`
- [Featured Places](https://github.com/udinjmng/desapintar/blob/master/components/dashboard/FeaturedPlaces.tsx): `components/dashboard/FeaturedPlaces.tsx`
- [Community News](https://github.com/udinjmng/desapintar/blob/master/components/dashboard/CommunityNews.tsx): `components/dashboard/CommunityNews.tsx`
- [Report Submission](https://github.com/udinjmng/desapintar/blob/master/app/laporan/page.tsx): `app/laporan/page.tsx`
- [News Reader](https://github.com/udinjmng/desapintar/blob/master/components/modals/SlideReaderDrawer.tsx): `components/modals/SlideReaderDrawer.tsx`
- [Account Access](https://github.com/udinjmng/desapintar/blob/master/app/login/page.tsx): `app/login/page.tsx`
- [User Profile](https://github.com/udinjmng/desapintar/blob/master/app/profil/page.tsx): `app/profil/page.tsx`
- [Business Registration](https://github.com/udinjmng/desapintar/blob/master/app/umkm/daftar/page.tsx): `app/umkm/daftar/page.tsx`

### Administration

- [Admin Dashboard](https://github.com/udinjmng/desapintar/blob/master/app/admin/page.tsx): `app/admin/page.tsx`
- [Admin Telemetry](https://github.com/udinjmng/desapintar/blob/master/app/admin/page.tsx): `app/admin/page.tsx`

### Service Routes

- [Places API](https://github.com/udinjmng/desapintar/blob/master/app/api/places/route.ts): `app/api/places/route.ts`
- [Reports API](https://github.com/udinjmng/desapintar/blob/master/app/api/reports/route.ts): `app/api/reports/route.ts`
- [Business API](https://github.com/udinjmng/desapintar/blob/master/app/api/businesses/route.ts): `app/api/businesses/route.ts`
- [News API](https://github.com/udinjmng/desapintar/blob/master/app/api/news/route.ts): `app/api/news/route.ts`
- [Authentication API](https://github.com/udinjmng/desapintar/blob/master/app/api/auth/login/route.ts): `app/api/auth/login/route.ts`
- [Profile API](https://github.com/udinjmng/desapintar/blob/master/app/api/users/profile/route.ts): `app/api/users/profile/route.ts`
- [AI Recommendations](https://github.com/udinjmng/desapintar/blob/master/app/api/ai/recommend/route.ts): `app/api/ai/recommend/route.ts`
- [AI Chat](https://github.com/udinjmng/desapintar/blob/master/app/api/ai/chat/route.ts): `app/api/ai/chat/route.ts`
- [Business Analysis](https://github.com/udinjmng/desapintar/blob/master/app/api/ai/business-performance/route.ts): `app/api/ai/business-performance/route.ts`
- [Telemetry Analysis](https://github.com/udinjmng/desapintar/blob/master/app/api/ai/admin-telemetry/route.ts): `app/api/ai/admin-telemetry/route.ts`

### Data And AI

- [MySQL Store](https://github.com/udinjmng/desapintar/blob/master/lib/db.ts): `lib/db.ts`
- [AI Gateway](https://github.com/udinjmng/desapintar/blob/master/lib/ai.ts): `lib/ai.ts`
- [Alert Context](https://github.com/udinjmng/desapintar/blob/master/context/AlertContext.tsx): `context/AlertContext.tsx`
- [Domain Types](https://github.com/udinjmng/desapintar/blob/master/data/types.ts): `data/types.ts`

### Other components

- **Resident**

## Connections

- Resident → Village Home: opens portal (evidence: `app/page.tsx`)
- Resident → Report Submission: submits report (evidence: `app/laporan/page.tsx`)
- Village Home → Featured Places: renders (evidence: `app/page.tsx`)
- Village Home → Community News: renders (evidence: `app/page.tsx`)
- Village Home → Reports API: posts report (evidence: `app/page.tsx`)
- Report Submission → Reports API: posts report (evidence: `app/laporan/page.tsx`)
- Featured Places → Domain Types: uses types (evidence: `components/dashboard/FeaturedPlaces.tsx`)
- Community News → Domain Types: uses types (evidence: `components/dashboard/CommunityNews.tsx`)
- Village Home → News Reader: opens reader (evidence: `app/page.tsx`)
- News Reader → Alert Context: uses alerts (evidence: `components/modals/SlideReaderDrawer.tsx`)
- Resident → Account Access: signs in (evidence: `app/login/page.tsx`)
- Resident → User Profile: manages profile (evidence: `app/profil/page.tsx`)
- Resident → Business Registration: registers business
- Admin Dashboard → Business API: updates status (evidence: `app/admin/page.tsx`)
- Admin Dashboard → Admin Telemetry: shows analytics (evidence: `app/admin/page.tsx`)
- Admin Telemetry → Telemetry Analysis: requests analysis
- Places API → MySQL Store: queries places (evidence: `app/api/places/route.ts`)
- Reports API → MySQL Store: stores reports (evidence: `app/api/reports/route.ts`)
- Business API → MySQL Store: queries businesses (evidence: `app/api/businesses/route.ts`)
- News API → MySQL Store: queries news (evidence: `app/api/news/route.ts`)
- Profile API → MySQL Store: accesses profiles (evidence: `app/api/users/profile/route.ts`)
- Authentication API → MySQL Store: accesses accounts
- AI Recommendations → MySQL Store: reads records (evidence: `app/api/ai/recommend/route.ts`)
- AI Recommendations → AI Gateway: requests AI (evidence: `app/api/ai/recommend/route.ts`)
- AI Chat → AI Gateway: requests AI
- Business Analysis → AI Gateway: requests analysis (evidence: `app/api/ai/business-performance/route.ts`)
- Telemetry Analysis → MySQL Store: reads reports (evidence: `app/api/ai/admin-telemetry/route.ts`)
- Telemetry Analysis → AI Gateway: summarizes data (evidence: `app/api/ai/admin-telemetry/route.ts`)
