# conovatec/observatoriofrontend architecture

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

- Interactive diagram: https://gitdiagram.com/conovatec/observatoriofrontend
- Repository: https://github.com/conovatec/observatoriofrontend

## Overview

##### 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.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["User's Browser"]:::external

    subgraph "Server Layer"
        NextServer["Next.js Runtime\n(next.config.js)"]:::server
        click NextServer "https://github.com/conovatec/observatoriofrontend/blob/main/next.config.js"
        Pages["Pages (SSR/SSG)\npages/*.tsx"]:::server
        click Pages "https://github.com/conovatec/observatoriofrontend/blob/main/pages/index.tsx"
        APIRoutes["API Routes\npages/api/*.ts"]:::server
        click APIRoutes "https://github.com/conovatec/observatoriofrontend/blob/main/pages/api/hello.ts"
    end

    subgraph "Client Layer"
        ReactComponents["React Components\nsrc/components, src/containers, src/views"]:::frontend
        UIComponents["UI Components\nsrc/components/*"]:::frontend
        click UIComponents "https://github.com/conovatec/observatoriofrontend/blob/main/src/components/CustomButton/index.tsx"
        Containers["Smart Components\nsrc/containers/*"]:::frontend
        click Containers "https://github.com/conovatec/observatoriofrontend/blob/main/src/containers/CustomNavBar/index.tsx"
        Views["Views & Layouts\nsrc/views/*"]:::frontend
        click Views "https://github.com/conovatec/observatoriofrontend/blob/main/src/views/DefaultLayout/index.tsx"

        subgraph "Redux"
            ReduxStore["Store\nsrc/redux/store.ts"]:::frontend
            click ReduxStore "https://github.com/conovatec/observatoriofrontend/blob/main/src/redux/store.ts"
            subgraph "Slices"
                PostsSlice["Posts Slice"]:::frontend
                click PostsSlice "https://github.com/conovatec/observatoriofrontend/blob/main/src/redux/posts/slice.ts"
                NationalSlice["National Slice"]:::frontend
                click NationalSlice "https://github.com/conovatec/observatoriofrontend/blob/main/src/redux/national/slice.ts"
                FormSlice["Form Slice"]:::frontend
                click FormSlice "https://github.com/conovatec/observatoriofrontend/blob/main/src/redux/form/slice.ts"
                StrategySlice["Strategy Slice"]:::frontend
                click StrategySlice "https://github.com/conovatec/observatoriofrontend/blob/main/src/redux/strategy/slice.ts"
                AboutCmpjSlice["AboutCmpj Slice"]:::frontend
                click AboutCmpjSlice "https://github.com/conovatec/observatoriofrontend/blob/main/src/redux/aboutCmpj/slice.ts"
                AboutObsSlice["AboutObservatory Slice"]:::frontend
                click AboutObsSlice "https://github.com/conovatec/observatoriofrontend/blob/main/src/redux/aboutObservatory/slice.ts"
                DirectiveSlice["Directive Slice"]:::frontend
                click DirectiveSlice "https://github.com/conovatec/observatoriofrontend/blob/main/src/redux/directive/slice.ts"
                SponsorsSlice["Sponsors Slice"]:::frontend
                click SponsorsSlice "https://github.com/conovatec/observatoriofrontend/blob/main/src/redux/sponsors/slice.ts"
            end
        end
    end

    subgraph "Data Layer"
        MockDB["Mock DB\nmock/db.json"]:::data
        click MockDB "https://github.com/conovatec/observatoriofrontend/blob/main/mock/db.json"
        ExternalServices["External Services & Databases"]:::external
    end

    %% Connections
    Browser -->|"HTTP GET (HTML)"| Pages
    Pages -->|"getStaticProps / getServerSideProps"| ReduxStore
    Pages -->|"renders UI"| ReactComponents
    ReactComponents -->|"dispatch actions / read state"| ReduxStore
    ReactComponents -->|"fetch JSON"| APIRoutes
    ReduxStore -->|"state updates"| ReactComponents
    APIRoutes -->|"JSON Data"| ReactComponents
    APIRoutes -->|"reads/writes"| MockDB
    APIRoutes -->|"calls"| ExternalServices

    %% Styles
    classDef frontend fill:#d4f4dd,stroke:#333,stroke-width:1px
    classDef server fill:#d0e1f9,stroke:#333,stroke-width:1px
    classDef data fill:#f9e7c1,stroke:#333,stroke-width:1px
    classDef external stroke-dasharray:5 5,stroke:#333
```
