How ww-side/structify-frontend works
Project Type and Purpose
• This is a full‑stack web application built with Next.js (React) serving both server‑side rendered (SSR) and client‑side rendered (CSR) pages.
• It uses Apollo Client to talk to a GraphQL backend (not contained in this repo), and implements authentication, user management, theming, and a feature‑driven UI (calendar, views, rows, columns, etc.).
Key Architectural Layers (derived from file tree)
• Presentation Layer (src/app): Next.js “app” routes, layouts, pages.
• Cross‑Cutting Core (src/core):
• api (Apollo provider)
• auth (sign‑in, sign‑up, token refresh, auth guard)
• theme (theme switcher, context)
• user (get‑me, update, logout, store)
• Feature Modules (src/features): Calendar, Columns, Create‑View, Rows, Row‑Value, Sidebar, View—each with its own components, lib (schemas/types), and service layer (actions, stores).
• Widgets (src/widgets): Page‑specific widget compositions (auth layouts, home widgets, settings, views).
Main Components
A. Next.js Application
• SSR Engine (Node.js at server startup)
• Client bundle (served to browser)
B. UI Component Tree
• Page Layouts (src/app/layout.tsx)
• Widgets & Feature Components
C. State & Data Layer
• Apollo Client (src/core/api/apollo-provider.tsx)
• React context/providers (Auth Guard, Theme)
• Feature stores and services (e.g., calendarEvents.store, user.store)
D. External Services
• GraphQL API endpoint
• Authentication service (could be part of GraphQL or external OAuth)
• Database (behind the GraphQL server)
E. Hosting/CI (Vercel)
Relationships and Data Flow
• User’s browser → HTTP request → Next.js server
• SSR resolves protected routes via Auth Guard → renders initial HTML.
• Client bundle loads → React hydrates
• Apollo Provider wraps app → feature components dispatch GraphQL queries/mutations.
• GraphQL requests → GraphQL server → Database → back to client.
• Auth flows (sign‑in/sign‑up/refresh) → Auth mutations → tokens stored in cookies or in-memory store → Auth Guard on client & server reads token.
• Theme toggles update Theme Context → persisted via local storage or context state.
Architectural Patterns & Principles
• Feature‑Driven Modularization: Each business domain has its own folder with clear boundaries.
• Atomic Design for UI Kit: Shared UI components are small (buttons, inputs) and composed into larger widgets.
• Provider Pattern: ApolloProvider, AuthGuard, ThemeProvider wrap the component tree.
• Separation of Concerns:
• UI (components)
• Data (services/actions/stores)
• Types/Validation (lib/schemas)