# mohamediliasskaddar/test-sma architecture

> Architecture diagram of the GitHub repository mohamediliasskaddar/test-sma, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohamediliasskaddar/test-sma
- Repository: https://github.com/mohamediliasskaddar/test-sma

## Overview

1. Overall purpose  
ReserVibe is a Java multi-agent simulation built on JADE. It models a resource-allocation problem where multiple person agents try to reserve seats at multiple restaurant agents with limited capacity and possible line saturation. The architecture is centered on agent interaction rather than a traditional layered application.

2. Runtime and platform boundary  
The main runtime dependency is JADE (`lib/jade.jar`), which provides the agent container, agent lifecycle, and inter-agent messaging. The project is a console-based simulation, so the observable output is primarily logs/statistics rather than a GUI or network service.

3. Entry and orchestration  
`Main.java` is the likely bootstrap entrypoint. It delegates simulation setup to `simulation/Simulation.java`, which appears to configure the scenario, create agents, launch the JADE container, and collect results at the end. This is the top-level orchestration boundary.

4. Simulation subsystem  
`simulation/Simulation.java` is the scenario manager. It owns the experiment parameters such as number of people, number of restaurants, and chosen strategy. It also appears responsible for generating restaurant capacities and saturation probabilities, then coordinating execution and summary reporting.

5. Agent hierarchy  
`agents/AgentBase.java` is the shared abstraction for JADE agents in this system. `AgentPersonne.java` and `AgentRestaurant.java` specialize it into two roles: demand-side agents that search for reservations, and supply-side agents that accept or reject reservations based on capacity and line availability.

6. Person-agent flow  
`AgentPersonne` drives the reservation attempt sequence. A person agent selects restaurants according to one of the strategies, sends reservation-related requests, counts attempts, and records whether it succeeded. This is the main consumer-facing side of the simulation.

7. Restaurant-agent flow  
`AgentRestaurant` is the service endpoint for reservation requests. It maintains capacity, tracks occupancy/reservations, and simulates whether its phone line or intake is saturated. It responds to incoming requests with acceptance or refusal, making it the resource gatekeeper.

8. Strategy subsystem  
The `behaviours/` package contains the decision logic: `ComportementGlouton`, `ComportementAleatoire`, and `ComportementCooperatif`. These are behavior modules attached to person agents, letting the same agent type operate under different policies without changing the agent identity itself.

9. Strategy selection and configuration  
`enums/Strategie.java` is the configuration boundary for choosing among the three behaviors. The simulation uses this enum to decide which behavior to attach or activate for person agents. This keeps strategy choice separate from agent implementation.

10. Cooperative data flow  
The cooperative mode introduces peer-to-peer information sharing between agents. Instead of each person acting only on direct feedback, agents broadcast or reuse knowledge about saturated lines, unavailable restaurants, and successful reservations to reduce wasted calls. This is the only strategy that explicitly creates a shared-information channel.

11. Main interaction pattern  
The primary data flow is: simulation initializes agents → person agents choose a restaurant via their behavior → request is sent to a restaurant agent → restaurant accepts or rejects based on capacity/saturation → person agent updates its state and possibly retries → simulation aggregates results. The architecture is therefore a closed-loop agent interaction model with centralized setup and decentralized decision-making.

12. Output and analysis boundary  
At the end of execution, the simulation reports restaurant occupancy, number of calls per person, reservation success rate, and global efficiency metrics. These outputs are used to compare the three strategies rather than to drive further system behavior.

13. Key architectural characteristics  
This repository is best understood as an experimental multi-agent model, not a business application. The important boundaries are: simulation orchestration, agent roles, strategy behaviors, and JADE runtime messaging. The design makes it easy to compare behavioral policies under the same restaurant-capacity constraints.

Main entry points: [`src/agents/AgentPersonne.java`](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/agents/AgentPersonne.java) (Person agent), [`src/simulation/Simulation.java`](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/simulation/Simulation.java) (Simulation), [`src/agents/AgentRestaurant.java`](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/agents/AgentRestaurant.java) (Restaurant agent), [`src/enums/Strategie.java`](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/enums/Strategie.java) (Strategy enum)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_runtime["Runtime"]
  node_node_jade[("JADE<br/>runtime<br/>[jade.jar]")]
end

subgraph group_group_core["Core simulation"]
  node_node_main(("Main<br/>bootstrap<br/>[Main.java]"))
  node_node_simulation["Simulation<br/>orchestrator<br/>[Simulation.java]"]
  node_node_strategy_enum{{"Strategy enum<br/>config enum<br/>[Strategie.java]"}}
  node_node_metrics["Results<br/>reporting<br/>[Simulation.java]"]
end

subgraph group_group_agents["Agents"]
  node_node_agent_base["Agent base<br/>abstract agent<br/>[AgentBase.java]"]
  node_node_person(("Person agent<br/>demand agent<br/>[AgentPersonne.java]"))
  node_node_restaurant(("Restaurant agent<br/>supply agent"))
end

subgraph group_group_behaviors["Strategies"]
  node_node_greedy["Greedy<br/>strategy"]
  node_node_random["Random<br/>strategy"]
  node_node_coop["Cooperative<br/>strategy"]
end

