Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

67 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

OpenMeal Monorepo

Java Spring Boot Docker Status

โš ๏ธ Project Status: This repository is under active development. The documentation describes the target architecture for the complete system. See Implementation Status below for current progress.

OpenMeal is a server-side platform for food ordering and delivery from restaurants and cafes, uniting all process participants: customers, establishments, couriers, support service, and administrators.

Platform Capabilities

The platform implements complete food delivery workflow:

  • Customer Experience: Browse restaurants, order food, track courier in real-time, receive notifications
  • Restaurant Management: Menu management, order processing, preparation status updates
  • Courier Coordination: Automated courier assignment algorithm based on proximity and availability
  • Support Operations: Incident handling, refunds, account management with escalation workflows
  • Administration: Restaurant verification, permanent account actions, operational analytics

The platform is designed as a backend-ready system with API-first architecture, prepared for frontend integration.

๐Ÿš€ Quick Start

Prerequisites:

  • Docker & Docker Compose (v2.0+)
  • Java 21+
  • Make
  • yq (for local development with microservices.local)

First Time Setup:

# 1. Initialize configuration files
make init

# 2. Configure environment
cp .env.infra.example .env.infra
nano .env.infra

Edit .env.infra:

  • Set ENVIRONMENT=local-dev
  • Configure passwords for databases
  • See config/ directory documentation below
# 3. Install pre-commit hooks (recommended)
pipx install pre-commit
pre-commit install --hook-type pre-commit --hook-type commit-msg

# 4. Start infrastructure and services
make up

Verify Everything Works

# Check health of all services
make check-services

# View logs
make logs

Access Points:

๐ŸŒ Environment Strategy

The project supports 4 deployment environments with different service activation:

Environment Profile Active Services Use Case
local-dev local-dev Postgres, MongoDB, Redis, MinIO Developer laptop (minimal resources)
shared-dev shared-dev + Keycloak, Redpanda, Nginx Shared development VDS
stage stage Full stack (no MinIO) Pre-production testing
prod prod Full + Prometheus/Grafana Production deployment

Environment is controlled by ENVIRONMENT variable in .env.infra.

๐ŸŽฏ Implementation Status

