# jgmacedo/cha-com-senhor-frontend architecture

> Architecture diagram of the GitHub repository jgmacedo/cha-com-senhor-frontend, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jgmacedo/cha-com-senhor-frontend
- Repository: https://github.com/jgmacedo/cha-com-senhor-frontend

## Overview

##### Project type and purpose
- This is a full-stack web application (“Chá com o Senhor”) for daily spiritual devotions, based on a Next.js 15 frontend and a Java Spring Boot REST API backend.
- Purpose: deliver daily devotional content (Bible verses + commentary), with separate user and admin experiences, authentication, profile management and content management.

##### File structure
- Top-level directories
– app/: Next.js App Router pages and layouts
– components/: reusable React UI components (shadcn/ui base under ui/, admin-specific under admin/)
– contexts/: React Context providers (auth, theme)
– hooks/: custom hooks (use-mobile, use-toast)
– lib/: API client, health-check and utility functions
– public/: static assets
- Config and scripts
– next.config.mjs, tailwind.config.ts, postcss.config.mjs, tsconfig.json: build and styling config
– vercel.json: Vercel deployment settings
- Project_memorial.md and readme.md contain documentation and architecture overview.

##### README for additional insights
- Frontend stack: Next.js, React, TypeScript, Tailwind CSS, shadcn/ui, next-themes
- Backend stack: Java Spring Boot (REST API), Spring Security with JWT, Spring Data JPA, relational database
- Deployment: Frontend on Vercel, Backend on a production server
- Key features: user/devotional flow, admin panel, authentication and authorization with roles

##### Detail
– App Router (app folder), Layout (layout.tsx), Pages (/page.tsx), UI Components (components/ui), Admin Components (components/admin), Context Providers (contexts/auth, theme)
- On the backend side, call out:
– Authentication module (Spring Security + JWT filter)
– Devotional service layer, Verse repository (Spring Data JPA)
– REST controllers for user, devotional, verse, health-check (lib/health-check aligns with a /health endpoint)
- Environments
– Development (localhost:3000, local Java server:8080) vs. Production (cha-com-senhor.vercel.app, backend server URL)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Browser["Browser/Mobile"]:::external

    %% Frontend (Vercel)
    subgraph "Frontend (Vercel)"
        subgraph "App Router (Next.js)"
            Layout["layout.tsx"]:::frontend
            PageHome["page.tsx"]:::frontend
            AdminPage["admin/page.tsx"]:::frontend
            LoginPage["auth/login/page.tsx"]:::frontend
            RegisterPage["auth/register/page.tsx"]:::frontend
            DashboardPage["dashboard/page.tsx"]:::frontend
            ProfilePage["dashboard/profile/page.tsx"]:::frontend
        end
        subgraph "UI Components"
            UI["components/ui/"]:::frontend
        end
        subgraph "Admin Components"
            AdminUI["components/admin/"]:::frontend
        end
        subgraph "Layout & Theming"
            DashLayout["dashboard-layout.tsx"]:::frontend
            ThemeProv["theme-provider.tsx"]:::frontend
            ThemeToggle["theme-toggle.tsx"]:::frontend
        end
        subgraph "Context & Hooks"
            AuthContext["contexts/auth-context.tsx"]:::frontend
            UseMobile["hooks/use-mobile.tsx"]:::frontend
            UseToast["hooks/use-toast.ts"]:::frontend
        end
        subgraph "Lib & Utils"
            APIClient["lib/api.ts"]:::frontend
            HealthHelper["lib/health-check.ts"]:::frontend
            Utils["lib/utils.ts"]:::frontend
        end
        Static["public/"]:::external
        Config["next.config.mjs / tailwind.config.ts / postcss.config.mjs / tsconfig.json"]:::frontend
        DeployCfg["vercel.json"]:::frontend
    end

    %% API Gateway
    Gateway["Vercel Edge/CDN"]:::external

    %% Backend (Spring Boot)
    subgraph "Backend (Spring Boot)"
        AuthMod["Spring Security + JWT"]:::backend
        subgraph "Controllers"
            UserCtrl["UserController"]:::backend
            DevotionalCtrl["DevotionalController"]:::backend
            VerseCtrl["VerseController"]:::backend
            HealthCtrl["HealthController"]:::backend
        end
        subgraph "Services & Repos"
            DevService["DevotionalService"]:::backend
            VerseRepo["VerseRepository"]:::backend
            UserRepo["UserRepository"]:::backend
        end
    end

    DB["PostgreSQL/MySQL"]:::datastore

    subgraph "External Services"
        Email["Email Service"]:::external
        Analytics["Analytics"]:::external
    end

    %% Connections
    Browser -->|"HTTP(S)"| Gateway
    Gateway -->|"SSR/CSR" | Layout
    Layout --> PageHome
    Layout --> AdminPage
    Layout --> LoginPage
    Layout --> RegisterPage
    Layout --> DashboardPage
    DashboardPage --> ProfilePage
    PageHome --> UI
    AdminPage --> AdminUI
    AdminPage --> AuthContext
    DashboardPage --> AuthContext
    AuthContext --> APIClient
    APIClient -->|"JWT Auth"| AuthMod
    APIClient -->|"REST Calls"| UserCtrl
    APIClient -->|"REST Calls"| DevotionalCtrl
    APIClient -->|"REST Calls"| VerseCtrl
    APIClient -->|"REST Calls"| HealthCtrl
    AuthMod --> UserRepo
    DevotionalCtrl --> DevService
    VerseCtrl --> VerseRepo
    UserCtrl --> UserRepo
    HealthCtrl --> HealthHelper
    DevService --> VerseRepo
    DevService --> DB
    VerseRepo --> DB
    UserRepo --> DB
    HealthHelper --> HealthCtrl
    UserCtrl --> Email
    PageHome --> Analytics

    %% Click Events
    click Layout "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/app/layout.tsx"
    click PageHome "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/app/page.tsx"
    click AdminPage "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/app/admin/page.tsx"
    click LoginPage "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/app/auth/login/page.tsx"
    click RegisterPage "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/app/auth/register/page.tsx"
    click DashboardPage "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/app/dashboard/page.tsx"
    click ProfilePage "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/app/dashboard/profile/page.tsx"
    click UI "https://github.com/jgmacedo/cha-com-senhor-frontend/tree/main/components/ui/"
    click AdminUI "https://github.com/jgmacedo/cha-com-senhor-frontend/tree/main/components/admin/"
    click DashLayout "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/components/dashboard-layout.tsx"
    click ThemeProv "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/components/theme-provider.tsx"
    click ThemeToggle "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/components/theme-toggle.tsx"
    click AuthContext "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/contexts/auth-context.tsx"
    click UseMobile "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/hooks/use-mobile.tsx"
    click UseToast "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/hooks/use-toast.ts"
    click APIClient "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/lib/api.ts"
    click HealthHelper "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/lib/health-check.ts"
    click Utils "https://github.com/jgmacedo/cha-com-senhor-frontend/blob/main/lib/utils.ts"

    %% Styles
    classDef frontend fill:#E0F7FA,stroke:#006064,color:#006064
    classDef backend fill:#E8F5E9,stroke:#2E7D32,color:#2E7D32
    classDef datastore fill:#FFF3E0,stroke:#EF6C00,color:#EF6C00
    classDef external fill:#ECEFF1,stroke:#607D8B,color:#607D8B
```
