# rutbelcarlostc/cs-project-backend architecture

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

- Interactive diagram: https://gitdiagram.com/rutbelcarlostc/cs-project-backend
- Repository: https://github.com/rutbelcarlostc/cs-project-backend

## Overview

##### Project type and purpose
- This repository contains the server-side component of **MapMap**, an open-source public transit route mapping kit.
- According to the README, the server’s responsibilities are:
- Receiving georeferenced route data submitted by the Android mobile app
- Exposing RESTful endpoints for data retrieval
- Exporting route data as Shapefiles and CSV

##### File structure
- Top-level files:
- pom.xml, Maven wrapper, .mvn/ → Java 17+, Spring Boot 3, built with Maven
- scripts-bbdd/ → SQL scripts to seed/create the relational database
- Source code under src/main/java/org/codeandomexico/mapmap/server:
- controller/ → Spring MVC controllers (APIController, ExportController, MainController, UploadController)
- service/ → Business logic (UploadService, MainService, ExportService)
- repository/ → Spring Data JPA repositories (AgencyRepository, RouteRepository, TripPatternRepository, etc.)
- model/ → JPA @Entity classes (Agency, Route, Stop, TripPattern, etc.)
- util/ → Helpers (zip directories, polyline encoding, serializers)
- jpa/ → Hibernate naming strategy customization
- src/main/resources:
- application.properties → config (DB connection, ports, etc.)
- protobuffer/route.proto → definition for Protobuf messages submitted by mobile app
- public/ → static web assets (HTML templates, Mustache views, Bootstrap CSS/JS, Backbone, Leaflet, jQuery, Handlebars)
- templates/ → Mustache templates for server-side view rendering
- src/test/ → unit/integration tests for the Spring Boot application

##### README for additional insights
- Technology stack: Java 17+, Spring Boot 3, Maven, JPA/Hibernate
- Frontend uses server-rendered Mustache plus client-side Backbone.js, Leaflet.js, and related JS/CSS libraries
- Mobile app communicates via Protobuf messages over HTTP to the server’s upload endpoint

##### Detail
- Four controllers and their respective service flows
- Protobuf module as a dedicated component
- Where JPA entities map to database tables (scripts-bbdd)
- Two user-facing flows: data collection (upload) and data visualization/export

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Clients
    Android["Android Mobile Client"]:::external
    Browser["Web Browser"]:::external

    %% Spring Boot Application Container
    subgraph "Spring Boot Application"
        direction TB

        %% Controllers
        subgraph "Controllers"
            direction TB
            UploadController["UploadController"]:::controller
            APIController["APIController"]:::controller
            MainController["MainController"]:::controller
            ExportController["ExportController"]:::controller
        end

        %% Services
        subgraph "Services"
            direction TB
            UploadService["UploadService"]:::service
            MainService["MainService"]:::service
            ExportService["ExportService"]:::service
        end

        %% Repositories
        subgraph "Repositories"
            direction TB
            AgencyRepository["AgencyRepository"]:::repository
            RouteRepository["RouteRepository"]:::repository
            TripPatternRepository["TripPatternRepository"]:::repository
            PhoneRepository["PhoneRepository"]:::repository
        end

        %% Models
        subgraph "JPA Entities"
            direction TB
            Agency["Agency"]:::model
            Route["Route"]:::model
            Stop["Stop"]:::model
            TripPattern["TripPattern"]:::model
        end

        %% Utilities
        subgraph "Utilities"
            direction TB
            DirectoryZip["DirectoryZip"]:::util
            PolylineEncoder["PolylineEncoder"]:::util
        end

        %% Protobuf
        subgraph "Protobuf"
            direction TB
            RouteProto["route.proto"]:::protobuf
            TransitProtos["TransitWandProtos"]:::protobuf
        end

        %% Static Assets & Templates
        subgraph "Static Resources"
            direction TB
            StaticAssets["Static Assets"]:::static
            Templates["Mustache Templates"]:::static
        end

        %% Configuration
        Config["application.properties"]:::config
    end

    %% Data Stores
    Database["Relational Database"]:::datastore
    ScriptsSQL["DB Scripts"]:::datastore

    %% Flows
    Android -->|"POST Protobuf"| UploadController
    UploadController -->|"handleUpload()"| UploadService
    UploadService -->|"saveEntities()"| AgencyRepository
    AgencyRepository --> Database

    Browser -->|"GET /"| MainController
    MainController --> Templates
    MainController --> StaticAssets
    Browser -->|"JS API calls"| APIController
    APIController -->|"fetchData()"| MainService
    MainService --> RouteRepository
    RouteRepository --> Database

    Browser -->|"GET /export"| ExportController
    ExportController -->|"generateExport()"| ExportService
    ExportService --> DirectoryZip
    ExportService --> PolylineEncoder

    UploadController --> RouteProto
    UploadController --> TransitProtos

    Config --> UploadController
    Config --> APIController
    Config --> MainController
    Config --> ExportController
    Config --> Database

    ScriptsSQL --> Database

    %% Click Events
    click MapMapServerApplication "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/MapMapServerApplication.java"
    click UploadController "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/controller/UploadController.java"
    click APIController "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/controller/APIController.java"
    click MainController "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/controller/MainController.java"
    click ExportController "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/controller/ExportController.java"
    click UploadService "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/service/UploadService.java"
    click MainService "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/service/MainService.java"
    click ExportService "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/service/ExportService.java"
    click AgencyRepository "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/repository/AgencyRepository.java"
    click RouteRepository "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/repository/RouteRepository.java"
    click TripPatternRepository "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/repository/TripPatternRepository.java"
    click PhoneRepository "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/repository/PhoneRepository.java"
    click Agency "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/model/Agency.java"
    click Route "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/model/Route.java"
    click Stop "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/model/Stop.java"
    click TripPattern "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/model/TripPattern.java"
    click DirectoryZip "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/util/DirectoryZip.java"
    click PolylineEncoder "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/org/codeandomexico/mapmap/server/util/PolylineEncoder.java"
    click RouteProto "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/resources/protobuffer/route.proto"
    click TransitProtos "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/java/com/conveyal/transitwand/TransitWandProtos.java"
    click StaticAssets "https://github.com/rutbelcarlostc/cs-project-backend/tree/main/src/main/resources/public"
    click Templates "https://github.com/rutbelcarlostc/cs-project-backend/tree/main/src/main/resources/templates"
    click Config "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/src/main/resources/application.properties"
    click ScriptsSQL "https://github.com/rutbelcarlostc/cs-project-backend/blob/main/scripts-bbdd/schema.sql"

    %% Styles
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef controller fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef service fill:#87CEFA,stroke:#333,stroke-width:1px
    classDef repository fill:#6495ED,stroke:#333,stroke-width:1px
    classDef model fill:#1E90FF,stroke:#333,stroke-width:1px
    classDef util fill:#00CED1,stroke:#333,stroke-width:1px
    classDef protobuf fill:#98FB98,stroke:#333,stroke-width:1px
    classDef static fill:#FFD700,stroke:#333,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef datastore fill:#32CD32,stroke:#333,stroke-width:1px
```
