# nguyntu/swd392_happyprogramming architecture

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

- Interactive diagram: https://gitdiagram.com/nguyntu/swd392_happyprogramming
- Repository: https://github.com/nguyntu/swd392_happyprogramming

## Overview

Happy Programming is a mentor directory and admin CRUD application with account authentication and a floating Gemini chatbot. The main workflow is browsing or searching mentor listings, opening details/CVs, and—when signed in as an admin—creating, editing, deleting, or changing mentor visibility. The React client calls Spring REST controllers, which delegate to services and JPA repositories backed by MySQL. Edges reflect the shown excerpts, source-index references, or README documentation; some backend security and setup wiring is unsampled.

Main entry points: [`frontend/src/App.jsx`](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/App.jsx) (App navigation), [`frontend/src/pages/MentorManagement.jsx`](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/pages/MentorManagement.jsx) (Mentor management), [`backend/src/main/java/com/happyprogramming/repository/UserRepository.java`](https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/repository/UserRepository.java) (User repository), [`frontend/src/pages/HomePage.jsx`](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/pages/HomePage.jsx) (Mentor directory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_app["App navigation<br/>[App.jsx]"]
  node_home["Mentor directory<br/>[HomePage.jsx]"]
  node_adminpage["Mentor management"]
  node_mentorform["Mentor form<br/>[MentorForm.jsx]"]
  node_mentortable["Mentor table<br/>[MentorTable.jsx]"]
  node_authmodal["Auth modal<br/>[AuthModal.jsx]"]
  node_profile["User profile"]
  node_chatbot["AI chatbot<br/>[AiChatbot.jsx]"]
  node_mentorclient["Mentor API client<br/>[mentorService.js]"]
  node_authclient["Auth API client<br/>[authService.js]"]
  node_aiclient["AI API client<br/>[aiService.js]"]
end

subgraph group_api["REST API"]
  node_mentorcontroller["Mentor controller"]
  node_authcontroller["Auth controller"]
  node_aicontroller["AI controller<br/>[AiController.java]"]
end

subgraph group_domain["Domain services"]
  node_mentorservice["Mentor service"]
  node_authservice["Auth service"]
  node_aiservice["AI service<br/>[AiServiceImpl.java]"]
  node_contracts["DTO contracts"]
  node_exceptions["API exceptions"]
end

subgraph group_persistence["Persistence"]
  node_mentorrepo["Mentor repository"]
  node_userrepo["User repository"]
  node_entities["JPA entities"]
  node_mysql[("MySQL")]
end

subgraph group_security["Authentication"]
  node_securityconfig["Spring security"]
  node_userdetails["User lookup"]
  node_jwt["JWT utilities<br/>[JwtUtils.java]"]
end

node_visitor(("Visitor / admin"))
node_gemini{{"Google Gemini"}}

node_visitor -->|"uses"| node_app
node_app -->|"renders"| node_home
node_app -->|"renders"| node_adminpage
node_app -->|"opens"| node_authmodal
node_app -->|"renders"| node_chatbot
node_home -->|"loads listings"| node_mentorclient
node_home -->|"uses"| node_profile
node_adminpage -->|"renders"| node_mentorform
node_adminpage -->|"renders"| node_mentortable
node_adminpage -->|"manages mentors"| node_mentorclient
node_authmodal -->|"authenticates"| node_authclient
node_chatbot -->|"sends chat"| node_aiclient
node_mentorclient -->|"calls REST"| node_mentorcontroller
node_authclient -->|"calls REST"| node_authcontroller
node_aiclient -->|"calls REST"| node_aicontroller
node_mentorcontroller -->|"delegates"| node_mentorservice
node_authcontroller -->|"delegates"| node_authservice
node_aicontroller -->|"delegates"| node_aiservice
node_mentorservice -->|"queries"| node_mentorrepo
node_authservice -->|"reads / writes"| node_userrepo
node_authservice -->|"creates tokens"| node_jwt
node_userdetails -->|"looks up users"| node_userrepo
node_mentorrepo -->|"persists"| node_entities
node_userrepo -->|"persists"| node_entities
node_mentorrepo -->|"stores data"| node_mysql
node_userrepo -->|"stores data"| node_mysql
node_securityconfig -.->|"configures lookup"| node_userdetails
node_aiservice -.->|"requests responses"| node_gemini

click node_app "https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/App.jsx"
click node_home "https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/pages/HomePage.jsx"
click node_adminpage "https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/pages/MentorManagement.jsx"
click node_mentorform "https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/components/MentorForm.jsx"
click node_mentortable "https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/components/MentorTable.jsx"
click node_authmodal "https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/components/AuthModal.jsx"
click node_profile "https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/components/UserProfileModal.jsx"
click node_chatbot "https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/components/AiChatbot.jsx"
click node_mentorclient "https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/services/mentorService.js"
click node_authclient "https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/services/authService.js"
click node_aiclient "https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/services/aiService.js"
click node_mentorcontroller "https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/controller/MentorController.java"
click node_authcontroller "https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/controller/AuthController.java"
click node_aicontroller "https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/controller/AiController.java"
click node_mentorservice "https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/service/impl/MentorServiceImpl.java"
click node_authservice "https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/service/impl/AuthServiceImpl.java"
click node_aiservice "https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/service/impl/AiServiceImpl.java"
click node_contracts "https://github.com/nguyntu/swd392_happyprogramming/tree/main/backend/src/main/java/com/happyprogramming/dto"
click node_exceptions "https://github.com/nguyntu/swd392_happyprogramming/tree/main/backend/src/main/java/com/happyprogramming/exception"
click node_mentorrepo "https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/repository/MentorRepository.java"
click node_userrepo "https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/repository/UserRepository.java"
click node_entities "https://github.com/nguyntu/swd392_happyprogramming/tree/main/backend/src/main/java/com/happyprogramming/entity"
click node_securityconfig "https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/config/SecurityConfig.java"
click node_userdetails "https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/security/CustomUserDetailsService.java"
click node_jwt "https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/security/JwtUtils.java"

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_app,node_home,node_adminpage,node_mentorform,node_mentortable,node_authmodal,node_profile,node_chatbot,node_mentorclient,node_authclient,node_aiclient toneBlue
class node_mentorcontroller,node_authcontroller,node_aicontroller toneAmber
class node_mentorservice,node_authservice,node_aiservice,node_contracts,node_exceptions toneMint
class node_mentorrepo,node_userrepo,node_entities,node_mysql toneRose
class node_securityconfig,node_userdetails,node_jwt,node_visitor,node_gemini toneIndigo
```

## Components

### React client

- [App navigation](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Mentor directory](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/pages/HomePage.jsx): `frontend/src/pages/HomePage.jsx`
- [Mentor management](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/pages/MentorManagement.jsx): `frontend/src/pages/MentorManagement.jsx`
- [Mentor form](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/components/MentorForm.jsx): `frontend/src/components/MentorForm.jsx`
- [Mentor table](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/components/MentorTable.jsx): `frontend/src/components/MentorTable.jsx`
- [Auth modal](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/components/AuthModal.jsx): `frontend/src/components/AuthModal.jsx`
- [User profile](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/components/UserProfileModal.jsx): `frontend/src/components/UserProfileModal.jsx`
- [AI chatbot](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/components/AiChatbot.jsx): `frontend/src/components/AiChatbot.jsx`
- [Mentor API client](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/services/mentorService.js): `frontend/src/services/mentorService.js`
- [Auth API client](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/services/authService.js): `frontend/src/services/authService.js`
- [AI API client](https://github.com/nguyntu/swd392_happyprogramming/blob/main/frontend/src/services/aiService.js): `frontend/src/services/aiService.js`

### REST API

- [Mentor controller](https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/controller/MentorController.java): `backend/src/main/java/com/happyprogramming/controller/MentorController.java`
- [Auth controller](https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/controller/AuthController.java): `backend/src/main/java/com/happyprogramming/controller/AuthController.java`
- [AI controller](https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/controller/AiController.java): `backend/src/main/java/com/happyprogramming/controller/AiController.java`

### Domain services

- [Mentor service](https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/service/impl/MentorServiceImpl.java): `backend/src/main/java/com/happyprogramming/service/impl/MentorServiceImpl.java`
- [Auth service](https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/service/impl/AuthServiceImpl.java): `backend/src/main/java/com/happyprogramming/service/impl/AuthServiceImpl.java`
- [AI service](https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/service/impl/AiServiceImpl.java): `backend/src/main/java/com/happyprogramming/service/impl/AiServiceImpl.java`
- [DTO contracts](https://github.com/nguyntu/swd392_happyprogramming/tree/main/backend/src/main/java/com/happyprogramming/dto): `backend/src/main/java/com/happyprogramming/dto`
- [API exceptions](https://github.com/nguyntu/swd392_happyprogramming/tree/main/backend/src/main/java/com/happyprogramming/exception): `backend/src/main/java/com/happyprogramming/exception`

### Persistence

- [Mentor repository](https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/repository/MentorRepository.java): `backend/src/main/java/com/happyprogramming/repository/MentorRepository.java`
- [User repository](https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/repository/UserRepository.java): `backend/src/main/java/com/happyprogramming/repository/UserRepository.java`
- [JPA entities](https://github.com/nguyntu/swd392_happyprogramming/tree/main/backend/src/main/java/com/happyprogramming/entity): `backend/src/main/java/com/happyprogramming/entity`
- **MySQL**

### Authentication

- [Spring security](https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/config/SecurityConfig.java): `backend/src/main/java/com/happyprogramming/config/SecurityConfig.java`
- [User lookup](https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/security/CustomUserDetailsService.java): `backend/src/main/java/com/happyprogramming/security/CustomUserDetailsService.java`
- [JWT utilities](https://github.com/nguyntu/swd392_happyprogramming/blob/main/backend/src/main/java/com/happyprogramming/security/JwtUtils.java): `backend/src/main/java/com/happyprogramming/security/JwtUtils.java`

### Other components

- **Visitor / admin**
- **Google Gemini**

## Connections

- Visitor / admin → App navigation: uses (evidence: `README.md`)
- App navigation → Mentor directory: renders (evidence: `frontend/src/App.jsx`)
- App navigation → Mentor management: renders (evidence: `frontend/src/App.jsx`)
- App navigation → Auth modal: opens (evidence: `frontend/src/App.jsx`)
- App navigation → AI chatbot: renders (evidence: `frontend/src/App.jsx`)
- Mentor directory → Mentor API client: loads listings (evidence: `frontend/src/pages/HomePage.jsx`)
- Mentor directory → User profile: uses (evidence: `frontend/src/pages/HomePage.jsx`)
- Mentor management → Mentor form: renders (evidence: `frontend/src/pages/MentorManagement.jsx`)
- Mentor management → Mentor table: renders (evidence: `frontend/src/pages/MentorManagement.jsx`)
- Mentor management → Mentor API client: manages mentors (evidence: `frontend/src/pages/MentorManagement.jsx`)
- Auth modal → Auth API client: authenticates (evidence: `frontend/src/components/AuthModal.jsx`)
- AI chatbot → AI API client: sends chat (evidence: `frontend/src/components/AiChatbot.jsx`)
- Mentor API client → Mentor controller: calls REST (evidence: `README.md`)
- Auth API client → Auth controller: calls REST (evidence: `README.md`)
- AI API client → AI controller: calls REST (evidence: `README.md`)
- Mentor controller → Mentor service: delegates (evidence: `backend/src/main/java/com/happyprogramming/controller/MentorController.java`)
- Auth controller → Auth service: delegates (evidence: `backend/src/main/java/com/happyprogramming/controller/AuthController.java`)
- AI controller → AI service: delegates (evidence: `backend/src/main/java/com/happyprogramming/controller/AiController.java`)
- Mentor service → Mentor repository: queries (evidence: `backend/src/main/java/com/happyprogramming/service/impl/MentorServiceImpl.java`)
- Auth service → User repository: reads / writes (evidence: `backend/src/main/java/com/happyprogramming/service/impl/AuthServiceImpl.java`)
- Auth service → JWT utilities: creates tokens (evidence: `backend/src/main/java/com/happyprogramming/service/impl/AuthServiceImpl.java`)
- User lookup → User repository: looks up users (evidence: `backend/src/main/java/com/happyprogramming/security/CustomUserDetailsService.java`)
- Mentor repository → JPA entities: persists (evidence: `backend/src/main/java/com/happyprogramming/repository/MentorRepository.java`)
- User repository → JPA entities: persists (evidence: `backend/src/main/java/com/happyprogramming/repository/UserRepository.java`)
- Mentor repository → MySQL: stores data (evidence: `README.md`)
- User repository → MySQL: stores data (evidence: `README.md`)
- Spring security → User lookup: configures lookup
- AI service → Google Gemini: requests responses (evidence: `README.md`)
