# rafalez72/proyectoindividual-countries architecture

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

- Interactive diagram: https://gitdiagram.com/rafalez72/proyectoindividual-countries
- Repository: https://github.com/rafalez72/proyectoindividual-countries

## Overview

##### Project type and purpose
- This is a full-stack web application for browsing, filtering, creating, and favoriting countries and related activities.
- The frontend (React/Redux) communicates with a Node/Express backend, which in turn uses Sequelize to interact with a PostgreSQL database. An external countries API supplies domain data.

##### File structure
- Top-level directories:
- api/ (Express server code, models, routes, tests)
- client/ (React application, components, Redux store)
- cors-anywhere/ (likely a CORS proxy)
- Configuration/build files: package.json at root and in each sub-project; ESLint, npmrc, tests under api; React boilerplate under client.
- Patterns:
- API layer under api/src/routes
- Data models under api/src/models (Activity, Country, favorites)
- Redux for state management under client/src/Redux

##### README for additional insights
- It describes features: filtering, ordering, search, create country/activity, delete, favorites, detail views.
- Technology stack: React/Redux (frontend), Node/Express (backend), PostgreSQL + Sequelize (DB), external API.

##### Elements
- Browser → React components → Redux actions → API calls
- API controllers → Models → DB
- API ↔ External API
- Frontend (blue rectangles)
- Backend/API (green rectangles)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Frontend (React/Redux)" 
        direction TB
        Browser["User's Browser"]:::external
        Index["client/src/index.js"]:::frontend
        App["client/src/App.js"]:::frontend
        subgraph "UI Components"
            direction TB
            Home["Home Page<br/>home.jsx"]:::frontend
            Search["Search Bar<br/>searchBar.jsx"]:::frontend
            ActivityList["Activity Listing<br/>activity.jsx"]:::frontend
            CountryCard["Country Card<br/>country.jsx"]:::frontend
            CountryDetail["Country Detail<br/>countryDetail.jsx"]:::frontend
            CreateActivity["Create Activity Form<br/>createActivity.jsx"]:::frontend
            CreateCountry["Create Country Form<br/>createCountry.jsx"]:::frontend
            Favorites["Favorites View<br/>favorites.jsx"]:::frontend
            Landing["Landing Page<br/>landingPage.jsx"]:::frontend
            Initial["Initial Page<br/>initialPage.jsx"]:::frontend
        end
        subgraph "Redux Store"
            direction TB
            Store["store/index.js"]:::frontend
            Actions["actions/index.js"]:::frontend
            Reducer["reducer/index.js"]:::frontend
        end
    end

    %% Backend Layer
    subgraph "Backend (Express API)" 
        direction TB
        Server["api/index.js"]:::backend
        AppServer["api/src/app.js"]:::backend
        DBInit["api/src/db.js"]:::backend
        subgraph "Routes"
            direction TB
            MainRoutes["index.js"]:::backend
            GetApiRoute["GetApi.js"]:::backend
        end
        subgraph "Sequelize Models"
            direction TB
            ModelCountry["Country.js"]:::backend
            ModelActivity["Activities.js"]:::backend
            ModelFavorites["favorites.js"]:::backend
        end
    end

    %% Database Layer
    subgraph "Database (PostgreSQL)" 
        direction TB
        Postgres[(PostgreSQL)]:::db
    end

    %% External Services
    subgraph "External Services"
        direction TB
        CountriesAPI["External Countries API"]:::external
        CORSProxy["cors-anywhere/"]:::external
    end

    %% Connections Frontend
    Browser --> Index
    Index --> App
    App --> Home
    App --> Search
    App --> ActivityList
    App --> CountryCard
    App --> CountryDetail
    App --> CreateActivity
    App --> CreateCountry
    App --> Favorites
    App --> Landing
    App --> Initial
    App --> Store
    Store --> Actions
    Store --> Reducer

    %% Frontend to Backend
    App -->|"HTTP Requests"| Server
    Actions -->|"dispatches API calls"| Server

    %% Backend internals
    Server --> AppServer
    AppServer --> MainRoutes
    MainRoutes --> GetApiRoute
    AppServer --> DBInit
    DBInit --> Postgres
    MainRoutes --> ModelCountry
    MainRoutes --> ModelActivity
    MainRoutes --> ModelFavorites
    ModelCountry --> Postgres
    ModelActivity --> Postgres
    ModelFavorites --> Postgres

    %% External integration
    GetApiRoute --> CountriesAPI
    AppServer --> CORSProxy

    %% Click Events
    click Index "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/index.js"
    click App "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/App.js"
    click Home "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Components/Home/home.jsx"
    click Search "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Components/SearchBar/searchBar.jsx"
    click ActivityList "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Components/activity/activity.jsx"
    click CountryCard "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Components/country/country.jsx"
    click CountryDetail "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Components/countryDetail/countryDetail.jsx"
    click CreateActivity "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Components/createActivity/createActivity.jsx"
    click CreateCountry "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Components/createCountry/createCountry.jsx"
    click Favorites "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Components/favorites/favorites.jsx"
    click Landing "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Components/landingPage/landingPage.jsx"
    click Initial "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Components/initialPage/initialPage.jsx"
    click Store "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Redux/store/index.js"
    click Actions "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Redux/actions/index.js"
    click Reducer "https://github.com/rafalez72/proyectoindividual-countries/blob/main/client/src/Redux/reducer/index.js"
    click Server "https://github.com/rafalez72/proyectoindividual-countries/blob/main/api/index.js"
    click AppServer "https://github.com/rafalez72/proyectoindividual-countries/blob/main/api/src/app.js"
    click DBInit "https://github.com/rafalez72/proyectoindividual-countries/blob/main/api/src/db.js"
    click MainRoutes "https://github.com/rafalez72/proyectoindividual-countries/blob/main/api/src/routes/index.js"
    click GetApiRoute "https://github.com/rafalez72/proyectoindividual-countries/blob/main/api/src/routes/GetApi.js"
    click ModelCountry "https://github.com/rafalez72/proyectoindividual-countries/blob/main/api/src/models/Country.js"
    click ModelActivity "https://github.com/rafalez72/proyectoindividual-countries/blob/main/api/src/models/Activities.js"
    click ModelFavorites "https://github.com/rafalez72/proyectoindividual-countries/blob/main/api/src/models/favorites.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#037CD5,color:#000;
    classDef backend fill:#DFF5D0,stroke:#3C8D0D,color:#000;
    classDef db fill:#FFE2B3,stroke:#D58A00,color:#000;
    classDef external fill:#F0F0F0,stroke-dasharray: 5 5,stroke:#888,color:#000;
```
