# cristhian036/proyecto-herramientas-desarrollo architecture

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

- Interactive diagram: https://gitdiagram.com/cristhian036/proyecto-herramientas-desarrollo
- Repository: https://github.com/cristhian036/proyecto-herramientas-desarrollo

## Overview

##### Project Type and Purpose
- This is a full-stack web application (“Plataforma de Gestión y Difusión de la Municipalidad”) comprised of:
- A Spring Boot/JVM-based backend (sistema_municipal_backend)
- An Angular frontend (sistema_municipal_frontend)
- A relational database defined by bd.sql (base_datos_sistema_municipal)
- It provides citizen communication, transparency portals, participation forums with JWT-based authentication, role management, and notifications.

##### File Structure Overview
- Top-level directories:
- base_datos_sistema_municipal – SQL schema/data
- sistema_municipal_backend – Spring Boot service
- sistema_municipal_frontend – Angular SPA
- Backend layers (com.utp.sistema_municipal_backend):
- configuraciones – JWT, security filters/config
- controladores – REST controllers for auth & user/forum endpoints
- modelo – domain objects (Usuario, Rol, JwtRequest/Response)
- repositorios – Spring Data JPA interfaces
- servicios + impl – business logic & UserDetailsService
- Frontend modules (src/app):
- pages – home, login, signup, admin dashboard, user dashboard
- components – shared navbar
- services – HTTP clients (login.service, user.service), guards, interceptor
- environments – API URL settings

##### Key Insights from README
- Emphasis on user-generated forums, moderated discussion, notifications
- JWT authentication for registered users
- Clear separation between public info (news, alerts) and private forum area

##### Main Components
a. Frontend (Angular SPA)
- UI Components (pages, navbar)
- Angular Router & Guards (AdminGuard, NormalGuard)
- HTTP Interceptor (attaches JWT)
b. Backend (Spring Boot REST API)
- Security Layer (JwtAuthenticationFilter, JwtUtils, AuthenticationEntryPoint)
- Controllers (AuthenticationController, UsuarioController)
- Service Layer (UsuarioService, UserDetailsServiceImpl)
- Repository Layer (UsuarioRepository, RolRepository)
c. Database (SQL)
- Tables: users, roles, user_roles, forums, posts, notifications
– Defined in bd.sql
d. External/Infrastructure
- (Optional) Email/Notification Service
- Build tools: Gradle, npm
- Deployment env: Tomcat/embedded, Node

