How dromara/lamp-cloud works
Project type and purpose
• This is a full‐stack, multi‐module Java17/SpringCloudAlibaba rapid development platform (“lamp-cloud”), organized as a monorepo. It combines microservices (API gateway, OAuth, system, base, generator, support services) with shared libraries (lamp-public, lamp-base, lamp-support) and a separate front-end ecosystem (Vue3).
• Purpose: Provide a SaaS-capable, RBAC-enabled, multi-tenant back-end scaffolding with code generation, file storage, messaging, distributed transactions, resilience, and monitoring built in.
Top-level structure and architectural patterns
• Libraries:
• lamp-public: common utilities, annotation/aspect, cache, data-scope SDK, file/message SDK, Sa-token extensions
• lamp-base: core multi-tenant/user/role/file/message services and server application
• lamp-support: supporting services (boot server template, job executor, monitor server)
• Microservices:
• lamp-gateway: API gateway (routing, filters, auth via Sa-token), Dockerized
• lamp-oauth: OAuth2 authorization server
• lamp-system: system management (tenant, dict, parameter, login logs, server info)
• lamp-generator: code generation service (metadata DB, Freemarker templates)
• lamp-base-server: combined “base” back-end application if running monolith
• Patterns:
• Layered MVC (entity → mapper → manager/biz → service → controller)
• Facade modules (lamp-*-facade) for inter-service API with Feign + fallbacks
• Strategy pattern (file storage, message sending)
• Microservices with service registry/discovery (Nacos), config center (Nacos), circuit breaker (Sentinel), distributed transaction (Seata), messaging (RabbitMQ).
External systems and middleware
• Service registry & config: Nacos
• Databases: MySQL (multi-tenant isolation), optional Dameng/Oracle/SQLServer
• Cache: Redis
• Message broker: RabbitMQ
• File storage: FastDFS, MinIO, Aliyun, Huawei, Qiniu, or local
• Monitoring/tracing: SkyWalking, Prometheus/Grafana (via lamp-monitor)
• CI/CD: Jenkinsfiles, Dockerfiles, shell scripts
Main components and interactions
a. API Gateway (lamp-gateway)
• Exposes single entry point for clients
• Performs authentication/authorization via Sa-token
• Routes requests to microservices over HTTP/REST/Feign
b. OAuth Service (lamp-oauth)
• Manages tokens, user authentication, event listeners for login/logout
c. Core Services
• Base Service (lamp-base-server): user/org/role management, file upload/download, internal messaging
• System Service (lamp-system-server): tenant application management, dict/param, area, client, login log, server info
• Generator Service (lamp-generator-server): persists table metadata, generates code templates via Freemarker
d. Support Services
• Monitor Service (lamp-support/lamp-monitor): dashboards, security config
• Job Executor (lamp-support/lamp-job-executor): runs distributed scheduled tasks via XXL-Job
• Boot Server template (lamp-support/lamp-boot-server): sample monolithic server with pre-wired configs
e. Shared Libraries (lamp-public, lamp-base, lamp-support libs)
• Packaged and published as Maven artifacts or loaded via classpath
f. Infrastructure
• Nacos cluster (service registry + config)
• MySQL cluster (one DB per tenant or shared with tenant_id filter)
• Redis cluster (caching, token store)
• RabbitMQ (event bus for messaging, glue events, notifications)
• File storage backends (via strategy implementations)
• SkyWalking & Prometheus/Grafana for tracing & metrics
Architectural patterns & design principles
• High cohesion, low coupling: monorepo of self-contained modules
• Microservices: each server runs independently, registers in Nacos
• Layered design and separation of concerns in each module
• Facade and API modules to decouple business implementations from API contracts
• Strategy pattern for pluggable file storage and messaging
• Spring Cloud features: discovery, config, circuit breaker, load-balancing, distributed transactions
Essential elements
• Arrowheads to show request/response or publish/subscribe direction
• Brief callouts for design patterns (“Strategy” on file storage, “Facade” on inter-service APIs)