# amirun-nahin/stackunderflow-cse470-project architecture

> Architecture diagram of the GitHub repository amirun-nahin/stackunderflow-cse470-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/amirun-nahin/stackunderflow-cse470-project
- Repository: https://github.com/amirun-nahin/stackunderflow-cse470-project

## Overview

#### Purpose and Entry Points
A full-stack developer community platform combining social posts, groups/chat, coding challenges, competitions, bounties, quizzes, jobs, news, and GitHub integration. The API starts at `backend/index.js`; database setup is centralized in `backend/config/db.js`. The Vite/React client mounts from `frontend/src/main.jsx` and composes the application in `frontend/src/App.jsx`.

#### Backend HTTP and Authentication Boundary
Express route modules expose domain APIs, with authentication enforced through `backend/middlewares/AuthMiddleware.js`. User identity and account operations are handled through `backend/routes/auth.js` and `backend/routes/users.js`. Protected route handlers are the main boundary between browser-driven actions and persistent platform state.

#### Persistence Model
The backend uses a model-centric data layer. `backend/models/User.js` anchors identities; community content is represented by `backend/models/Post.js`, `backend/models/Comment.js`, and `backend/models/Vote.js`. Relationship and collaboration state is persisted in `backend/models/Group.js`, `backend/models/GroupMember.js`, and `backend/models/Message.js`. Database connection details are isolated at `backend/config/db.js`.

#### Community, Discovery, and Notifications
Social feed and discussion workflows flow through `backend/routes/posts.js`, then into post/comment/vote models. Group creation, membership, and group interaction are served by `backend/routes/groups.js` and `backend/routes/chat.js`. Cross-feature user alerts are stored in `backend/models/Notification.js` and exposed through `backend/routes/notifications.js`; the client surfaces them via `frontend/src/components/NotificationBell.jsx`.

#### Challenge and Competition Domains
Three structured challenge modes have separate APIs and persistence boundaries:
- Bounties: `backend/routes/bounty.js`, `backend/models/BountyEnrollment.js`, `backend/models/BountySubmission.js`.
- Competitions: `backend/routes/competition.js`, `backend/models/Competition.js`, `backend/models/CompetitionSubmission.js`.
- Duels and quiz: `backend/routes/duel.js`, `backend/models/Duel.js`, `backend/models/QuizAttempt.js`.

The client presents these as discoverable boards and detail workflows in `frontend/src/components/BountyBoard.jsx`, `frontend/src/components/CompetitionBoard.jsx`, and `frontend/src/pages/DuelDetail.jsx`.

#### External Content and Developer Integrations
GitHub connection/request functionality is isolated behind `backend/routes/github.js` and `backend/routes/repoRequest.js`, with request state in `backend/models/RepoRequestJoin.js`. Jobs and technology news are distinct external-content-facing domains at `backend/routes/jobs.js` and `backend/routes/news.js`; saved news state uses `backend/models/SavedNews.js`. Search is provided separately at `backend/routes/search.js`.

#### Frontend Navigation and Feature Composition
The React SPA uses page-level route targets for major workflows, including `frontend/src/pages/Home.jsx`, `frontend/src/pages/Discover.jsx`, and `frontend/src/pages/Profile.jsx`. Reusable feature widgets compose dashboards and feeds, notably `frontend/src/components/PostCard.jsx`, `frontend/src/components/DailyQuizCard.jsx`, and `frontend/src/components/GitHubConnect.jsx`. Client-to-server integration is mediated by the route-oriented backend API rather than a separate backend-for-frontend layer.

