Course: Databases II
Team Members: Daniel AlemΓ‘n, Luis Meza
EN | ES
Click the image to watch the explainer video. (Note: The video is in Spanish).
- Project Description
- Architecture
- Main Components
- Installation
- Build and Deployment
- Generating Synthetic Data
- ETL, Airflow and OLAP Layer
- Testing
- CI/CD Pipeline
- Interface Access
- Environment Reset
This project implements a complete restaurant management system with a microservices architecture. It allows managing restaurants, menus, products, reservations, and orders through a set of RESTful APIs.
The system is designed with high availability, scalability, and performance as priorities, using modern technologies such as load balancing, database sharding, distributed caching, and optimized searches. It also implements DAGs via Airflow to perform ETL and automatically reindex products in Elastic. Additionally, it includes functionality to visualize significant analytics data.
The project follows a microservices architecture with the following key components:
-
API Microservices:
- Main API for CRUD operations of restaurants, menus, products, reservations, and orders.
- Authentication service for user and JWT token management.
- Optimized search service with Elasticsearch.
- Indexing and routing operations service within a graph using Neo4J.
-
Load Balancing:
- Nginx as a reverse proxy and load balancer to distribute requests among instances.
-
Persistence:
- MongoDB: Main storage with sharding and replication for high availability.
- PostgreSQL: Configurable alternative storage.
- Elasticsearch: Search index for optimized queries.
- HiveDB: Storage as a Data Warehouse.
-
Cache:
- Redis as a distributed cache store to improve performance.
-
CI/CD:
- Automated pipeline for testing, building, and deployment.
π View Project Structure
proyecto2-bases2/
βββ airflow/ # Airflow service for automated DAGs
βββ analytics_service/ # Analytics dashboards service
βββ api/ # Main API
βββ auth_service/ # Authentication service
βββ drivers/ # Drivers required for Hive metadata
βββ etl_service/ # Specific purpose service for full ETL
βββ graph_service/ # Indexing and routing service with Neo4j
βββ pruebas/ # Testing and data generation scripts
βββ search_service/ # Search service
βββ spark_analytics/ # Basic query script with Spark and Hive
βββ docker-compose.yml # Container configuration
βββ hive_warehouse_init.sql # Warehouse initialization via HiveQL
βββ init_cluster.sh # Script to initialize MongoDB cluster
βββ init_hive_warehouse.sh # Script to initialize Hive
βββ init.sql # Initialization of Postgres tables for services
βββ set_config.sh # Script to configure the environment
βββ nginx.conf # Load balancer configuration
βββ README.md # Documentation
Each service follows an MVC (Model-Controller) structure with a clear separation of responsibilities:
servicio/
βββ src/
β βββ config/ # Configuration
β βββ controllers/ # Controllers
β βββ dao/ # Data Access Objects
β βββ db/ # Database connections
β βββ middlewares/ # Middlewares
β βββ models/ # Data models
β βββ routes/ # Route definitions
β βββ app.js # Main application
βββ swagger/ # API Documentation
βββ tests/ # Tests
β βββ integration/ # Integration tests
β βββ unit/ # Unit tests
β βββ utils/ # Test utilities
βββ server.js # Entry point
Handles all CRUD operations related to restaurants, menus, products, reservations, orders, and delivery drivers.
- RESTful implementation with Express.js and Swagger documentation.
- Horizontal scalability with multiple instances (
api1,api2).
Manages users, security, login, registration, roles, and JWT verification.
- JWT-based authentication and secure password hashing.
- High availability (
auth_service1,auth_service2).
Provides independent optimized search functionality.
- Free-text, category searches, and typo tolerance using Elasticsearch.
- Real-time updates and automatic indexing.
Resolves complex queries using graph structures (Neo4j).
- Calculation of optimal delivery routes and automatic delivery driver assignment.
- Co-purchase analysis and identification of influential users.
Extracts, transforms, and loads (ETL) data for OLAP analysis.
- Automated extraction from MongoDB/PostgreSQL with Python and processing with Apache Spark.
- Load into Apache Hive optimized for columnar storage.
Automates programmable workflows.
- ETL DAG executed every 6 hours to keep the Data Warehouse updated.
- Automatic reindexing DAG for Elasticsearch when catalog changes are detected.
Distributes traffic (round-robin) among backend service instances and manages API routes in a unified manner.
Implements the Cache-Aside pattern to alleviate database load and reduce response times.
- Docker and Docker Compose
- Git
- Node.js and npm (for local development)
git clone https://github.com/DanielAR27/proyecto2-bases2.git
cd proyecto2-bases2Module Installation (Local)
For each service that requires module installation (api, auth_service, search_service, graph_service), navigate to its folder and install:
cd <service_name>
npm install- Grant execution permissions to the scripts:
chmod +x set_config.sh init_cluster.sh init_hive_warehouse.sh- Execute the main script:
./set_config.shThis script starts the base services, initializes the MongoDB cluster (with sharding and replication), prepares the Hive warehouse, and starts the backend services.
If you want to populate the database with test data:
cd pruebas/
npm install
node generarDatosMasivos.js- Start the ETL service:
docker-compose --profile etl up --build -d- After the first execution, start Airflow (responsible for the periodic ETL):
docker-compose --profile airflow up --build -d- Start the analytics dashboard:
docker-compose --profile analytics up --build -dYou can view the dashboards at http://localhost:8501/ and check the metrics logs:
docker logs -f spark_analyticsThe project includes unit and integration tests using Jest. They evaluate CRUD flows, security, resilience, and cache behavior.
Testing Commands
Authentication:
docker-compose --profile test build auth_test
docker-compose --profile test run --rm auth_testSearch:
docker-compose --profile test build search_test
docker-compose --profile test run --rm search_testMain API:
docker-compose --profile test build api_test
docker-compose --profile test run --rm api_testGitHub Actions is used for Continuous Integration and Continuous Deployment (CI/CD):
- Test: Sets up the test infrastructure, runs microservices tests, and validates coverage.
- Build-and-Push: If tests are successful on main/master, it builds multi-architecture Docker images and pushes them to the GitHub Container Registry.
- Deploy: Generates an artifact with the Docker Compose configuration, scripts, and environment, preparing deployment documentation.
API Documentation (Swagger)
- Main API:
http://localhost/api/api-docs/ - Auth:
http://localhost/auth/api-docs/ - Search:
http://localhost/search/api-docs/ - Graphs:
http://localhost/graph/api-docs/
Databases & Monitoring
- PgAdmin (Postgres):
http://localhost:5050(Host:postgres_container, User:postgres, Pass:postgres) - Mongo Express:
http://localhost:8081(Check credentials in.env) - Kibana (Elasticsearch):
http://localhost:5601
To completely remove all containers, networks, and volumes:
docker-compose down -vLast update: 21/8/2026
