# amirphiladam2/swepack architecture

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

- Interactive diagram: https://gitdiagram.com/amirphiladam2/swepack
- Repository: https://github.com/amirphiladam2/swepack

## Overview

SWEPack is a resource-discovery and curation product: users browse and search a library, submit resources for review, save finds, and organize them into private collections; administrators manage moderation and taxonomy. The Next.js app proxies requests to a NestJS REST API, whose domain services use Prisma with PostgreSQL. Authentication supports Firebase-backed sessions, GitHub sign-in/linking, and optional password-reset email. Several frontend-to-feature connections and unsampled backend modules are included only where the README documents them; edges cite that documentation or shown source references.

Main entry points: [`frontend/src/app`](https://github.com/amirphiladam2/swepack/tree/main/frontend/src/app) (Next.js app), [`backend/src/app.module.ts`](https://github.com/amirphiladam2/swepack/blob/main/backend/src/app.module.ts) (NestJS REST API), [`backend/src/auth/auth.service.ts`](https://github.com/amirphiladam2/swepack/blob/main/backend/src/auth/auth.service.ts) (Authentication service), [`backend/src/prisma/prisma.service.ts`](https://github.com/amirphiladam2/swepack/blob/main/backend/src/prisma/prisma.service.ts) (Prisma data access)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Next.js app"]
  node_proxy["API proxy<br/>[route.ts]"]
  node_resource_ui["Resource browsing<br/>[page.tsx]"]
  node_submit_ui["Resource submission"]
  node_account_ui["Account and admin<br/>[page.tsx]"]
  node_collection_ui["Collection screens"]
end

subgraph group_identity["Identity and sessions"]
  node_auth_api["Authentication routes<br/>[auth.controller.ts]"]
  node_auth_service["Authentication service<br/>[auth.service.ts]"]
  node_github_oauth["GitHub OAuth"]
end

subgraph group_catalog["Resource catalog"]
  node_resource_api["Resource routes"]
  node_resource_service["Resource catalog service"]
  node_metadata["Metadata preview"]
  node_taxonomy["Categories and tags"]
end

subgraph group_curation["Curation and administration"]
  node_collections_api["Collection routes"]
  node_collections_service["Collection service"]
end

node_visitor(("Visitor"))
node_api["NestJS REST API<br/>[app.module.ts]"]
node_firebase{{"Firebase Auth"}}
node_github{{"GitHub"}}
node_email{{"Email provider"}}
node_prisma["Prisma data access<br/>[prisma.service.ts]"]
node_postgres[("PostgreSQL")]

node_visitor -->|"uses"| node_webapp
node_webapp -->|"sends API requests"| node_proxy
node_proxy -->|"forwards requests"| node_api
node_webapp -->|"presents browsing"| node_resource_ui
node_webapp -->|"presents submission"| node_submit_ui
node_webapp -->|"presents account tools"| node_account_ui
node_webapp -->|"presents collections"| node_collection_ui
node_api -.->|"routes authentication"| node_auth_api
node_auth_api -->|"delegates to"| node_auth_service
node_auth_service -->|"verifies tokens"| node_firebase
node_auth_api -->|"uses OAuth flow"| node_github_oauth
node_github_oauth -->|"exchanges identity"| node_github
node_github_oauth -->|"creates access token"| node_auth_service
node_auth_service -->|"sends reset email"| node_email
node_api -.->|"routes resources"| node_resource_api
node_resource_api -->|"delegates to"| node_resource_service
node_resource_api -->|"fetches preview"| node_metadata
node_resource_service -->|"queries data"| node_prisma
node_api -->|"serves taxonomy"| node_taxonomy
node_taxonomy -->|"reads and writes"| node_prisma
node_api -.->|"routes collections"| node_collections_api
node_collections_api -->|"delegates to"| node_collections_service
node_collections_service -->|"reads and writes"| node_prisma
node_auth_service -->|"persists accounts"| node_prisma
node_prisma -->|"connects through adapter"| node_postgres

click node_webapp "https://github.com/amirphiladam2/swepack/tree/main/frontend/src/app"
click node_proxy "https://github.com/amirphiladam2/swepack/blob/main/frontend/src/app/api/backend/%5B...path%5D/route.ts"
click node_resource_ui "https://github.com/amirphiladam2/swepack/blob/main/frontend/src/app/page.tsx"
click node_submit_ui "https://github.com/amirphiladam2/swepack/blob/main/frontend/src/components/resources/submit-resource-form.tsx"
click node_account_ui "https://github.com/amirphiladam2/swepack/blob/main/frontend/src/app/account/page.tsx"
click node_collection_ui "https://github.com/amirphiladam2/swepack/tree/main/frontend/src/app/collections"
click node_api "https://github.com/amirphiladam2/swepack/blob/main/backend/src/app.module.ts"
click node_auth_api "https://github.com/amirphiladam2/swepack/blob/main/backend/src/auth/auth.controller.ts"
click node_auth_service "https://github.com/amirphiladam2/swepack/blob/main/backend/src/auth/auth.service.ts"
click node_github_oauth "https://github.com/amirphiladam2/swepack/blob/main/backend/src/auth/github-oauth.service.ts"
click node_resource_api "https://github.com/amirphiladam2/swepack/blob/main/backend/src/resources/resources.controller.ts"
click node_resource_service "https://github.com/amirphiladam2/swepack/blob/main/backend/src/resources/resources.service.ts"
click node_metadata "https://github.com/amirphiladam2/swepack/blob/main/backend/src/resources/resource-metadata.service.ts"
click node_taxonomy "https://github.com/amirphiladam2/swepack/tree/main/backend/src/categories"
click node_collections_api "https://github.com/amirphiladam2/swepack/blob/main/backend/src/collections/collections.controller.ts"
click node_collections_service "https://github.com/amirphiladam2/swepack/blob/main/backend/src/collections/collections.service.ts"
click node_prisma "https://github.com/amirphiladam2/swepack/blob/main/backend/src/prisma/prisma.service.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_webapp,node_proxy,node_resource_ui,node_submit_ui,node_account_ui,node_collection_ui toneBlue
class node_auth_api,node_auth_service,node_github_oauth,node_postgres toneAmber
class node_resource_api,node_resource_service,node_metadata,node_taxonomy,node_api toneMint
class node_collections_api,node_collections_service toneRose
class node_visitor,node_firebase,node_github,node_email toneIndigo
class node_prisma toneTeal
```

## Components

### Web experience

- [Next.js app](https://github.com/amirphiladam2/swepack/tree/main/frontend/src/app): `frontend/src/app`
- [API proxy](https://github.com/amirphiladam2/swepack/blob/main/frontend/src/app/api/backend/%5B...path%5D/route.ts): `frontend/src/app/api/backend/[...path]/route.ts`
- [Resource browsing](https://github.com/amirphiladam2/swepack/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Resource submission](https://github.com/amirphiladam2/swepack/blob/main/frontend/src/components/resources/submit-resource-form.tsx): `frontend/src/components/resources/submit-resource-form.tsx`
- [Account and admin](https://github.com/amirphiladam2/swepack/blob/main/frontend/src/app/account/page.tsx): `frontend/src/app/account/page.tsx`
- [Collection screens](https://github.com/amirphiladam2/swepack/tree/main/frontend/src/app/collections): `frontend/src/app/collections`

### Identity and sessions

- [Authentication routes](https://github.com/amirphiladam2/swepack/blob/main/backend/src/auth/auth.controller.ts): `backend/src/auth/auth.controller.ts`
- [Authentication service](https://github.com/amirphiladam2/swepack/blob/main/backend/src/auth/auth.service.ts): `backend/src/auth/auth.service.ts`
- [GitHub OAuth](https://github.com/amirphiladam2/swepack/blob/main/backend/src/auth/github-oauth.service.ts): `backend/src/auth/github-oauth.service.ts`

### Resource catalog

- [Resource routes](https://github.com/amirphiladam2/swepack/blob/main/backend/src/resources/resources.controller.ts): `backend/src/resources/resources.controller.ts`
- [Resource catalog service](https://github.com/amirphiladam2/swepack/blob/main/backend/src/resources/resources.service.ts): `backend/src/resources/resources.service.ts`
- [Metadata preview](https://github.com/amirphiladam2/swepack/blob/main/backend/src/resources/resource-metadata.service.ts): `backend/src/resources/resource-metadata.service.ts`
- [Categories and tags](https://github.com/amirphiladam2/swepack/tree/main/backend/src/categories): `backend/src/categories`

### Curation and administration

- [Collection routes](https://github.com/amirphiladam2/swepack/blob/main/backend/src/collections/collections.controller.ts): `backend/src/collections/collections.controller.ts`
- [Collection service](https://github.com/amirphiladam2/swepack/blob/main/backend/src/collections/collections.service.ts): `backend/src/collections/collections.service.ts`

### Other components

- **Visitor**
- [NestJS REST API](https://github.com/amirphiladam2/swepack/blob/main/backend/src/app.module.ts): `backend/src/app.module.ts`
- **Firebase Auth**
- **GitHub**
- **Email provider**
- [Prisma data access](https://github.com/amirphiladam2/swepack/blob/main/backend/src/prisma/prisma.service.ts): `backend/src/prisma/prisma.service.ts`
- **PostgreSQL**

## Connections

- Visitor → Next.js app: uses (evidence: `README.md`)
- Next.js app → API proxy: sends API requests (evidence: `README.md`)
- API proxy → NestJS REST API: forwards requests (evidence: `README.md`)
- Next.js app → Resource browsing: presents browsing (evidence: `README.md`)
- Next.js app → Resource submission: presents submission (evidence: `README.md`)
- Next.js app → Account and admin: presents account tools (evidence: `README.md`)
- Next.js app → Collection screens: presents collections (evidence: `README.md`)
- NestJS REST API → Authentication routes: routes authentication
- Authentication routes → Authentication service: delegates to (evidence: `backend/src/auth/auth.controller.ts`)
- Authentication service → Firebase Auth: verifies tokens (evidence: `backend/src/auth/auth.service.ts`)
- Authentication routes → GitHub OAuth: uses OAuth flow (evidence: `backend/src/auth/auth.controller.ts`)
- GitHub OAuth → GitHub: exchanges identity (evidence: `backend/src/auth/github-oauth.service.ts`)
- GitHub OAuth → Authentication service: creates access token (evidence: `backend/src/auth/github-oauth.service.ts`)
- Authentication service → Email provider: sends reset email (evidence: `backend/src/auth/auth.service.ts`)
- NestJS REST API → Resource routes: routes resources
- Resource routes → Resource catalog service: delegates to (evidence: `backend/src/resources/resources.controller.ts`)
- Resource routes → Metadata preview: fetches preview (evidence: `backend/src/resources/resources.controller.ts`)
- Resource catalog service → Prisma data access: queries data (evidence: `backend/src/resources/resources.service.ts`)
- NestJS REST API → Categories and tags: serves taxonomy (evidence: `backend/src/categories/categories.controller.ts`)
- Categories and tags → Prisma data access: reads and writes (evidence: `backend/src/categories/categories.service.ts`)
- NestJS REST API → Collection routes: routes collections
- Collection routes → Collection service: delegates to (evidence: `backend/src/collections/collections.controller.ts`)
- Collection service → Prisma data access: reads and writes (evidence: `backend/src/collections/collections.service.ts`)
- Authentication service → Prisma data access: persists accounts (evidence: `backend/src/auth/auth.service.ts`)
- Prisma data access → PostgreSQL: connects through adapter (evidence: `backend/src/prisma/prisma.service.ts`)
