# alejandrosopa/codebuddy architecture

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

- Interactive diagram: https://gitdiagram.com/alejandrosopa/codebuddy
- Repository: https://github.com/alejandrosopa/codebuddy

## Overview

##### Main Components
- Frontend:
- Located in the “frontend” directory, it’s built with React (files in .jsx, .css, and a vite.config.js indicate a modern Vite setup).
- Contains multiple UI components (e.g., IniciarSesion, CrearCuenta, PerfilUsuario, etc.) implying various user-facing screens and functionalities such as login, account creation, error handling, and project viewing/creation.
- Uses an external authentication mechanism with Google OAuth (as defined in the frontend .env).

- Backend:
- Found in the “backend” folder, with clear subdirectories for controllers, models, routes, and utils.
- The file “app.js” is the entry point for the server, while the “controllers” and “routes” directories indicate an MVC-like structure.
- The “models/mysql” folder implies that the application communicates with a MySQL database and handles data logic.

- Database:
- The “dataBase” folder includes SQL files (such as codebuddy.sql, dataBase.sql, inserts.sql, and a schema file) that define the database structure and initial data.
- The README outlines steps to create and import the database, underlining the importance of the MySQL service.

- External Services / Infrastructure:
- Email service: The backend’s .env configuration includes credentials for sending emails.
- Google Cloud OAuth: Present on the frontend .env for enabling Google-based authentication.

##### Relationships and Interactions
- The Frontend communicates with the Backend via API calls (most likely RESTful endpoints defined in backend/routes/routes.js).
- The Backend handles business logic (via controllers and utils) and data manipulation using models that connect to the MySQL Database.
- The Database is central to storing user information, project data, and other persistent data.
- External services like Google OAuth (for authentication) and possibly an email service are integrated via environment configurations and utility modules.

##### Architectural Patterns and Design Principles
- Modular Design: Separation of the project into “frontend”, “backend”, and “dataBase” directories.
- MVC Pattern in the Backend: Organized controllers, models, and routes help define a clear separation of business logic, data access, and request routing.
- API-Driven Development: The frontend’s communication with the backend is likely through well-defined API endpoints.
- Use of Environment Variables for Configuration: Both backend and frontend rely on .env files, which enhance security and configuration management.

##### Relevant Technologies and Frameworks
- Backend: Likely built on Node.js and Express (or similar framework) given the file structure and language used (JavaScript).
- Frontend: Developed with React and bundled with Vite, implying fast development and hot module reloading.
- Database: MySQL is the chosen database technology.
- Additional Libraries: Various React components, eslint for code quality (frontend/.eslintrc.cjs), and NPM as the package manager.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend"
        FE["Frontend Application"]:::frontend
        FS["IniciarSesion (Login)"]:::frontend
        FC["CrearCuenta (Account Creation)"]:::frontend
        FP["PerfilUsuario (User Profile)"]:::frontend
        AP["AllProyectos (View Projects)"]:::frontend
        CP["CrearProyecto (Create Project)"]:::frontend
        AUI["Additional UI Components"]:::frontend
        VITE["Vite Config"]:::frontend
        PUB["Static Assets"]:::frontend
    end

    subgraph "Backend"
        BE["Backend Application"]:::backend
        CT["Controllers"]:::backend
        RT["Routes"]:::backend
        MD["Models"]:::backend
        UT["Utilities"]:::backend
    end

    subgraph "Database"
        DB_MAIN["MySQL Database"]:::database
        DB1["codebuddy.sql"]:::database
        DB2["dataBase.sql"]:::database
        DB3["inserts.sql"]:::database
        DB4["schema.mwb"]:::database
    end

    subgraph "External Services"
        OAuth["Google OAuth"]:::external
        Email["Email Service"]:::external
    end

    %% Connections
    FE -->|"APICalls"| BE
    BE --> CT
    BE --> RT
    BE --> MD
    BE --> UT
    MD -->|"queries"| DB_MAIN
    DB_MAIN -->|"contains"| DB1
    DB_MAIN -->|"contains"| DB2
    DB_MAIN -->|"contains"| DB3
    DB_MAIN -->|"contains"| DB4
    BE -.->|"integration"| OAuth
    BE -.->|"integration"| Email

    %% Click Events
    click FE "https://github.com/alejandrosopa/codebuddy/tree/pro/frontend"
    click FS "https://github.com/alejandrosopa/codebuddy/blob/pro/frontend/src/components/IniciarSesion/IniciarSesion.jsx"
    click FC "https://github.com/alejandrosopa/codebuddy/blob/pro/frontend/src/components/CrearCuenta/CrearCuenta.jsx"
    click FP "https://github.com/alejandrosopa/codebuddy/blob/pro/frontend/src/components/PerfilUsuario/PerfilUsuario.jsx"
    click AP "https://github.com/alejandrosopa/codebuddy/blob/pro/frontend/src/components/AllProyectos/AllProyectos.jsx"
    click CP "https://github.com/alejandrosopa/codebuddy/blob/pro/frontend/src/components/CrearProyecto/CrearProyecto.jsx"
    click AUI "https://github.com/alejandrosopa/codebuddy/tree/pro/frontend/src/components"
    click VITE "https://github.com/alejandrosopa/codebuddy/blob/pro/frontend/vite.config.js"
    click PUB "https://github.com/alejandrosopa/codebuddy/tree/pro/frontend/public"
    click BE "https://github.com/alejandrosopa/codebuddy/blob/pro/backend/app.js"
    click CT "https://github.com/alejandrosopa/codebuddy/blob/pro/backend/controllers/controller.js"
    click RT "https://github.com/alejandrosopa/codebuddy/blob/pro/backend/routes/routes.js"
    click MD "https://github.com/alejandrosopa/codebuddy/blob/pro/backend/models/mysql/model.js"
    click UT "https://github.com/alejandrosopa/codebuddy/blob/pro/backend/utils/utils.js"
    click DB1 "https://github.com/alejandrosopa/codebuddy/blob/pro/dataBase/codebuddy.sql"
    click DB2 "https://github.com/alejandrosopa/codebuddy/blob/pro/dataBase/dataBase.sql"
    click DB3 "https://github.com/alejandrosopa/codebuddy/blob/pro/dataBase/inserts.sql"
    click DB4 "https://github.com/alejandrosopa/codebuddy/blob/pro/dataBase/schema.mwb"

    %% Styles
    classDef frontend fill:#AED6F1,stroke:#2980B9,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#F1C40F,stroke-width:2px;
    classDef database fill:#A9DFBF,stroke:#28B463,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#E74C3C,stroke-width:2px;
```
