# amooonsen/wearther architecture

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

- Interactive diagram: https://gitdiagram.com/amooonsen/wearther
- Repository: https://github.com/amooonsen/wearther

## Overview

##### Project Type and Purpose
- The Wearther project is a full-stack weather and fashion recommendation application. The main goal is to combine current weather trends with personalized clothing suggestions.
- Although the back-end is developed in NestJS (as indicated in the README) and maintained in a separate repository, this repo primarily houses a Next.js frontend that leverages API routes to handle authentication, product recommendations, Instagram posts, and user operations.
- The project heavily relies on modern React practices (Next.js app routing, React Context, Zustand for state management) along with a rich set of UI components (Shadcn UI, TailwindCSS, Framer Motion) to build a responsive and interactive user interface.

##### Analyzing the File Structure
- Top-level configuration files (e.g., .eslintrc.json, next.config.js, tsconfig.json, tailwind.config.ts) establish project-wide settings.
- The “src/app” directory is the heart of the application. It includes:
- Authorization-related pages (login, register, find-email, find-password) in a route group named (auth).
- Several sections like company pages (contact-us, privacy-policy, terms), products (recommendation flows, trends), and resources.
- API endpoint definitions under “src/app/api” for authentication, Instagram posts, and users.
- The “src/components” directory contains shared UI blocks (e.g., HeaderNavigation, Footer, login and register forms), composites, typography, and a comprehensive set of UI elements – this indicates a component-driven architecture.
- Other directories such as “src/lib”, “src/service”, and “src/server” offer utility functions, API service abstraction layers, and server-side configurations. Their separation hints at a layered architecture with clear responsibilities.

##### Architectural Patterns and Design Principles
- Next.js “app” directory pattern organizes UI pages and API endpoints, reflecting a modern, file-based routing mechanism.
- The existence of distinct “auth”, “products”, “company”, “user”, and “resources” modules implies a modular design where features are kept separated.
- The use of context providers (found in “src/components/context”) and global state management (Zustand in “src/lib/store”) demonstrates the implementation of the Provider pattern to propagate shared state and functionality.
- Integration with well-known libraries (React Hook Form for form management, Zod for schema validation, Framer Motion/GSAP for animation) informs you of the rich client-side interactivity layer.