Main entry points: [`backend/index.js`](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/index.js) (API server), [`frontend/src/App.jsx`](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/App.jsx) (Application shell), [`backend/config/db.js`](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/config/db.js) (Database connection), [`backend/routes/posts.js`](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/routes/posts.js) (Community APIs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React SPA"]
  node_client_entry["Client entry<br/>Vite bootstrap<br/>[main.jsx]"]
  node_app["Application shell<br/>React composition<br/>[App.jsx]"]
  node_pages["Main pages<br/>route targets<br/>[Home.jsx]"]
  node_community_ui["Community UI<br/>feature components<br/>[PostCard.jsx]"]
  node_challenge_ui["Challenge boards<br/>feature components<br/>[BountyBoard.jsx]"]
  node_github_ui["GitHub connect<br/>feature component<br/>[GitHubConnect.jsx]"]
end

subgraph group_api["Express API"]
  node_api_entry["API server<br/>Express entry<br/>[index.js]"]
  node_auth{{"Auth boundary<br/>middleware and routes<br/>[AuthMiddleware.js]"}}
  node_community_api["Community APIs<br/>post, group, chat routes<br/>[posts.js]"]
  node_notification_api["Notification API<br/>route module<br/>[notifications.js]"]
  node_challenge_api["Challenge APIs<br/>bounty, competition, duel routes<br/>[bounty.js]"]
  node_github_api["GitHub and repo APIs<br/>integration routes<br/>[github.js]"]
  node_discovery_api["Jobs, news, search APIs<br/>content routes<br/>[jobs.js]"]
end

subgraph group_data["Persistence"]
  node_db_config[("Database connection<br/>database setup<br/>[db.js]")]
  node_identity_data[("Identity data<br/>user model<br/>[User.js]")]
  node_community_data[("Community data<br/>post, comment, vote models<br/>[Post.js]")]
  node_collaboration_data[("Group and chat data<br/>group, member, message models<br/>[Group.js]")]
  node_notification_data[("Notification data<br/>notification model<br/>[Notification.js]")]
  node_challenge_data[("Challenge data<br/>enrollment, submission, attempt models")]
  node_integration_data[("Saved integration state<br/>[RepoRequestJoin.js]")]
end

subgraph group_integrations["External Content"]
  node_github(("GitHub<br/>developer integration"))
  node_content_sources(("Jobs and news sources<br/>external content"))
end

node_client_entry -->|"mounts"| node_app
node_app -->|"routes to"| node_pages
node_app -->|"composes"| node_community_ui
node_app -->|"composes"| node_challenge_ui
node_app -->|"composes"| node_github_ui
node_pages -->|"API requests"| node_api_entry
node_community_ui -->|"API requests"| node_api_entry
node_challenge_ui -->|"API requests"| node_api_entry
node_github_ui -->|"API requests"| node_api_entry
node_api_entry -->|"protects routes"| node_auth
node_auth -->|"resolves user"| node_identity_data
node_api_entry -->|"serves"| node_community_api
node_api_entry -->|"serves"| node_notification_api
node_api_entry -->|"serves"| node_challenge_api
node_api_entry -->|"serves"| node_github_api
node_api_entry -->|"serves"| node_discovery_api
node_community_api -->|"persists"| node_community_data
node_community_api -->|"persists"| node_collaboration_data
node_notification_api -->|"persists"| node_notification_data
node_challenge_api -->|"persists"| node_challenge_data
node_github_api -->|"persists"| node_integration_data
node_github_api -->|"connects to"| node_github
node_discovery_api -->|"saves news"| node_integration_data
node_discovery_api -->|"retrieves"| node_content_sources
node_db_config -.->|"connects"| node_identity_data
node_db_config -.->|"connects"| node_community_data
node_db_config -.->|"connects"| node_challenge_data

click node_client_entry "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/main.jsx"
click node_app "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/App.jsx"
click node_pages "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/pages/Home.jsx"
click node_community_ui "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/components/PostCard.jsx"
click node_challenge_ui "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/components/BountyBoard.jsx"
click node_github_ui "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/components/GitHubConnect.jsx"
click node_api_entry "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/index.js"
click node_auth "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/middlewares/AuthMiddleware.js"
click node_community_api "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/routes/posts.js"
click node_notification_api "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/routes/notifications.js"
click node_challenge_api "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/routes/bounty.js"
click node_github_api "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/routes/github.js"
click node_discovery_api "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/routes/jobs.js"
click node_db_config "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/config/db.js"
click node_identity_data "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/models/User.js"
click node_community_data "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/models/Post.js"
click node_collaboration_data "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/models/Group.js"
click node_notification_data "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/models/Notification.js"
click node_challenge_data "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/models/BountyEnrollment.js"
click node_integration_data "https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/models/RepoRequestJoin.js"

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_client_entry,node_app,node_pages,node_community_ui,node_challenge_ui,node_github_ui toneBlue
class node_api_entry,node_auth,node_community_api,node_notification_api,node_challenge_api,node_github_api,node_discovery_api toneAmber
class node_db_config,node_identity_data,node_community_data,node_collaboration_data,node_notification_data,node_challenge_data,node_integration_data toneMint
class node_github,node_content_sources toneRose
```

## Components

### React SPA

- [Client entry](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/main.jsx): Vite bootstrap · `frontend/src/main.jsx`
- [Application shell](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/App.jsx): React composition · `frontend/src/App.jsx`
- [Main pages](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/pages/Home.jsx): route targets · Home, discovery, and profile workflows. · `frontend/src/pages/Home.jsx`
- [Community UI](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/components/PostCard.jsx): feature components · Posts and notification surfaces. · `frontend/src/components/PostCard.jsx`
- [Challenge boards](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/components/BountyBoard.jsx): feature components · Bounty, competition, and duel workflows. · `frontend/src/components/BountyBoard.jsx`
- [GitHub connect](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/frontend/src/components/GitHubConnect.jsx): feature component · `frontend/src/components/GitHubConnect.jsx`

### Express API

- [API server](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/index.js): Express entry · `backend/index.js`
- [Auth boundary](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/middlewares/AuthMiddleware.js): middleware and routes · Authenticates browser actions and manages accounts. · `backend/middlewares/AuthMiddleware.js`
- [Community APIs](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/routes/posts.js): post, group, chat routes · `backend/routes/posts.js`
- [Notification API](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/routes/notifications.js): route module · `backend/routes/notifications.js`
- [Challenge APIs](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/routes/bounty.js): bounty, competition, duel routes · `backend/routes/bounty.js`
- [GitHub and repo APIs](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/routes/github.js): integration routes · `backend/routes/github.js`
- [Jobs, news, search APIs](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/routes/jobs.js): content routes · `backend/routes/jobs.js`

### Persistence

- [Database connection](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/config/db.js): database setup · `backend/config/db.js`
- [Identity data](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/models/User.js): user model · `backend/models/User.js`
- [Community data](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/models/Post.js): post, comment, vote models · `backend/models/Post.js`
- [Group and chat data](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/models/Group.js): group, member, message models · `backend/models/Group.js`
- [Notification data](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/models/Notification.js): notification model · `backend/models/Notification.js`
- [Challenge data](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/models/BountyEnrollment.js): enrollment, submission, attempt models · Stores bounty, competition, duel, and quiz state. · `backend/models/BountyEnrollment.js`
- [Saved integration state](https://github.com/amirun-nahin/stackunderflow-cse470-project/blob/main/backend/models/RepoRequestJoin.js): repo request and saved news models · `backend/models/RepoRequestJoin.js`

### External Content

- **GitHub**: developer integration
- **Jobs and news sources**: external content

## Connections

- Client entry → Application shell: mounts
- Application shell → Main pages: routes to
- Application shell → Community UI: composes
- Application shell → Challenge boards: composes
- Application shell → GitHub connect: composes
- Main pages → API server: API requests
- Community UI → API server: API requests
- Challenge boards → API server: API requests
- GitHub connect → API server: API requests
- API server → Auth boundary: protects routes
- Auth boundary → Identity data: resolves user
- API server → Community APIs: serves
- API server → Notification API: serves
- API server → Challenge APIs: serves
- API server → GitHub and repo APIs: serves
- API server → Jobs, news, search APIs: serves
- Community APIs → Community data: persists
- Community APIs → Group and chat data: persists
- Notification API → Notification data: persists
- Challenge APIs → Challenge data: persists
- GitHub and repo APIs → Saved integration state: persists
- GitHub and repo APIs → GitHub: connects to
- Jobs, news, search APIs → Saved integration state: saves news
- Jobs, news, search APIs → Jobs and news sources: retrieves
- Database connection → Identity data: connects
- Database connection → Community data: connects
- Database connection → Challenge data: connects