##### Relationships and Data Flows
- User → Frontend (login, navigate)
- Frontend → Backend (HTTP/JSON over REST):
- /auth/login, /auth/signup
- /users/** (profile, forums)
- /forums/** (create, post, fetch)
- Backend → Database (JPA/Hibernate): CRUD on entities
- JWT flows: user logs in → receives token → HTTP Interceptor adds token to subsequent calls → SecurityFilter validates token → grants access

##### Architectural Patterns & Principles
- Layered (Controller → Service → Repository)
- Stateless REST + JWT for authentication/authorization
- Angular modularity (feature modules, shared components)
- Dependency Injection throughout (Spring & Angular)

##### Technologies & Frameworks
- Frontend: Angular, TypeScript, RxJS, Angular Router, HTTPClient
- Backend: Spring Boot, Spring Security, Spring Data JPA, JWT, Gradle
- Database: MySQL/PostgreSQL (schema in bd.sql)
- Tools: Git, Maven wrapper/Gradle wrapper, npm, Karma/Jasmine tests

##### Final Recommendations
- Every layer—don’t just show “Backend,” break it into Security, Controllers, Services, Repos
- Keep labels concise but precise; include method names for key interactions if space allows
- Iterate: review with the team to ensure no component is missing or misrepresented

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Layer
    subgraph "Angular App"
        direction TB
        Pages["Pages (Home, Login, Signup, Dashboards)"]:::frontend
        Navbar["Navbar Component"]:::frontend
        Router["Angular Router"]:::frontend
        Guards["AdminGuard & NormalGuard"]:::frontend
        Interceptor["Auth Interceptor"]:::frontend
        ServicesFE["Login & User Services"]:::frontend
    end

    %% Backend Layer
    subgraph "Spring Boot App"
        direction TB
        AppEntry["SistemaMunicipalBackendApplication"]:::backend
        subgraph "Security Layer"
            direction TB
            JwtUtils["JwtUtils"]:::backend
            JwtFilter["JwtAuthenticationFilter"]:::backend
            JwtEntry["JwtAuthenticationEntryPoint"]:::backend
            SecConfig["MySecurityConfig"]:::backend
        end
        subgraph "Controllers"
            direction TB
            AuthCtrl["AuthenticationController"]:::backend
            UserCtrl["UsuarioController"]:::backend
        end
        subgraph "Service Layer"
            direction TB
            UserSvc["UsuarioService"]:::backend
            UserDetailsImpl["UserDetailsServiceImpl"]:::backend
            UserSvcImpl["UsuarioServiceImpl"]:::backend
        end
        subgraph "Repository Layer"
            direction TB
            UserRepo["UsuarioRepository"]:::backend
            RoleRepo["RolRepository"]:::backend
        end
        subgraph "Domain Models"
            direction TB
            Usuario["Usuario"]:::backend
            Rol["Rol"]:::backend
            Authority["Authority"]:::backend
            UsuarioRol["UsuarioRol"]:::backend
            JwtReq["JwtRequest"]:::backend
            JwtRes["JwtResponse"]:::backend
        end
    end

    %% Database
    Database[(Database)]:::database

    %% External Tools
    subgraph "Tools & Deployment"
        direction TB
        Gradle["Gradle Build"]:::external
        Npm["npm & package.json"]:::external
    end

    %% Flows
    User["User"] -->|uses| Pages
    Pages -->|renders| Navbar
    Pages -->|navigates via| Router
    Router -->|checks| Guards
    Pages -->|HTTP calls| Interceptor
    Interceptor -->|attaches JWT| AuthCtrl
    Interceptor -->|attaches JWT| UserCtrl

    SecConfig -->|configures| JwtFilter
    SecConfig -->|configures| JwtEntry
    JwtFilter -->|validates token via| JwtUtils

    AuthCtrl -->|delegates| UserDetailsImpl
    AuthCtrl -->|calls| AuthCtrl
    AuthCtrl -->|uses| JwtUtils

    UserCtrl -->|invokes| UserSvc
    UserSvc -->|implemented by| UserSvcImpl
    UserSvcImpl -->|uses| UserRepo
    UserSvcImpl -->|uses| RoleRepo

    UserRepo -->|CRUD| Database
    RoleRepo -->|CRUD| Database

    AppEntry -->|bootstraps| SecConfig
    AppEntry -->|bootstraps| AuthCtrl
    AppEntry -->|bootstraps| UserCtrl

    %% Click Events - Frontend
    click Pages "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/src/app/pages/home/home.component.ts"
    click Navbar "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/src/app/components/navbar/navbar.component.ts"
    click Router "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/src/app/app-routing.module.ts"
    click Guards "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/src/app/services/admin.guard.ts"
    click Interceptor "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/src/app/services/auth.interceptor.ts"
    click ServicesFE "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/src/app/services/login.service.ts"
    click ServicesFE "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/src/app/services/user.service.ts"

    %% Click Events - Backend
    click Database "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/base_datos_sistema_municipal/bd.sql"
    click AppEntry "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/SistemaMunicipalBackendApplication.java"
    click JwtUtils "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/configuraciones/JwtUtils.java"
    click JwtFilter "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/configuraciones/JwtAuthenticationFilter.java"
    click JwtEntry "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/configuraciones/JwtAuthenticationEntryPoint.java"
    click SecConfig "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/configuraciones/MySecurityConfig.java"
    click AuthCtrl "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/controladores/AuthenticationController.java"
    click UserCtrl "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/controladores/UsuarioController.java"
    click Usuario "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/modelo/Usuario.java"
    click Rol "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/modelo/Rol.java"
    click Authority "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/modelo/Authority.java"
    click UsuarioRol "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/modelo/UsuarioRol.java"
    click JwtReq "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/modelo/JwtRequest.java"
    click JwtRes "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/modelo/JwtResponse.java"
    click UserRepo "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/repositorios/UsuarioRepository.java"
    click RoleRepo "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/repositorios/RolRepository.java"
    click UserSvc "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/servicios/UsuarioService.java"
    click UserDetailsImpl "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/servicios/impl/UserDetailsServiceImpl.java"
    click UserSvcImpl "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/src/main/java/com/utp/sistema_municipal_backend/servicios/impl/UsuarioServiceImpl.java"
    click Gradle "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_backend/build.gradle"
    click Npm "https://github.com/cristhian036/proyecto-herramientas-desarrollo/blob/main/sistema_municipal_frontend/package.json"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#004085,color:#004085
    classDef backend fill:#d4edda,stroke:#155724,color:#155724
    classDef database fill:#fff3cd,stroke:#856404,color:#856404
    classDef external fill:#f8d7da,stroke:#721c24,color:#721c24,stroke-dasharray: 5 5
```
