How conovatec/observatoriofrontend works
Project Type and Purpose
• This is a full-stack React application built with Next.js. It delivers both the frontend pages (with SSR/SSG capabilities) and lightweight API endpoints under pages/api. It uses TypeScript, Redux Toolkit for client-side state, and CSS Modules for styling.
Main Architectural Components
a. Next.js Server
• Responsible for rendering React pages (SSR, SSG) and exposing API routes.
• Entry point: next.config.js, pages/ directory.
b. Presentation Layer (Frontend)
• Pages: pages/*.tsx handle routing and data-fetching methods (getStaticProps, getServerSideProps).
• UI Components and Containers:
• src/components/*: reusable, pure Presentation Components (buttons, cards, menus).
• src/containers/*: smart components wired to hooks, configs, and Redux slices.
• Layouts & Views:
• src/views/*: high-level composites (e.g., DefaultLayout, Carousel).
c. State Management
• Redux Toolkit slices under src/redux/* and the store in src/redux/store.ts.
• Centralized state for posts, national data, forms, strategy, etc.
d. Data Layer / API
• API Routes: pages/api/hello.ts (example) → Next.js handles HTTP JSON endpoints.
• Mocked Data: mock/db.json can simulate a backend datastore during development.
e. Configuration & Utilities
• Global config: config/index.ts, src/config/*.
• Theme & constants: src/utils/theme.tsx, src/utils/constants.ts.
f. Public Assets & Build
• Static assets in public/.
• Build config: .eslintrc.json, tsconfig.json, .github/workflows/*.yml for CI.
Relationships & Data Flows
• Browser → Next.js Server:
• Page requests → SSR/SSG → HTML + JSON.
• Client-side navigation via React Router.
• Frontend → State Store: dispatch actions & subscribe to slices.
• Frontend → API Routes: fetch JSON endpoints (/api/*).
• API Routes → Data Source: return data from mock/db.json or future real services.
Architectural Patterns & Principles
• Component-Based UI: clear separation of dumb (components) vs. smart (containers).
• Redux for centralized, predictable state.
• Next.js patterns: File-system routing, SSR/SSG data-fetch methods, API routes co-located under pages/api.
• TypeScript for type safety across layers.