Infrastructure & DevOps:

  • โœ… Docker Compose orchestration with multi-environment support
  • โœ… Ansible deployment automation (staging/production)
  • โœ… GitHub Actions CI/CD pipeline
  • โœ… Secrets management (Ansible Vault + GitHub Secrets)
  • โœ… SSL/TLS automation (Let's Encrypt)
  • โœ… Monitoring stack (Prometheus + Grafana)

Microservices (Target: 13 services):

  • ๐Ÿšง API Gateway - Routing, authentication, rate limiting (In Progress)
  • ๐Ÿšง User Service - User profiles, addresses, preferences (In Progress)
  • ๐Ÿšง Auth Service - Authentication, JWT tokens (In Progress)
  • โณ Restaurant Service - Menus, schedules, reviews (Planned)
  • โณ Order Service - Order lifecycle, status management (Planned)
  • โณ Payment Service - ะฎKassa integration, refunds (Planned)
  • โณ Dispatch Service - Courier assignment algorithm (Planned)
  • โณ Tracking Service - Real-time location tracking (Planned)
  • โณ File Service - File upload, S3 storage (Planned)
  • โณ External Sender - Push/SMS/Email notifications (Planned)
  • โณ Support Service - Incident handling, escalation (Planned)
  • โณ Admin Service - Verification, analytics (Planned)
  • โณ Report Service - Data aggregation, dashboards (Planned)

Note: Documentation reflects the complete target architecture. Features marked as "Planned" are designed but not yet implemented.

๐Ÿ“‚ Repository Structure

.
โ”œโ”€โ”€ services/
โ”‚   โ””โ”€โ”€ [microservice-name]/
โ”œโ”€โ”€ infrastructure/
โ”‚   โ”œโ”€โ”€ ansible/
โ”‚   โ””โ”€โ”€ keycloak/
โ”œโ”€โ”€ compose/
โ”‚   โ”œโ”€โ”€ infra.yml
โ”‚   โ””โ”€โ”€ monitoring.yml
โ”œโ”€โ”€ config/
โ”‚   โ”œโ”€โ”€ postgres/
โ”‚   โ”œโ”€โ”€ mongodb/
โ”‚   โ”œโ”€โ”€ redpanda/
โ”‚   โ””โ”€โ”€ nginx/
โ”œโ”€โ”€ scripts/
โ”œโ”€โ”€ makefiles/
โ””โ”€โ”€ docs/

Key directories:

  • services/ - Spring Boot microservices (domain-driven modules)
  • infrastructure/ - Ansible playbooks, roles, and Keycloak customization
  • compose/ - Docker Compose files for infrastructure and monitoring
  • config/ - Initialization scripts and templates for databases, Redpanda, Nginx
  • scripts/ - Utility scripts for health checks, backups, SSL management
  • makefiles/ - Modular Makefile includes for different concerns
  • docs/ - Architecture documentation and ADRs

โš™๏ธ Configuration Management

The config/ Directory

This directory contains initialization scripts and configuration templates for infrastructure services. It solves the problem of environment-aware service initialization and secrets injection.

Structure:

config/
โ”œโ”€โ”€ postgres/
โ”‚   โ”œโ”€โ”€ init-db.sh
โ”‚   โ”œโ”€โ”€ init-users.conf
โ”‚   โ”œโ”€โ”€ init-users.conf.example
โ”‚   โ””โ”€โ”€ check-and-init.sh
โ”œโ”€โ”€ mongodb/
โ”‚   โ”œโ”€โ”€ init-db.sh
โ”‚   โ”œโ”€โ”€ init-users.conf
โ”‚   โ””โ”€โ”€ init-users.conf.example
โ”œโ”€โ”€ redpanda/
โ”‚   โ”œโ”€โ”€ redpanda.yaml.template
โ”‚   โ”œโ”€โ”€ generate-config.sh
โ”‚   โ””โ”€โ”€ bootstrap-user.sh
โ”œโ”€โ”€ nginx/
โ”‚   โ”œโ”€โ”€ default.conf.template
โ”‚   โ””โ”€โ”€ default-http-only.conf.template
โ””โ”€โ”€ minio/
    โ”œโ”€โ”€ init-buckets.sh
    โ””โ”€โ”€ init-users.conf.example

How it works:

  1. Template files (.example, .template) are committed to Git
  2. Actual config files (.conf, .yaml) are gitignored and generated locally or by Ansible
  3. Init scripts read config files and create database users, buckets, etc.
  4. Environment variables from .env.infra are resolved at runtime

Example: PostgreSQL User Initialization

config/postgres/init-users.conf:

keycloak:KEYCLOAK_DB_PASSWORD:keycloak
user_service:USER_SERVICE_DB_PASSWORD:users
order_service:ORDER_SERVICE_DB_PASSWORD:orders

Format: username:ENV_VAR_NAME:database

The init-db.sh script:

  • Reads this file
  • Resolves $KEYCLOAK_DB_PASSWORD from environment
  • Creates user and database if they don't exist
  • Grants necessary privileges

Environment-Aware Activation:

The scripts/prepare-db-configs.sh script modifies init-users.conf based on ENVIRONMENT:

  • local-dev - Comments out Keycloak (uses shared-dev instance)
  • shared-dev - Only Keycloak active
  • stage/prod - All users active

This prevents resource waste and ensures proper service isolation.

Secrets Management Strategy

Local Development:

  1. Copy example files:

    make init
  2. Edit .env.infra:

    POSTGRES_PASSWORD=local_dev_password
    REDIS_PASSWORD=local_dev_redis
    KEYCLOAK_DB_PASSWORD=local_kc_password
  3. Edit config/postgres/init-users.conf:

    user_service:USER_SERVICE_DB_PASSWORD:users
    
  4. Add to .env.infra:

    USER_SERVICE_DB_PASSWORD=user_svc_password

Production Deployment:

GitHub Secrets โ†’ generate-vault.py โ†’ vault.yml โ†’ Ansible โ†’ .env.infra on server

See infrastructure/README.md for details.

Local Development with Selective Services

Problem: Running all microservices locally consumes too much RAM.

Solution: microservices.local file for selective activation.

  1. Copy example:

    cp microservices.local.example microservices.local
  2. Uncomment services you want to run:

    user-service
    order-service
    
  3. Generate local compose file:

    make init-local

    This creates compose/docker-compose.local.yml that builds images from source.

  4. Start only selected services:

    make up

How it works:

  • makefiles/local-dev.mk reads microservices.local
  • Uses yq to filter services from docker-compose.yml
  • Generates compose/docker-compose.local.yml with build: instead of image:
  • makefiles/docker.mk includes this file when ENVIRONMENT=local-dev

This allows developers to run only the services they're working on, while infrastructure (Postgres, Redis, etc.) always runs.

๐Ÿ›  Common Commands

Essential commands:

# Start all services
make up
# Stop all services
make down
# View logs
make logs
# Build Maven projects
make build
# Health check
make check-services

Service-specific operations:

make up SERVICES=user-service
make restart SERVICES="order-service payment-service"
make logs SERVICES=payment-service

For complete command reference including database operations, SSL management, backups, and advanced options, see docs/MAKEFILE.md.

๐Ÿ“– Documentation

๐Ÿ— Technology Stack

Backend:

  • Java 21, Spring Boot 4.0.3, Spring Cloud 2025.1.1
  • Maven (multi-module monorepo)

Infrastructure:

  • PostgreSQL, MongoDB, Redis
  • Redpanda (Kafka-compatible event streaming)
  • Keycloak (Identity & Access Management)
  • MinIO (S3-compatible storage, local-dev only)
  • Nginx (Reverse proxy with SSL)

DevOps:

  • Docker Compose
  • Ansible (deployment automation)
  • GitHub Actions (CI/CD)
  • Prometheus + Grafana (monitoring, prod only)

Why Docker Compose over Kubernetes?

Docker Compose chosen to minimize operational overhead and focus on application architecture. Managing Kubernetes clusters (etcd, control plane, CNI, ingress controllers) would shift focus from building microservices to infrastructure administration. For this project scope, Docker Compose provides sufficient container management without the complexity of cluster orchestration. See ADR-003 for detailed rationale.

๐Ÿ” Security & Secrets

Local Development:

  • Secrets in .env.infra (gitignored)
  • Database credentials in config/*/init-users.conf (gitignored)

Production:

  • GitHub Secrets โ†’ Ansible Vault โ†’ .env files
  • SSL certificates via Let's Encrypt (automatic renewal)
  • SASL/SCRAM authentication for Redpanda

See infrastructure/README.md for details.

๐Ÿงช Testing

# Run all tests
make test

# Test specific service
./mvnw -pl services/user-service test

# Ansible role testing (Molecule)
make test-ansible

๐Ÿ“ฆ Adding a New Microservice

  1. Create services/your-service/ with Spring Boot structure
  2. Add module to root pom.xml
  3. Create services/your-service/Dockerfile
  4. Add service to docker-compose.yml
  5. Create .env.your-service.example
  6. CI/CD workflows auto-detect changes and build new service

See existing services in services/ directory for reference implementation examples.

๐Ÿšจ Troubleshooting

Services won't start:

make check-services
make logs SERVICE=user-service

Database connection issues:

make exec-postgres

Inside PostgreSQL shell, list databases with \l command.

Port conflicts:

make down
make clean
make up

๐Ÿ“„ License

See LICENSE file for details.


Need help? Check docs/ARCHITECTURE.md for system overview or docs/MAKEFILE.md for command reference.

About

A microservice backend for a food delivery platform, built with Java Spring Boot. OpenMeal connects customers, restaurants, and couriers. The project comes with a production-ready DevOps infrastructure (IaC via Docker, Ansible) enabling rapid deployment across dev, stage, and prod environments.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages