# imaditya-jain/everm-re architecture

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

- Interactive diagram: https://gitdiagram.com/imaditya-jain/everm-re
- Repository: https://github.com/imaditya-jain/everm-re

## Overview

1. This is a Next.js App Router application with a mixed frontend/backend shape: UI pages live under `app/(pages)` and server endpoints live under `app/api/v1`. The repository is organized around account/auth workflows plus a Shopify integration and an AI SEO generation feature.

2. The public UI surface is split into a small set of route groups:
   - `/` home page
   - `/auth/*` authentication screens
   - `/dashboard` protected application area  
   The auth pages are wrapped by an auth-specific layout in `app/components/layout/auth`, and the dashboard is guarded by a `ProtectedRoute` component.

3. The main domain flows are authentication-centric. The API layer includes login, registration, logout, token refresh, “me”, username availability, verify-user, forgot-password, and reset-password endpoints. This indicates the app uses a server-issued session/token model rather than purely client-side auth.

4. Authentication state is split between client state and server cookies/tokens. Client-side state lives in Redux (`lib/store.ts`, `lib/slices/*`, `lib/features/*`), while low-level token/cookie handling is in `app/utils/auth-token.utils.ts` and `app/utils/auth-cookie.utils.ts`. An `auth-session-provider` bridges auth state into the React tree.

5. Account recovery and verification have an email-backed backend path. The mail config and helper (`app/config/nodemailer.config.ts`, `app/helpers/mail/send-mail.helper.ts`) support the forgot-password, reset-password, and verify-user routes. Those flows likely generate tokens and send transactional email from the API layer.

6. The Shopify integration is a second major subsystem. It includes:
   - store connection UI (`app/components/shopify/connect-store-form.tsx`)
   - install URL generation
   - OAuth callback and connect endpoints
   - product sync endpoint  
   Helper modules cover domain validation, access-token exchange, product fetching, and client setup. This is a clear external-service boundary centered on Shopify OAuth and catalog sync.

7. AI-assisted SEO generation is exposed as an API feature at `app/api/v1/ai/generate-seo`. The helper layer contains prompt templates and an AI provider abstraction, so the app is likely designed to swap or encapsulate the underlying model/provider without changing the route contract.

8. The data model layer is separate from the routes and helpers. `app/models/user.model.ts`, `store.model.ts`, and `product.model.ts` define the persistence entities used by auth, Shopify store linkage, and synced product data. `app/config/db.config.ts` is the central database connection/configuration boundary.

9. There is also a small GraphQL area (`app/graphQL/query.ts`, `mutation.ts`), which suggests some backend operations are expressed as GraphQL documents or integrations rather than only REST. In diagram terms, this is an auxiliary integration layer, not the primary app surface.

10. The client UI is composed from reusable form and field components under `app/components/forms`, `app/components/fields`, and `app/components/common`. These feed the route pages and keep the auth screens and Shopify connect flow thin.

11. Application-wide context is provided through `app/providers/StoreProvider.tsx` and `app/providers/auth-session-provider.tsx`. These providers are the main client-side composition boundary for state, session, and access to the Redux store.

12. The supporting runtime/tooling is standard Next.js/TypeScript with app-level CSS modules and globals, plus a service worker/manifest file indicating some PWA-oriented browser support. `next.config.ts`, `postcss.config.mjs`, and `eslint.config.mjs` are build/runtime support rather than core architecture.

13. The clearest end-to-end data flows are:
   - user auth screen → API route → token/cookie utils → Redux/auth provider → protected dashboard
   - forgot/reset/verify flows → mail helper → email delivery → token-based follow-up route
   - Shopify connect → OAuth callback → store model/token exchange → product sync → product model
   - AI SEO request → AI route → prompt/provider helper → generated content response

14. For an architecture diagram, the main boundaries to show are: browser/UI, Next.js server routes, persistence/database, email delivery, Shopify external API, and AI provider. The repo is structured as a single Next.js application that bundles all of these concerns behind one codebase rather than splitting them into separate services.

Main entry points: [`app/api/v1/auth`](https://github.com/imaditya-jain/everm-re/tree/main/app/api/v1/auth) (Auth API), [`app/api/v1/shopify`](https://github.com/imaditya-jain/everm-re/tree/main/app/api/v1/shopify) (Shopify API), [`app/(pages)/auth`](https://github.com/imaditya-jain/everm-re/tree/main/app/(pages)/auth) (Auth pages), [`app/config/db.config.ts`](https://github.com/imaditya-jain/everm-re/blob/main/app/config/db.config.ts) (DB config)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["UI"]
  node_home_page["Home<br/>page<br/>[page.tsx]"]
  node_auth_pages["Auth pages<br/>route group"]
  node_dashboard_page["Dashboard<br/>page<br/>[page.tsx]"]
  node_auth_layout["Auth layout<br/>[layout.tsx]"]
  node_protected_route["Protected route<br/>guard"]
end

subgraph group_client["Client State"]
  node_store_provider["Store provider<br/>[StoreProvider.tsx]"]
  node_session_provider["Session provider"]
  node_redux_state[("Redux state<br/>store<br/>[store.ts]")]
  node_auth_feature["Auth feature<br/>[auth.feature.ts]"]
end

subgraph group_api["API"]
  node_auth_api["Auth API<br/>routes"]
  node_shopify_api["Shopify API<br/>routes"]
  node_ai_api["SEO API<br/>route<br/>[route.ts]"]
end

subgraph group_integrations["Integrations"]
  node_shopify_helper["Shopify helpers<br/>integration helper"]
  node_ai_helper["AI helper<br/>provider helper"]
end

subgraph group_data["Data"]
  node_db_config[("DB config<br/>database config<br/>[db.config.ts]")]
  node_user_model["User model<br/>[user.model.ts]"]
  node_store_model["Store model<br/>[store.model.ts]"]
  node_product_model["Product model<br/>[product.model.ts]"]
end

subgraph group_shared["Shared"]
  node_mail_helper["Mail helper"]
  node_graphql_docs["GraphQL docs<br/>documents<br/>[query.ts]"]
end

node_home_page -->|"entry"| node_auth_pages
node_auth_pages -->|"wrapped by"| node_auth_layout
node_dashboard_page -->|"guarded by"| node_protected_route
node_protected_route -->|"reads session"| node_session_provider
node_store_provider -->|"provides"| node_redux_state
node_session_provider -->|"syncs auth"| node_redux_state
node_auth_pages -->|"calls"| node_auth_api
node_auth_feature -->|"dispatches"| node_auth_api
node_auth_api -->|"persists"| node_user_model
node_auth_api -->|"uses"| node_db_config
node_auth_api -->|"sends email"| node_mail_helper
node_auth_api -.->|"may query"| node_graphql_docs
node_shopify_api -->|"delegates"| node_shopify_helper
node_shopify_api -->|"persists"| node_store_model
node_shopify_api -->|"syncs"| node_product_model
node_shopify_api -->|"uses"| node_db_config
node_ai_api -->|"delegates"| node_ai_helper
node_mail_helper -.->|"may depend on"| node_db_config
node_shopify_helper -.->|"supports"| node_graphql_docs

click node_home_page "https://github.com/imaditya-jain/everm-re/blob/main/app/page.tsx"
click node_auth_pages "https://github.com/imaditya-jain/everm-re/tree/main/app/(pages)/auth"
click node_dashboard_page "https://github.com/imaditya-jain/everm-re/blob/main/app/(pages)/dashboard/page.tsx"
click node_auth_layout "https://github.com/imaditya-jain/everm-re/blob/main/app/components/layout/auth/layout.tsx"
click node_protected_route "https://github.com/imaditya-jain/everm-re/blob/main/app/components/auth/protected-route.tsx"
click node_store_provider "https://github.com/imaditya-jain/everm-re/blob/main/app/providers/StoreProvider.tsx"
click node_session_provider "https://github.com/imaditya-jain/everm-re/blob/main/app/providers/auth-session-provider.tsx"
click node_redux_state "https://github.com/imaditya-jain/everm-re/blob/main/lib/store.ts"
click node_auth_feature "https://github.com/imaditya-jain/everm-re/blob/main/lib/features/auth.feature.ts"
click node_auth_api "https://github.com/imaditya-jain/everm-re/tree/main/app/api/v1/auth"
click node_shopify_api "https://github.com/imaditya-jain/everm-re/tree/main/app/api/v1/shopify"
click node_ai_api "https://github.com/imaditya-jain/everm-re/blob/main/app/api/v1/ai/generate-seo/route.ts"
click node_db_config "https://github.com/imaditya-jain/everm-re/blob/main/app/config/db.config.ts"
click node_user_model "https://github.com/imaditya-jain/everm-re/blob/main/app/models/user.model.ts"
click node_store_model "https://github.com/imaditya-jain/everm-re/blob/main/app/models/store.model.ts"
click node_product_model "https://github.com/imaditya-jain/everm-re/blob/main/app/models/product.model.ts"
click node_mail_helper "https://github.com/imaditya-jain/everm-re/blob/main/app/helpers/mail/send-mail.helper.ts"
click node_shopify_helper "https://github.com/imaditya-jain/everm-re/tree/main/app/helpers/shopify"
click node_ai_helper "https://github.com/imaditya-jain/everm-re/tree/main/app/helpers/ai"
click node_graphql_docs "https://github.com/imaditya-jain/everm-re/blob/main/app/graphQL/query.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_page,node_auth_pages,node_dashboard_page,node_auth_layout,node_protected_route toneBlue
class node_store_provider,node_session_provider,node_redux_state,node_auth_feature toneAmber
class node_auth_api,node_shopify_api,node_ai_api toneMint
class node_shopify_helper,node_ai_helper toneRose
class node_db_config,node_user_model,node_store_model,node_product_model toneIndigo
class node_mail_helper,node_graphql_docs toneTeal
```

## Components

### UI

Pages and reusable client components

- [Home](https://github.com/imaditya-jain/everm-re/blob/main/app/page.tsx): page · Public landing page · `app/page.tsx`
- [Auth pages](https://github.com/imaditya-jain/everm-re/tree/main/app/(pages)/auth): route group · Login, register, recovery, verify screens · `app/(pages)/auth`
- [Dashboard](https://github.com/imaditya-jain/everm-re/blob/main/app/(pages)/dashboard/page.tsx): page · Protected app area · `app/(pages)/dashboard/page.tsx`
- [Auth layout](https://github.com/imaditya-jain/everm-re/blob/main/app/components/layout/auth/layout.tsx): layout · Layout wrapper for auth screens · `app/components/layout/auth/layout.tsx`
- [Protected route](https://github.com/imaditya-jain/everm-re/blob/main/app/components/auth/protected-route.tsx): guard · Client guard for dashboard access · `app/components/auth/protected-route.tsx`

### Client State

React providers and Redux state

- [Store provider](https://github.com/imaditya-jain/everm-re/blob/main/app/providers/StoreProvider.tsx): provider · Redux provider wrapper · `app/providers/StoreProvider.tsx`
- [Session provider](https://github.com/imaditya-jain/everm-re/blob/main/app/providers/auth-session-provider.tsx): provider · Bridges auth session into React tree · `app/providers/auth-session-provider.tsx`
- [Redux state](https://github.com/imaditya-jain/everm-re/blob/main/lib/store.ts): store · Auth and username-check slices · `lib/store.ts`
- [Auth feature](https://github.com/imaditya-jain/everm-re/blob/main/lib/features/auth.feature.ts): feature · Client auth workflows · `lib/features/auth.feature.ts`

### API

Next.js server routes

- [Auth API](https://github.com/imaditya-jain/everm-re/tree/main/app/api/v1/auth): routes · Login, register, token, recovery endpoints · `app/api/v1/auth`
- [Shopify API](https://github.com/imaditya-jain/everm-re/tree/main/app/api/v1/shopify): routes · Connect, callback, and product sync endpoints · `app/api/v1/shopify`
- [SEO API](https://github.com/imaditya-jain/everm-re/blob/main/app/api/v1/ai/generate-seo/route.ts): route · AI SEO generation endpoint · `app/api/v1/ai/generate-seo/route.ts`

### Integrations

External service boundaries

- [Shopify helpers](https://github.com/imaditya-jain/everm-re/tree/main/app/helpers/shopify): integration helper · OAuth, validation, token exchange, product fetch · `app/helpers/shopify`
- [AI helper](https://github.com/imaditya-jain/everm-re/tree/main/app/helpers/ai): provider helper · Prompts and model abstraction · `app/helpers/ai`

### Data

Database models and config

- [DB config](https://github.com/imaditya-jain/everm-re/blob/main/app/config/db.config.ts): database config · Database connection boundary · `app/config/db.config.ts`
- [User model](https://github.com/imaditya-jain/everm-re/blob/main/app/models/user.model.ts): model · Account persistence · `app/models/user.model.ts`
- [Store model](https://github.com/imaditya-jain/everm-re/blob/main/app/models/store.model.ts): model · Shopify store linkage · `app/models/store.model.ts`
- [Product model](https://github.com/imaditya-jain/everm-re/blob/main/app/models/product.model.ts): model · Synced catalog data · `app/models/product.model.ts`

### Shared

Helpers and cross-cutting support

- [Mail helper](https://github.com/imaditya-jain/everm-re/blob/main/app/helpers/mail/send-mail.helper.ts): email helper · Transactional email delivery · `app/helpers/mail/send-mail.helper.ts`
- [GraphQL docs](https://github.com/imaditya-jain/everm-re/blob/main/app/graphQL/query.ts): documents · Auxiliary query and mutation documents · `app/graphQL/query.ts`

## Connections

- Home → Auth pages: entry · Users move from landing to authentication
- Auth pages → Auth layout: wrapped by · Auth screens share a dedicated layout
- Dashboard → Protected route: guarded by · Dashboard access is protected client-side
- Protected route → Session provider: reads session · Guard depends on session state
- Store provider → Redux state: provides · Redux store is exposed to the app
- Session provider → Redux state: syncs auth · Session state bridges into Redux
- Auth pages → Auth API: calls · Auth UI submits to server auth routes
- Auth feature → Auth API: dispatches · Client feature talks to auth endpoints
- Auth API → User model: persists · Account records are stored in user model
- Auth API → DB config: uses · Auth routes depend on database connection
- Auth API → Mail helper: sends email · Recovery and verification flows send mail
- Auth API → GraphQL docs: may query · Auxiliary backend documents support some operations
- Shopify API → Shopify helpers: delegates · Shopify routes rely on integration helpers
- Shopify API → Store model: persists · Store connection data is saved
- Shopify API → Product model: syncs · Synced products are stored
- Shopify API → DB config: uses · Shopify routes use the database boundary
- SEO API → AI helper: delegates · AI route uses prompt and provider abstraction
- Mail helper → DB config: may depend on · Email workflows may reference persisted tokens or users
- Shopify helpers → GraphQL docs: supports · Shared documents can back integration operations
