|  | 
|  | 1 | +# Course Management System | 
|  | 2 | + | 
|  | 3 | + | 
|  | 4 | +This section describes the C4 model for the Course Management System, a Spring Boot microservices application with Course, Review, and CourseComposite services, deployed using Docker Compose and Kubernetes. | 
|  | 5 | + | 
|  | 6 | +### Level 1: System Context Diagram | 
|  | 7 | +**Description**: High-level view of the system and its external actors. | 
|  | 8 | + | 
|  | 9 | +- **System**: Course Management System | 
|  | 10 | + - A microservices-based application for managing courses and reviews. | 
|  | 11 | +- **Actors**: | 
|  | 12 | + - **User**: Browses courses and submits reviews (via browser/API). | 
|  | 13 | + - **Administrator**: Manages content and monitors system health. | 
|  | 14 | +- **External Systems**: | 
|  | 15 | + - **Keycloak**: Authentication and authorization (OIDC/OAuth2). | 
|  | 16 | + - **Grafana Observability Stack**: Grafana, Loki, Tempo, Fluent-bit, and OpenTelemetry (Otel) for monitoring and logging. | 
|  | 17 | +- **Interactions**: | 
|  | 18 | + - User → System: HTTP requests via Gateway. | 
|  | 19 | + - System → Keycloak: Authenticates users. | 
|  | 20 | + - System → Grafana Stack: Sends observability data. | 
|  | 21 | + | 
|  | 22 | +### Level 2: Container Diagram | 
|  | 23 | +**Description**: Breaks the system into deployable units. | 
|  | 24 | + | 
|  | 25 | +- **Containers**: | 
|  | 26 | + 1. **API Gateway (Spring Cloud Gateway)** | 
|  | 27 | + - Tech: Spring Boot + Spring Cloud Gateway | 
|  | 28 | + - Role: Routes requests, enforces security. | 
|  | 29 | + - Interactions: User → Gateway → CourseComposite. | 
|  | 30 | + 2. **CourseComposite (Aggregate Microservice)** | 
|  | 31 | + - Tech: Spring Boot | 
|  | 32 | + - Role: Aggregates Course and Review data. | 
|  | 33 | + - Interactions: Gateway → CourseComposite → Course/Review. | 
|  | 34 | + 3. **Course (Core Microservice)** | 
|  | 35 | + - Tech: Spring Boot | 
|  | 36 | + - Role: Manages course data. | 
|  | 37 | + - Database: PostgreSQL | 
|  | 38 | + - Interactions: CourseComposite → Course → PostgreSQL. | 
|  | 39 | + 4. **Review (Core Microservice)** | 
|  | 40 | + - Tech: Spring Boot | 
|  | 41 | + - Role: Manages review data. | 
|  | 42 | + - Database: MongoDB | 
|  | 43 | + - Interactions: CourseComposite → Review → MongoDB. | 
|  | 44 | + 5. **Keycloak** | 
|  | 45 | + - Role: External auth provider. | 
|  | 46 | + - Interactions: Gateway → Keycloak. | 
|  | 47 | + 6. **Observability Stack**: | 
|  | 48 | + - **Fluent-bit**: Log collection. | 
|  | 49 | + - **OpenTelemetry (OTel)**: Trace. | 
|  | 50 | + - **Loki**: Log storage. | 
|  | 51 | + - **Tempo**: Trace storage. | 
|  | 52 | + - **Grafana**: Visualization. | 
|  | 53 | + - Interactions: Microservices → Fluent-bit/OTel → Loki/Tempo → Grafana. | 
|  | 54 | + | 
|  | 55 | +### Level 3: Component Diagram | 
|  | 56 | +**Description**: Key components within containers. | 
|  | 57 | + | 
|  | 58 | +- **API Gateway**: | 
|  | 59 | + - Routing Component (Spring Cloud Gateway). | 
|  | 60 | + - Security Component (Keycloak integration). | 
|  | 61 | + - Observability Agent (OTel + Fluent-bit). | 
|  | 62 | +- **CourseComposite**: | 
|  | 63 | + - Course Client (REST). | 
|  | 64 | + - Review Client (REST). | 
|  | 65 | + - Aggregation Logic. | 
|  | 66 | + - Observability Agent. | 
|  | 67 | +- **Course**: | 
|  | 68 | + - Course Controller (REST). | 
|  | 69 | + - Course Service (Logic). | 
|  | 70 | + - Course Repository (JPA/PostgreSQL). | 
|  | 71 | + - Observability Agent. | 
|  | 72 | +- **Review**: | 
|  | 73 | + - Review Controller (REST). | 
|  | 74 | + - Review Service (Logic). | 
|  | 75 | + - Review Repository (MongoDB). | 
|  | 76 | + - Observability Agent. | 
|  | 77 | + | 
|  | 78 | +### Level 4: Deployment Notes | 
|  | 79 | +**Description**: Two deployment setups. | 
|  | 80 | + | 
|  | 81 | +1. **Docker Compose Setup**: | 
|  | 82 | + - Containers: Gateway, CourseComposite, Course + PostgreSQL, Review + MongoDB, Keycloak, Observability Stack. | 
|  | 83 | + - Networking: Single Docker network. | 
|  | 84 | + - Config: `docker-compose.yml`. | 
|  | 85 | + | 
|  | 86 | +2. **Kubernetes Setup with Tilt**: | 
|  | 87 | + - Pods: Gateway, CourseComposite, Course + PostgreSQL, Review + MongoDB, Keycloak, Observability Pods. | 
|  | 88 | + - Resources: Ingress, Services, ConfigMaps/Secrets, PVCs. | 
|  | 89 | + - Tilt: Automates dev with live updates. | 
|  | 90 | + - Observability: Fluent-bit DaemonSet | 
|  | 91 | + | 
|  | 92 | +### Additional Notes | 
|  | 93 | +- **Tech**: Spring Boot, Spring Cloud, JPA, MongoDB driver, OTel, Fluent-bit. | 
|  | 94 | +- **Interactions**: REST/HTTP, JDBC, MongoDB protocol. | 
|  | 95 | +- **Scalability**: Kubernetes supports replicas; Docker Compose for local dev. | 
0 commit comments