# renxsaurr/swapy architecture

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

- Interactive diagram: https://gitdiagram.com/renxsaurr/swapy
- Repository: https://github.com/renxsaurr/swapy

## Overview

Swapy is a marketplace web app with a Next.js frontend, NestJS REST API, and PostgreSQL/PostGIS database. The evidenced user workflow is account sign-up or sign-in in the web UI, API credential/session handling, and persistence of account and session data; the account menu also checks and ends sessions. The tree and product docs describe broader marketplace domains, but sampled implementation evidence is concentrated in authentication, basic user access, health, and starter pages. Those unsampled domains are not expanded into speculative runtime flows.

Main entry points: [`apps/api/src/app.module.ts`](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/app.module.ts) (API modules), [`apps/api/src/auth/auth.controller.ts`](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/auth/auth.controller.ts) (Auth routes), [`apps/api/src/db/db.module.ts`](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/db/db.module.ts) (Database provider), [`apps/api/src/db/schema.ts`](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/db/schema.ts) (Account schema)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web app"]
  node_home["Home page<br/>[page.tsx]"]
  node_login["Account form<br/>[login.tsx]"]
  node_account_menu["Account menu<br/>[header-actions.tsx]"]
  node_items["Items page<br/>[items.tsx]"]
end

subgraph group_api["API"]
  node_bootstrap["API bootstrap<br/>[main.ts]"]
  node_app_module["API modules<br/>[app.module.ts]"]
  node_auth_routes["Auth routes<br/>[auth.controller.ts]"]
  node_auth_logic["Auth service<br/>[auth.service.ts]"]
  node_signup_dto["Sign-up validation<br/>[sign-up.dto.ts]"]
  node_users_routes["User routes"]
  node_users_logic["User service<br/>[users.service.ts]"]
  node_health_route["Health route"]
  node_root_route["Root route<br/>[app.controller.ts]"]
  node_root_logic["Root service<br/>[app.service.ts]"]
end

subgraph group_data["Persistence"]
  node_db_module["Database provider<br/>[db.module.ts]"]
  node_schema["Account schema<br/>[schema.ts]"]
end

node_visitor(("Marketplace visitor"))
node_postgres[("PostgreSQL")]

node_visitor -->|"opens"| node_home
node_visitor -->|"submits credentials"| node_login
node_home -->|"renders"| node_account_menu
node_login -->|"posts sign-in/up"| node_auth_routes
node_account_menu -->|"checks/signs out"| node_auth_routes
node_bootstrap -->|"starts"| node_app_module
node_app_module -->|"registers"| node_auth_routes
node_app_module -->|"registers"| node_users_routes
node_app_module -->|"registers"| node_health_route
node_app_module -->|"registers"| node_root_route
node_auth_routes -->|"delegates"| node_auth_logic
node_auth_routes -->|"accepts"| node_signup_dto
node_auth_logic -->|"uses database"| node_db_module
node_auth_logic -->|"reads/writes"| node_schema
node_users_routes -->|"delegates"| node_users_logic
node_users_logic -->|"uses database"| node_db_module
node_users_logic -->|"queries users"| node_schema
node_health_route -->|"checks database"| node_schema
node_root_route -->|"delegates"| node_root_logic
node_db_module -->|"configures ORM"| node_schema
node_db_module -->|"connects"| node_postgres

click node_home "https://github.com/renxsaurr/swapy/blob/main/apps/web/app/page.tsx"
click node_login "https://github.com/renxsaurr/swapy/blob/main/apps/web/app/accounts/login/login.tsx"
click node_account_menu "https://github.com/renxsaurr/swapy/blob/main/apps/web/app/components/header-actions.tsx"
click node_items "https://github.com/renxsaurr/swapy/blob/main/apps/web/app/items/items.tsx"
click node_bootstrap "https://github.com/renxsaurr/swapy/blob/main/apps/api/src/main.ts"
click node_app_module "https://github.com/renxsaurr/swapy/blob/main/apps/api/src/app.module.ts"
click node_auth_routes "https://github.com/renxsaurr/swapy/blob/main/apps/api/src/auth/auth.controller.ts"
click node_auth_logic "https://github.com/renxsaurr/swapy/blob/main/apps/api/src/auth/auth.service.ts"
click node_signup_dto "https://github.com/renxsaurr/swapy/blob/main/apps/api/src/auth/dto/sign-up.dto.ts"
click node_users_routes "https://github.com/renxsaurr/swapy/blob/main/apps/api/src/users/users.controller.ts"
click node_users_logic "https://github.com/renxsaurr/swapy/blob/main/apps/api/src/users/users.service.ts"
click node_health_route "https://github.com/renxsaurr/swapy/blob/main/apps/api/src/health/health.controller.ts"
click node_root_route "https://github.com/renxsaurr/swapy/blob/main/apps/api/src/app.controller.ts"
click node_root_logic "https://github.com/renxsaurr/swapy/blob/main/apps/api/src/app.service.ts"
click node_db_module "https://github.com/renxsaurr/swapy/blob/main/apps/api/src/db/db.module.ts"
click node_schema "https://github.com/renxsaurr/swapy/blob/main/apps/api/src/db/schema.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_home,node_login,node_account_menu,node_items toneBlue
class node_bootstrap,node_app_module,node_auth_routes,node_auth_logic,node_signup_dto,node_users_routes,node_users_logic,node_health_route,node_root_route,node_root_logic,node_postgres toneAmber
class node_db_module,node_schema toneMint
class node_visitor toneIndigo
```

## Components

### Web app

- [Home page](https://github.com/renxsaurr/swapy/blob/main/apps/web/app/page.tsx): `apps/web/app/page.tsx`
- [Account form](https://github.com/renxsaurr/swapy/blob/main/apps/web/app/accounts/login/login.tsx): `apps/web/app/accounts/login/login.tsx`
- [Account menu](https://github.com/renxsaurr/swapy/blob/main/apps/web/app/components/header-actions.tsx): `apps/web/app/components/header-actions.tsx`
- [Items page](https://github.com/renxsaurr/swapy/blob/main/apps/web/app/items/items.tsx): `apps/web/app/items/items.tsx`

### API

- [API bootstrap](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/main.ts): `apps/api/src/main.ts`
- [API modules](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/app.module.ts): `apps/api/src/app.module.ts`
- [Auth routes](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/auth/auth.controller.ts): `apps/api/src/auth/auth.controller.ts`
- [Auth service](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/auth/auth.service.ts): `apps/api/src/auth/auth.service.ts`
- [Sign-up validation](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/auth/dto/sign-up.dto.ts): `apps/api/src/auth/dto/sign-up.dto.ts`
- [User routes](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/users/users.controller.ts): `apps/api/src/users/users.controller.ts`
- [User service](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/users/users.service.ts): `apps/api/src/users/users.service.ts`
- [Health route](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/health/health.controller.ts): `apps/api/src/health/health.controller.ts`
- [Root route](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/app.controller.ts): `apps/api/src/app.controller.ts`
- [Root service](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/app.service.ts): `apps/api/src/app.service.ts`

### Persistence

- [Database provider](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/db/db.module.ts): `apps/api/src/db/db.module.ts`
- [Account schema](https://github.com/renxsaurr/swapy/blob/main/apps/api/src/db/schema.ts): `apps/api/src/db/schema.ts`

### Other components

- **Marketplace visitor**
- **PostgreSQL**

## Connections

- Marketplace visitor → Home page: opens (evidence: `apps/web/app/page.tsx`)
- Marketplace visitor → Account form: submits credentials (evidence: `apps/web/app/accounts/login/login.tsx`)
- Home page → Account menu: renders (evidence: `apps/web/app/page.tsx`)
- Account form → Auth routes: posts sign-in/up (evidence: `apps/web/app/accounts/login/login.tsx`)
- Account menu → Auth routes: checks/signs out (evidence: `apps/web/app/components/header-actions.tsx`)
- API bootstrap → API modules: starts (evidence: `apps/api/src/main.ts`)
- API modules → Auth routes: registers (evidence: `apps/api/src/app.module.ts`)
- API modules → User routes: registers (evidence: `apps/api/src/app.module.ts`)
- API modules → Health route: registers (evidence: `apps/api/src/app.module.ts`)
- API modules → Root route: registers (evidence: `apps/api/src/app.module.ts`)
- Auth routes → Auth service: delegates (evidence: `apps/api/src/auth/auth.controller.ts`)
- Auth routes → Sign-up validation: accepts (evidence: `apps/api/src/auth/auth.controller.ts`)
- Auth service → Database provider: uses database (evidence: `apps/api/src/auth/auth.service.ts`)
- Auth service → Account schema: reads/writes (evidence: `apps/api/src/auth/auth.service.ts`)
- User routes → User service: delegates (evidence: `apps/api/src/users/users.controller.ts`)
- User service → Database provider: uses database (evidence: `apps/api/src/users/users.service.ts`)
- User service → Account schema: queries users (evidence: `apps/api/src/users/users.service.ts`)
- Health route → Account schema: checks database (evidence: `apps/api/src/health/health.controller.ts`)
- Root route → Root service: delegates (evidence: `apps/api/src/app.controller.ts`)
- Database provider → Account schema: configures ORM (evidence: `apps/api/src/db/db.module.ts`)
- Database provider → PostgreSQL: connects (evidence: `apps/api/src/db/db.module.ts`)