a. Frontend Client:
- Next.js Pages & Layouts: Represented by directories in “src/app” with individual pages (e.g., login, register, recommendation, trends, company info) and layout components.
- UI Components Library: Gathered under “src/components” (blocks, layouts, typography, composables, and UI elements).
- Context Providers & State Management: Mark the providers (AuthProvider, QueryProvider, ModalProvider) and Zustand stores (useAuthStore, etc.) that facilitate global state sharing.
b. API Endpoints (Serverless Functions via Next.js):
- Under “src/app/api”, include endpoints for authentication ([...nextauth]), Instagram posts, and user management. These route handlers allow the frontend to communicate with likely external back-end services.
c. Service and Utility Layers:
- The “src/service” (with API modules for board, product, recommend, trend, weather, youtube) encapsulates communication with external back-end services.
- The “src/lib” (with utility functions, constants, hooks, and types) forms a core layer that supports application logic and UI behavior.
d. External Services & Back-end:
- As detailed in the README, external backend services (NestJS, PostgreSQL, TypeORM) exist in a separate repo but must be included as a key element of the overall architecture.
- Containerization, continuous integration (GitHub Actions), and deployment (Vercel for frontend, AWS for backend) should be represented as well.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global User Node
    User("User"):::user

    %% Frontend Application Subgraph
    subgraph "Frontend Application"
        FE_Pages("Pages & Layouts"):::frontend
        FE_Auth("Authentication Module"):::frontend
        FE_Rec("Product Recommendation Module"):::frontend
        FE_Trends("Trends Module"):::frontend
        FE_UI("UI Components Library"):::frontend
        FE_Context("Context Providers"):::frontend
        FE_Store("Global State Management"):::frontend
    end

    %% API Endpoints Subgraph
    subgraph "API Endpoints"
        API_Auth("Auth Endpoint"):::api
        API_Instagram("Instagram Posts Endpoint"):::api
        API_Users("User Operations Endpoint"):::api
    end

    %% Service & Utility Layer Subgraph
    subgraph "Service & Utility Layer"
        Svc_API("API Service Abstractions"):::service
        Svc_Utils("Application Utilities & Constants"):::service
    end

    %% External Backend Services Subgraph
    subgraph "External Backend Services"
        Ext_NestJS("NestJS Server"):::external
        Ext_Postgres("PostgreSQL Database"):::external
    end

    %% Deployment & CI/CD Subgraph
    subgraph "Deployment & CI/CD"
        Deploy_Vercel("Vercel (Frontend Deployment)"):::deployment
        Deploy_AWS("AWS (Backend Deployment)"):::deployment
        Deploy_GH("GitHub Actions"):::deployment
        Deploy_Docker("Docker Containers"):::deployment
    end

    %% Connections
    
    %% User interactions with Frontend
    User -->|"interacts"| FE_Pages

    %% Frontend internal interactions leading to API calls
    FE_Auth -->|"calls"| API_Auth
    FE_UI   -->|"fetches"| API_Instagram
    FE_UI   -->|"fetches"| API_Users
    FE_Rec  -->|"triggers"| API_Users
    FE_Trends -->|"triggers"| API_Users

    %% Frontend modules utilizing utilities
    FE_UI -->|"utilizes"| Svc_Utils
    FE_Context -->|"uses"| Svc_Utils

    %% API Endpoints communicating with Service Layer
    API_Auth -->|"communicates"| Svc_API
    API_Instagram -->|"communicates"| Svc_API
    API_Users -->|"communicates"| Svc_API

    %% Service Layer contacting External Backend Services
    Svc_API -->|"calls backend"| Ext_NestJS
    Svc_API -->|"queries"| Ext_Postgres

    %% Deployment flows
    Deploy_Vercel -->|"deploys"| FE_Pages
    Deploy_AWS -->|"hosts"| Ext_NestJS
    Deploy_GH -->|"triggers"| Deploy_Vercel
    Deploy_GH -->|"triggers"| Deploy_AWS
    Deploy_Docker -->|"containerizes"| Ext_NestJS

    %% Styling Classes
    classDef frontend fill:#ccf,stroke:#036,stroke-width:2px;
    classDef api fill:#cfc,stroke:#0a0,stroke-width:2px;
    classDef service fill:#ffc,stroke:#d80,stroke-width:2px;
    classDef external fill:#fdd,stroke:#a00,stroke-width:2px;
    classDef deployment fill:#fcc,stroke:#c00,stroke-width:2px;
    classDef user fill:#eef,stroke:#00f,stroke-width:2px;

    %% Click Events (using provided component mappings)
    click FE_Pages "https://github.com/amooonsen/wearther/tree/main/src/app"
    click FE_Auth "https://github.com/amooonsen/wearther/tree/main/src/app/(auth)"
    click API_Auth "https://github.com/amooonsen/wearther/blob/main/src/app/api/auth/[...nextauth]/route.ts"
    click API_Instagram "https://github.com/amooonsen/wearther/blob/main/src/app/api/instagram-posts/route.ts"
    click API_Users "https://github.com/amooonsen/wearther/blob/main/src/app/api/users/route.ts"
    click FE_Rec "https://github.com/amooonsen/wearther/tree/main/src/app/products/recommend"
    click FE_Trends "https://github.com/amooonsen/wearther/tree/main/src/app/products/trends"
    click FE_UI "https://github.com/amooonsen/wearther/tree/main/src/components"
    click FE_Context "https://github.com/amooonsen/wearther/tree/main/src/components/context"
    click FE_Store "https://github.com/amooonsen/wearther/tree/main/src/lib/store"
    click Svc_API "https://github.com/amooonsen/wearther/tree/main/src/service/api"
    click Svc_Utils "https://github.com/amooonsen/wearther/tree/main/src/lib"
```
