# quick note

## 📝 Notes on Software Architecture (LeSS - Let’s Start Talking about Software Architecture)

### 📜 Historical Context

- **Software industry is young:** Only 40 years old; we borrowed architecture concepts from civil engineering.
- **Senate House** Symbol of the University of London
  - Designed to be unique and contemporary, not mimicking other universities.
  - Represents **“academic island in swirling tides of traffic”**—a structure suited to its era and location.
  - **Key Takeaways:**
    - Style drives pattern (decoration aligns with architecture).
    - **Even incomplete, it fulfills its intended purpose.**

### 🌐 Software Architecture Fundamentals

- **Definition:** High-level structure of a software system, including its components, interactions, and design principles.
- **Core Elements:**
  - **Style → Pattern → Component → Interface → Deployment → Dataflow**

### 🎯 Importance of Software Architecture according to internet and AI

- **Guides Development:** Creates a roadmap for building systems.
- **Improves Communication:** Helps developers and stakeholders collaborate.
- **Enhances Scalability:** Expands capacity effectively?
- **Increases Maintainability:** Ensures long-term stability?

but **Enhances Scalability** and **Increases Maintainability** usually can be done without good architecture, so its not actual one of the benefit of good architecture

### 💡 Key Concepts in Software Architecture

- **Architecture Styles:**
  - Known ones include **Layered (N-Tier), Event-Driven, CQRS, Hexagonal**.
    - detail each

      ### 1. **Layered (N-Tier) Architecture**

      - **Structure:** The system is divided into layers (or tiers) where each layer is responsible for a specific task. For example, a **3-layered architecture** may have a presentation layer (UI), a business logic layer (application logic), and a data layer (database interaction).
      - **Purpose:** To separate concerns and make the application easier to maintain, scale, and test.

      ### Key Details:

      - **Common Layers:**
        - **Presentation Layer:** Handles user interface (UI), interacting with users.
        - **Business Logic Layer:** Handles processing and decision-making based on the data.
        - **Data Layer:** Responsible for storing and retrieving data from a database.
      - **Advantages:**
        - Clear separation of concerns.
        - Easier to maintain and scale individual parts of the system.
      - **Disadvantages:**
        - Can lead to tightly-coupled code if not managed properly.
        - Overhead in moving data between layers.

      ---

      ### 2. **Event-Driven Architecture (EDA)**

      - **Structure:** The system reacts to events. An event represents a change in state, such as a user action or a system update. Components communicate by producing and consuming events asynchronously.
      - **Purpose:** To allow components of the system to operate independently and react to changes in the system as they occur.

      ### Key Details:

      - **Core Components:**
        - **Event Producers:** Generate events (e.g., a user submits a form).
        - **Event Consumers:** Listen for and respond to events (e.g., sending a confirmation email after form submission).
        - **Event Bus/Queue:** The mechanism that transmits events between producers and consumers (e.g., Kafka, RabbitMQ).
      - **Advantages:**
        - Decouples components, leading to more scalable and resilient systems.
        - Allows for real-time processing and greater flexibility in handling events.
      - **Disadvantages:**
        - Harder to track the flow of data, making debugging complex.
        - Requires careful management of event flow and event consistency.

      ---

      ### 3. **CQRS (Command Query Responsibility Segregation)**

      - **Structure:** Separates the handling of data into two different models: one for **commands** (write operations) and one for **queries** (read operations). This allows for optimized data handling for both operations.
      - **Purpose:** To optimize read and write operations separately, which is particularly useful in systems where reading and writing are vastly different in terms of performance and requirements.

      ### Key Details:

      - **Key Components:**
        - **Command Side:** Handles all write operations (e.g., creating or updating data).
        - **Query Side:** Handles all read operations (e.g., retrieving data).
      - **Advantages:**
        - Allows for better optimization of read and write models independently.
        - Improves performance and scalability for both types of operations.
        - Can reduce complexity by simplifying how data is queried and written.
      - **Disadvantages:**
        - Requires separate data models, leading to more complexity in managing the system.
        - Involves additional infrastructure for handling the separation (e.g., message queues).

      ---

      ### 4. **Hexagonal Architecture (Ports and Adapters)**

      - **Structure:** A system where the core application logic is surrounded by various "ports" that interact with external systems through "adapters." The main goal is to make the core system independent of external systems.
      - **Purpose:** To allow the core business logic to remain isolated from external dependencies like databases, UIs, and third-party services.

      ### Key Details:

      - **Core Application (The Hexagon):** The heart of the system, handling business logic.
      - **Ports:** Define the interfaces through which the core logic interacts with external components (e.g., a database port, a user interface port).
      - **Adapters:** Implement the actual communication between external systems and the core logic (e.g., database adapters, web service adapters).
      - **Advantages:**
        - Decouples the core application logic from external dependencies, making the system more adaptable.
        - Facilitates testing by allowing easy mock implementations of external components.
      - **Disadvantages:**
        - Can add complexity in terms of defining the ports and creating adapters for each external system.
        - Requires careful planning to ensure the core logic stays isolated and independent.

      ---

      ### Comparison Summary:

      Architecture StyleKey FeatureProsCons**Layered (N-Tier)**Separate layers for different responsibilitiesClear structure, easier to maintainCan become tightly coupled, performance overhead**Event-Driven**Reacting to events asynchronouslyDecouples components, supports real-time systemsHard to debug, complex event flow management**CQRS**Separate models for commands (writes) and queries (reads)Optimizes read and write operationsIncreased complexity with separate models**Hexagonal**Core business logic surrounded by ports and adaptersIsolates core logic, facilitates testingRequires careful design of ports and adapters
  - No “best” architecture—only what fits the specific **context and time**.
  - Large applications often combine multiple architectures.
- **Technology ≠ Architecture:**
  - Choose technology based on suitability, not preference.
  - Start small, scale up as necessary.
  - Technology landscape ≠ project architecture.

### 🛠 Practical Insights

- **Customer Expectations:** Customers expect clear, actionable solutions—most existing patterns are **well-documented online**.
- **Thailand Products:** 99% are not entirely new; leverage known patterns like **microservices** or **layered architecture**.
- **Architects Should Code:**
  - Like civil architects, software architects **must be hands-on**.
- **Tech Decisions:** Align choices with **system needs**, not personal desires.

### 🔗 General Philosophy

- **“There is no best architecture, only the one that fits the situation.”**
- Software architecture evolves with the system; adaptability is key.

## 📝 Note on Software Development and Release Management

### 🌱 Trunk-Based Development

- **Branching for Features:** Create separate branches for new features.
- **Merging to Main:** Once the feature is ready, merge it back into the `main` branch.

### 🔄 Backward Compatibility Requirements

- **Test Coverage:** Make sure new changes don’t break existing functionality. You cannot just push to `main` without ensuring the old features still work.
- **Backward Compatibility:** Use techniques like feature toggles to ensure users who haven’t updated still have a working version.
- **Regression Tests:** Ensure that new changes do not unintentionally break older functionality. 
  - **QA Coordinator:** Acts as the point of contact for all contributors to ensure quality and testing requirements are met.
  - **E2E Automation:** Automate end-to-end tests to speed up the process and reduce human errors.
- **Go/No-Go Meeting:** The release management team decides whether the product is ready to be deployed.

### 🛠️ Harness Pipeline and Canary Deployment

- **Harness Pipeline:** Use a pipeline to automate the deployment process.
- **Canary Deployment:** Gradually roll out new versions to a small set of users first to detect issues early before a full release.

### 🏗️ Back-End Coordinator

- **Microservices Deployment:** Ensure all microservices are deployed correctly on the staging environment for thorough testing before production.

### Using Recognize

- **Recognize** - 🧠 A process of identifying and recalling patterns, names, or things you've seen before. It helps in fast learning and decision-making.
- **eg:**
  - when you trying to remember these letters **“BT SKF CMR TSB ENA SA”** in 7 second, you mostly can’t remember every letters. but if you rearrange to **“BTS KFC MRT SBE NASA”** that would be easier because you recognize it!

### Flow, Mihaly

- **Flow** - 🌊 A mental state where you're fully immersed in an activity.
- **Mihaly Csikszentmihalyi** - 📚 Psychologist who developed the concept of "Flow."
- **Flow Characteristics**: 
  - Full engagement and concentration.
  - Loss of time awareness.
  - Balanced challenge and skill level.

### Brain as an Elephant Rider

- **Elephant Rider** 🐘: The brain's metaphor where: 
  - **Left Side** (Logical) - 🎓 Rider, rational thinking and logic.
  - **Right Side** (Emotional) - ❤️ Elephant, emotional thinking and decisions.
  - **Emotions** often take over because the elephant is much stronger than the rider.

### When Lizene Runs Out, All Power Goes to Elephant

- **Lizene** - 💡 Possibly a metaphor for willpower or decision-making energy.
- **Elephant** takes over when we are mentally exhausted, leading to emotional decisions.

### 4 Factors Impacting Mental Performance:

### 1. Responsiveness: ⏱️

- **Fast Feedback** = **Good**: The quicker you get feedback, the better the performance.
- **ADHD** can affect the need for fast responses.

### 2. Motivation: ❄️

- **Snowball Effect**: Motivation builds momentum. Small successes lead to more progress.
- **Celebrate**: Dopamine boosts and addiction to success.
- **Breaks**: Taking time for success celebrations can fuel more productivity.

### 3. Communication: 💬

- **Team Success** = **Personal Success**: Working together creates a feeling of shared achievement.
- **Levels of Intensity**: Messages and communication have different levels of emotional impact.
- **Hormonal Influence**: When one person feels a strong emotion, the group often shares that feeling.

### 4. Childress: 🧸

- **Fun**: Adding joy to work can boost creativity.
- **Hippocampus**: A brain part involved in memory and creativity.
- **Imagine Success**: Avoid imagining failure, as it negatively impacts performance.

### Curse of Learning

- **Curse of Learning**: 🤯 When you don’t fully understand something, it’s easy to forget it.
- **Unlearn, Relearn**: Essential skills for retaining knowledge and adapting to new concepts.

### Talking to Yourself for Mental Health

- **Self-Talk**: 🗣️ Talking to yourself helps process emotions and reinforce positive thinking. It's a good practice for mental well-being.

### Reflection

- "If you imagine failure first, you are guaranteed to fail." 
  - **Mindset**: 🧠 Starting with a positive mindset improves performance and outcomes.

## 💡 Everything is Possible

- **Endless opportunities** to explore and grow, believe in the potential for change and innovation.

## 🔄 Nothing Bad Comes from Experience

- **Self Improvement**: Every experience, whether good or bad, is a chance to evolve and grow.
- **Strategy & Evaluation**: Learning from experiences allows you to refine your approach and strategies.
- **Improve Performance**: Mistakes lead to better performance through continuous learning.

## 🤔 Notice Yourself by Asking:

- **“What do you want?”**: Reflect on your desires and goals.
- **“What do you want to teach?”**: Consider how you can share your knowledge and help others grow.

## 🔗 Connect Theory and Practice

- **Truth of Theory**: Theoretical knowledge forms the foundation, but its true value is seen in practice.
- **Connection Between Reality and Theory**: Not everyone interprets or applies theory the same way, leading to different outcomes.
  - **Reality is often hard to accept**: People struggle to see how theories play out in real situations.
- **Decision-Making**: Context and individual perspective drive the choices we make in each scenario.

## 🔄 Continuous Improvement

- **Learn What You Don’t Know**: Embrace the idea of lifelong learning. Seek out knowledge in areas outside your comfort zone.

## 🧑‍🤝‍🧑 Focus on Customers

- **Things Theory Doesn’t Tell You**:
  1. **Sharing**: Open communication builds trust and collaboration.
  2. **Listening**: Understanding customers’ needs leads to better service.
  3. **Maximizing Output**: Combining sharing and listening creates the best results.

## 🤝 Collaboration

- **Respect Every Role**: Everyone has a unique value. Respecting each role is essential for success.
- **Seeing Common Ground**: Focus on shared goals and objectives to unite the team.
- **Talented People Don’t Have to Be Good at Everything**: People are most effective when they excel in their specific roles.
- **Success Comes with the Team**: No achievement is truly individual; success is built through collective effort.

**“We believe working on software is going to be fun”** Odds 🎉
- **Doing software has to be fun** 💻✨
  - Fun means different things to different people, so there’s no wrong way to have fun! 🧑‍🤝‍🧑🎮
  - The essence of fun is about having energy, staying motivated, and enjoying the process. 💪🔥
  - Being lazy is not mean not joyful. Everyone has their own pace. 🛋️➡️🎯
- **Why?** 🤔💡
  - Software development isn't just a job; it’s something we do because it brings us joy and fulfillment. 😊🌱
  - Passion fuels the work, turning it into something enjoyable rather than a mere task. 💖
- **Speaking is key** 🗣️🔑
  - Communication helps to share ideas, build team energy, and maintain excitement. 🗨️👥
  - When you're passionate, it’s easier to motivate others and keep the energy flowing. 🌟🚀

## So basically, working by “passion”. make your job joyful in your own way”

## 🧠 **AI and Human Replacement: A Glimpse into the Future**

- 🚂 **We’ve already seen it in the past: Industrial Revolution**
  - Machines replaced muscle power with automation.
  - Now, we’re entering the **AI Revolution** where minds might be replaced by intelligent systems.
- 📅 **Agentic AI by 2025**
  - We are nearing the era of **Agentic AI**, which could take on roles that require human-like decision-making and autonomy.
- 💻 **AI Can Replace Humans in Every Career, Even Software Development**
  - AI is becoming capable of handling tasks in **every category** of software development and beyond.
  - This means **AI could replace any profession**, especially those focused on repetitive or systematic tasks.
- 👨‍💻 **Craig Larman's Prediction**
  - **Craig Larman** believes AI will be capable of replacing humans in just a few years, making the transition inevitable.
- 🖱️ **From Cursor to Copilot**
  - We are moving from traditional software usage with a **cursor** to having **AI-powered copilots** assisting us in real-time.
- ⚠️ **WE NEED TO ADAPT**
  - The future is approaching fast, and it's crucial that we **adapt** to new technologies to stay relevant.
- 🤖 **Concern About People Using AI to Replace Us**
  - The true concern isn’t just AI itself replacing jobs; it’s **people using AI** to replace others that we need to focus on.

summarize this in form of  human-like/bullet point with emoji as with topic note with detail of each bullet point.