node_node_main -->|"starts"| node_node_simulation
node_node_simulation -->|"uses"| node_node_jade
node_node_simulation -->|"configures"| node_node_strategy_enum
node_node_simulation -->|"creates"| node_node_person
node_node_simulation -->|"creates"| node_node_restaurant
node_node_agent_base -->|"base for"| node_node_person
node_node_agent_base -->|"base for"| node_node_restaurant
node_node_person -->|"can use"| node_node_greedy
node_node_person -->|"can use"| node_node_random
node_node_person -->|"can use"| node_node_coop
node_node_strategy_enum -->|"maps to"| node_node_greedy
node_node_strategy_enum -->|"maps to"| node_node_random
node_node_strategy_enum -->|"maps to"| node_node_coop
node_node_person -->|"requests"| node_node_restaurant
node_node_restaurant -->|"responds"| node_node_person
node_node_coop -.->|"shares info"| node_node_person
node_node_simulation -->|"reports"| node_node_metrics
node_node_person -->|"contributes"| node_node_metrics
node_node_restaurant -->|"contributes"| node_node_metrics

click node_node_main "https://github.com/mohamediliasskaddar/test-sma/blob/main/src/Main.java"
click node_node_simulation "https://github.com/mohamediliasskaddar/test-sma/blob/main/src/simulation/Simulation.java"
click node_node_jade "https://github.com/mohamediliasskaddar/test-sma/blob/main/lib/jade.jar"
click node_node_agent_base "https://github.com/mohamediliasskaddar/test-sma/blob/main/src/agents/AgentBase.java"
click node_node_person "https://github.com/mohamediliasskaddar/test-sma/blob/main/src/agents/AgentPersonne.java"
click node_node_restaurant "https://github.com/mohamediliasskaddar/test-sma/blob/main/src/agents/AgentRestaurant.java"
click node_node_greedy "https://github.com/mohamediliasskaddar/test-sma/blob/main/src/behaviours/ComportementGlouton.java"
click node_node_random "https://github.com/mohamediliasskaddar/test-sma/blob/main/src/behaviours/ComportementAleatoire.java"
click node_node_coop "https://github.com/mohamediliasskaddar/test-sma/blob/main/src/behaviours/ComportementCooperatif.java"
click node_node_strategy_enum "https://github.com/mohamediliasskaddar/test-sma/blob/main/src/enums/Strategie.java"
click node_node_metrics "https://github.com/mohamediliasskaddar/test-sma/blob/main/src/simulation/Simulation.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_jade toneBlue
class node_node_main,node_node_simulation,node_node_strategy_enum,node_node_metrics toneAmber
class node_node_agent_base,node_node_person,node_node_restaurant toneMint
class node_node_greedy,node_node_random,node_node_coop toneRose
```

## Components

### Runtime

Execution and platform boundary

- [JADE](https://github.com/mohamediliasskaddar/test-sma/blob/main/lib/jade.jar): runtime · Agent container and messaging platform · `lib/jade.jar`

### Core simulation

Bootstrap and scenario orchestration

- [Main](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/Main.java): bootstrap · Application entrypoint · `src/Main.java`
- [Simulation](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/simulation/Simulation.java): orchestrator · Sets up scenarios, agents, and results · `src/simulation/Simulation.java`
- [Strategy enum](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/enums/Strategie.java): config enum · Chooses which behavior policy to activate · `src/enums/Strategie.java`
- [Results](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/simulation/Simulation.java): reporting · Aggregates occupancy, calls, and success metrics · `src/simulation/Simulation.java`

### Agents

JADE agent roles and shared base

- [Agent base](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/agents/AgentBase.java): abstract agent · Shared JADE agent foundation · `src/agents/AgentBase.java`
- [Person agent](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/agents/AgentPersonne.java): demand agent · Searches restaurants and attempts reservations · `src/agents/AgentPersonne.java`
- [Restaurant agent](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/agents/AgentRestaurant.java): supply agent · Manages capacity and reservation responses · `src/agents/AgentRestaurant.java`

### Strategies

Behavior modules selected at runtime

- [Greedy](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/behaviours/ComportementGlouton.java): strategy · Chooses restaurants by greedily pursuing reservations · `src/behaviours/ComportementGlouton.java`
- [Random](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/behaviours/ComportementAleatoire.java): strategy · Selects restaurants randomly · `src/behaviours/ComportementAleatoire.java`
- [Cooperative](https://github.com/mohamediliasskaddar/test-sma/blob/main/src/behaviours/ComportementCooperatif.java): strategy · Shares information between person agents · `src/behaviours/ComportementCooperatif.java`

## Connections

- Main → Simulation: starts · Bootstraps the simulation run
- Simulation → JADE: uses · Relies on JADE for agent lifecycle and messaging
- Simulation → Strategy enum: configures · Selects the strategy for each run
- Simulation → Person agent: creates · Instantiates demand-side agents
- Simulation → Restaurant agent: creates · Instantiates supply-side agents
- Agent base → Person agent: base for · Person agent specialization
- Agent base → Restaurant agent: base for · Restaurant agent specialization
- Person agent → Greedy: can use · Behavior attached under greedy strategy
- Person agent → Random: can use · Behavior attached under random strategy
- Person agent → Cooperative: can use · Behavior attached under cooperative strategy
- Strategy enum → Greedy: maps to · Strategy selection resolves to greedy behavior
- Strategy enum → Random: maps to · Strategy selection resolves to random behavior
- Strategy enum → Cooperative: maps to · Strategy selection resolves to cooperative behavior
- Person agent → Restaurant agent: requests · Sends reservation attempts to restaurants
- Restaurant agent → Person agent: responds · Accepts or refuses reservation requests
- Cooperative → Person agent: shares info · Enables peer knowledge exchange
- Simulation → Results: reports · Produces final occupancy and efficiency summaries
- Person agent → Results: contributes · Provides attempts and success outcomes
- Restaurant agent → Results: contributes · Provides occupancy and capacity outcomes
