# oscarpachecoh/wedding-app architecture

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

- Interactive diagram: https://gitdiagram.com/oscarpachecoh/wedding-app
- Repository: https://github.com/oscarpachecoh/wedding-app

## Overview

##### Project Type and Purpose
- This is a full-stack web application intended to manage wedding-related operations (like user login, personal registrations, and matching (“casar”) of couples).
- The project is divided into two main parts: the API (backend) and the Client (frontend), with an SQL database to store necessary data.

##### Analyzing the File Structure
- The top-level directories are:
- /api: Contains the Node.js backend. Notice the “src” folder with distinct sub-components like “controllers” (business logic for login, registration, and matching) and “routes” (which expose endpoints for these functionalities). There’s also a configuration file (config.js) and a database module (db.js).
- /client: Contains the frontend built in React (indicated by files like App.jsx, index.js, and several components and CSS files). There is a “Pages” folder that segregates different views (Login, Dashboard, Registrar, Casar).
- bodas.sql: Script for setting up the SQL database (with instructions in the README regarding importing and inserting initial data).

##### How to Represent the Architecture
a. Main Components to Include:
- Client Application (Frontend): Built with React, handling the user interface, navigation (Navbar, pages for registering and matching, etc.), and routing.
- API Server (Backend): A Node.js/Express server that manages user authentication (login), registration, matching logic (casar), and interacts with the SQL database.
- SQL Database: Stores wedding data (like user credentials, registered persons, likely marriage matches) with tables (e.g., admis for authentication).
- External Dependencies: Although not extensive in this project, note that there is a dependency on an SQL environment (MySQL or PostgreSQL) and possibly other NPM modules.

b. Relationships and Interactions:
- API’s internal flow: routes receiving requests, controllers handling business logic (with a specific note regarding the CURP generation function in the casarController), and the database module facilitating queries.

c. Architectural Patterns and Design Principles:
- Separation of Concerns: The code is split between backend and frontend.
- RESTful API architecture: The API is organized into distinct routes and controllers for each functionality.
- Modular Design: Each system concern is grouped (e.g., controllers under /api/src/controllers, view components under /client/src/Components, and pages under /client/src/Pages).

d. Relevant Technologies and Libraries:
- Backend: Node.js, Express (inferred from index.js and use of controllers/routes structure).
- Frontend: React (component-based UI, routing via components like ProtectedRouter).
- Database: SQL (with setup provided by bodas.sql).
- Additional: NPM packages (as seen in package.json files for both api and client), CSS for styling, and possibly axios or fetch being used for front-to-back communication.

##### Detailing the Essential Architectural Elements
- Don’t hesitate to further break down or detail the API module (e.g., show that “casar”, “login”, and “personas” have their dedicated controllers and routes) in a separate section if clarity is needed.

Summary:

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend
    subgraph "Frontend (React Client)"
        FE["React Frontend"]:::frontend
    end

    %% Backend (Express API)
    subgraph "Backend (Express API)"
        API["Express API"]:::backend
        subgraph "Routes"
            CASAR_ROUTE["Casar Routes"]:::routes
            LOGIN_ROUTE["Login Routes"]:::routes
            PERSONAS_ROUTE["Personas Routes"]:::routes
        end
        subgraph "Controllers"
            CASAR_CTRL["Casar Controller"]:::controller
            LOGIN_CTRL["Login Controller"]:::controller
            PERSONAS_CTRL["Personas Controller"]:::controller
        end
        DB_MOD["DB Module"]:::module
        CONFIG["Config File"]:::module
    end

    %% SQL Database
    SQL_DB["SQL Database"]:::database

    %% Main Connections
    FE -->|"API_call"| API
    API -->|"dispatches"| CASAR_ROUTE
    API -->|"dispatches"| LOGIN_ROUTE
    API -->|"dispatches"| PERSONAS_ROUTE

    CASAR_ROUTE -->|"calls"| CASAR_CTRL
    LOGIN_ROUTE -->|"calls"| LOGIN_CTRL
    PERSONAS_ROUTE -->|"calls"| PERSONAS_CTRL

    CASAR_CTRL -->|"queries"| DB_MOD
    LOGIN_CTRL -->|"queries"| DB_MOD
    PERSONAS_CTRL -->|"queries"| DB_MOD

    CONFIG -->|"configures"| DB_MOD

    DB_MOD -->|"CRUD_operations"| SQL_DB

    %% Click Events
    click FE "https://github.com/oscarpachecoh/wedding-app/tree/master/client/"
    click API "https://github.com/oscarpachecoh/wedding-app/tree/master/api/"
    click CASAR_CTRL "https://github.com/oscarpachecoh/wedding-app/blob/master/api/src/controllers/casarController.js"
    click LOGIN_CTRL "https://github.com/oscarpachecoh/wedding-app/blob/master/api/src/controllers/loginController.js"
    click PERSONAS_CTRL "https://github.com/oscarpachecoh/wedding-app/blob/master/api/src/controllers/personasController.js"
    click CASAR_ROUTE "https://github.com/oscarpachecoh/wedding-app/blob/master/api/src/routes/casar.routes.js"
    click LOGIN_ROUTE "https://github.com/oscarpachecoh/wedding-app/blob/master/api/src/routes/login.routes.js"
    click PERSONAS_ROUTE "https://github.com/oscarpachecoh/wedding-app/blob/master/api/src/routes/personas.routes.js"
    click DB_MOD "https://github.com/oscarpachecoh/wedding-app/blob/master/api/src/db.js"
    click CONFIG "https://github.com/oscarpachecoh/wedding-app/blob/master/api/src/config.js"
    click SQL_DB "https://github.com/oscarpachecoh/wedding-app/blob/master/bodas.sql"

    %% Styles
    classDef frontend fill:#C8E6C9,stroke:#4CAF50,stroke-width:2px;
    classDef backend fill:#BBDEFB,stroke:#2196F3,stroke-width:2px;
    classDef routes fill:#E1BEE7,stroke:#9C27B0,stroke-width:2px;
    classDef controller fill:#FFE0B2,stroke:#FF9800,stroke-width:2px;
    classDef module fill:#BBDEFB,stroke:#2196F3,stroke-width:2px;
    classDef database fill:#FFCDD2,stroke:#f44336,stroke-width:2px;
```
