How rez3x/jw_web works
1. Overall shape
- This repo is a Next.js App Router frontend for the JogjaWaskita civic platform.
- It is not just a UI shell: it functions as a BFF (Backend-For-Frontend) that mediates all browser access to the Rust backend.
2. Primary boundary
- The key architectural boundary is between:
- Browser/UI in src/app and src/components
- Backend access through src/app/api/... route handlers
- The browser should not talk directly to the Rust API. Instead, client-side requests go through Next.js API routes, while server-rendered parts can call backend services during SSR.
3. Application routing layer
- src/app contains the user-facing routes:
- public/community feed
- auth pages
- chat
- post detail
- profile pages and settings
- explore/search
- government dashboard
- admin panel
- CCTV view
- This is the main presentation layer and defines the app’s navigable surfaces.
4. BFF/API proxy layer
- src/app/api contains route handlers that proxy or orchestrate backend calls.
- Major API domains are visible in the tree:
- auth
- posts
- comments
- chats
- users
- departments
- analytics
- logs
- votes
- cctv
- dev
- The catch-all patterns like [...slug] suggest these handlers forward or normalize backend endpoints rather than implementing business logic locally.
5. Authentication and session model
- Auth is centered on Google OAuth, email verification, and logout/me flows.
- The README says auth uses HttpOnly cookies, so token state is kept server-side from the browser’s perspective.
- src/components/auth/AuthProvider.js and src/lib/auth.js likely provide client-side auth state and guards, but the authoritative session lives in the backend/cookies, not local storage.
6. Content and engagement subsystem
- The social/reporting core revolves around:
- posts
- votes
- nested comments and subcomments
- pinned comments
- post classification
- The feed (src/app/HomeFeed.js) and post components (src/components/post/*) imply an infinite-scroll community timeline with detail views, creation flows, media upload, and voting interactions.
7. Conversation / AI assistant subsystem
- src/app/chat and src/app/api/chats implement a unified chat interface.
- The README describes it as a ChatGPT-style civic assistant with agentic tools, so the UI likely drives backend-assisted conversational workflows rather than a purely local chat experience.
- src/components/ui/Markdown support in the README suggests assistant responses are rendered as formatted content, not plain text.
8. Government operations subsystem
- src/app/dashboard is the operational workspace for departments to manage issue queues.
- The post lifecycle likely maps to states such as Pending, In Progress, and Resolved, with department assignment and classification supporting that workflow.
- src/app/api/departments and post classification endpoints indicate the dashboard depends on structured department metadata.
9. Admin and observability subsystem
- src/app/admin plus src/app/api/logs and src/app/api/dev form a higher-privilege administrative area.
- This includes user management, role assignment, and log viewing for auditing.
- The presence of analytics and logs routes suggests the admin UI is backed by operational telemetry, not just user data.
10. Search/discovery and profiles
- src/app/explore provides search across posts and a people directory view.
- src/app/profile/[username] and src/app/profile/settings expose public profiles and account preferences.
- These views likely consume shared user/search endpoints and are separate from the feed because they focus on retrieval and identity rather than creation.
11. CCTV / media-specific subsystem
- src/app/cctv and src/components/cctv/* indicate a dedicated surveillance/media viewing experience.
- The presence of HLSPlayer suggests live/streamed media playback, while CCTVMap and CCTVPanel suggest a spatial browsing and selection flow.
- src/lib/cctv-data.js likely supplies local metadata or configuration for camera locations.
12. Shared component and utility layer
- src/components is organized by domain and reusable UI:
- layout chrome: navbar, sidebars, trending panel
- post UI: cards, forms, modals, vote controls
- comment UI: threads, replies, forms
- generic UI primitives: buttons, badges, modals, search, skeletons, avatars
- src/lib holds cross-cutting concerns such as API helpers, constants, store/state, and utilities.
13. Runtime and styling
- The stack is Next.js + React with Tailwind CSS v4.
- next.config.mjs, postcss.config.mjs, biome.json, and jsconfig.json show a standard modern frontend toolchain with lint/format and path alias support.
- Static assets live under public/, which likely holds logos, icons, and media used across the app.
14. How to diagram the system
- The most accurate diagram should show:
- Browser → Next.js pages/components
- Client interactions → Next.js API route handlers
- Server-side rendering / route handlers → Rust backend
- Auth state via HttpOnly cookies
- Shared domain models feeding feed, chat, dashboard, admin, explore, and CCTV
- In other words, this is a single frontend repo with multiple domain-specific surfaces, all mediated through a Next.js BFF layer.
Main entry points: app App Router · components Components · users Users API · posts Content API
Components 26
Presentation
App Router surfaces and UI composition
- App Router · Top-level Next.js application shell and route tree
src/app - Home feed · Community timeline and entry surface
src/app/HomeFeed.js - Auth pages · Login and email verification surfaces
src/app/auth - Chat · User conversation surfaces
src/app/chat - Posts · Post detail and post-related browsing surfaces
src/app/post - Profiles · Public profile and settings surfaces
src/app/profile - Explore · Search and people discovery surface
src/app/explore - Dashboard · Department workflow workspace
src/app/dashboard - Admin · Privileged management and audit surfaces
src/app/admin - CCTV · Camera browsing and live stream surface
src/app/cctv
BFF API
Next.js route handlers that proxy and orchestrate backend access
- API routes · Next.js route handler layer mediating backend access
src/app/api - Auth API · Google OAuth, session, and verification flows
src/app/api/auth - Content API · Posts, comments, and votes endpoints
src/app/api/posts - Chat API · Chat session and message endpoints
src/app/api/chats - Ops API · Departments and admin-operational data endpoints
src/app/api/departments - Telemetry API · Analytics, logs, and dev/admin observability endpoints
src/app/api/analytics - Users API · User search and profile lookup endpoints
src/app/api/users - CCTV API · Camera and media streaming access
src/app/api/cctv
Shared
Reusable components and client-side shared logic
- Components · Reusable layout, post, comment, CCTV, auth, and primitive UI components
src/components - Lib · Cross-cutting client helpers, state, auth, and configuration
src/lib - API client · Client-side API helper and request plumbing
src/lib/api.js - Auth state · Client auth/session helpers and guards
src/lib/auth.js - Store · Shared client-side state management
src/lib/store.js - CCTV data · Local camera metadata and map data
src/lib/cctv-data.js
External
Runtime boundary outside this repository
- Browser · End-user runtime that uses the app through pages and API calls
- Rust backend · Authoritative application backend behind the Next.js BFF
Connections 26
- Browser → App Router: uses · Users navigate the App Router surfaces
- App Router → Components: renders with · Pages are composed from shared UI modules
- App Router → Lib: uses · Route-level code relies on shared helpers and state
- Auth pages → Auth API: calls · Login, callback, verify, me, and logout flows go through the auth BFF
- Chat → Chat API: calls · Chat UI reads sessions and sends messages through the chat BFF
- Posts → Content API: calls · Post detail surfaces fetch posts, comments, and votes via the BFF
- Home feed → Content API: calls · Feed loading and engagement actions go through content endpoints
- Profiles → Users API: calls · Profiles and settings use user lookup and account data
- Explore → Users API: calls · Discovery and people search depend on user search endpoints
- Dashboard → Ops API: calls · Department workflow views use structured ops data
- Admin → Telemetry API: calls · Admin views consume logs, analytics, and dev endpoints
- Admin → Users API: calls · User management and role assignment depend on user data
- CCTV → CCTV API: calls · CCTV browsing and stream access go through the media BFF
- CCTV → CCTV data: uses · Camera map and metadata come from local CCTV data
- API routes → Rust backend: proxies · Route handlers forward or orchestrate calls to the Rust backend
- Auth API → Rust backend: proxies · Auth state is backed by backend-managed HttpOnly cookies
- Content API → Rust backend: proxies · Content, comments, and votes are delegated to backend services
- Chat API → Rust backend: proxies · Chat sessions and messages are backend-driven
- Ops API → Rust backend: proxies · Department and dashboard data comes from backend services
- Telemetry API → Rust backend: proxies · Logs and analytics are surfaced from backend telemetry
- Users API → Rust backend: proxies · User identity and directory lookups are delegated upstream
- CCTV API → Rust backend: proxies · Camera and stream access is mediated by the BFF
- Components → API client: uses · Interactive UI components call the shared API client
- Components → Auth state: uses · Auth-aware components consume shared auth state
- Components → Store: uses · Some components coordinate through shared client state
- App Router → API routes: hosts · The application exposes the BFF under the same Next.js runtime