# asdt123/projeto-poo-2024-1 architecture

> Architecture diagram of the GitHub repository asdt123/projeto-poo-2024-1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/asdt123/projeto-poo-2024-1
- Repository: https://github.com/asdt123/projeto-poo-2024-1

## Overview

##### Project type and purpose
- This is a standalone 2D arcade-style game written in Python, inspired by Asteroids.
- Its primary goal is to let players choose a ship, load skins, fight aliens, collect drops, and enjoy a nostalgic experience.

##### File structure
- Top-level files:
- README.md – project description
- game.py – main entry point and game loop
- configurações/Config.py – global settings loader
- database/jogadores.db + root jogadores.db – SQLite files storing player progress or scores
- UML/ – design artifacts
- fontes, imagens/ – static assets (fonts, sprites, backgrounds)
- modulos/ package:
- modulos/personagens – domain entities (Player, Nave, Alien, Drops, Arsenal, Conta)
- modulos/janelas – UI layers (Janelas, Botões, Animações)

##### Key insights from README
- Built with Python, using OOP principles
- No external servers or microservices – everything runs locally
- Game mechanics, skin selection, and 2D rendering

##### Main components
a. Game Engine (game.py)
– Initializes subsystems, runs the main loop (initialize → input → update → render → loop).
b. Configuration Manager (configurações/Config.py)
– Reads config values (screen size, asset paths, difficulty).
c. Asset Manager
– Loads images (imagens/) and fonts (fontes/) at startup.
d. Entities Module (modulos/personagens)
– Defines game objects: Player/Nave, Alien, Drops, Conta, Arsenal – each with state and behavior.
e. UI Module (modulos/janelas)
– Handles menus, buttons, animations, HUD overlays.
f. Database Manager
– Encapsulates read/write operations on jogadores.db for saving high scores or player data.

##### Relationships and interactions
- The Game Engine calls Configuration Manager at startup, then hands off asset paths to Asset Manager.
- In each frame:
1. Input → Game Engine → evaluates via Entities Module (e.g., move Player).
2. Update → Entities Module updates positions, collisions, score (possibly invokes Database Manager on game over).
3. Render → UI Module draws menus, HUD; Asset Manager provides textures.
- Database Manager is invoked on “save profile” or “load profile” events in modulos/personagens/Conta.

##### Architectural patterns and principles
- Layered architecture:
- Presentation layer (UI Module)
- Domain layer (Entities Module)
- Infrastructure layer (Config, Asset, Database Managers)
- Single responsibility: each module deals with one concern (e.g., Config.py only reads settings).
- Dependency direction: higher-level modules (Game Engine) depend on lower-level services (config, assets, DB), not vice versa.

##### Technologies and frameworks
- Python standard library + pygame (presumed for rendering/input).
- SQLite for persistence.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        Config["Configuration Manager"]:::core
        AssetImg["Asset Manager (Images)"]:::asset
        AssetFont["Asset Manager (Fonts)"]:::asset
    end

    %% Core Game Loop
    GameEngine["Game Engine\n(game.py)"]:::core

    %% Domain Layer
    subgraph "Domain Layer"
        Alien["Alien"]:::core
        Arsenal["Arsenal"]:::core
        Conta["Conta\n(Account Save/Load)"]:::core
        Drops["Drops"]:::core
        Nave["Nave (Ship)"]:::core
        Player["Player"]:::core
    end

    %% Presentation Layer
    subgraph "Presentation Layer"
        Janelas["Window Management"]:::core
        Botoes["Button Widgets"]:::core
        Animacao["Animations"]:::core
    end

    %% Persistence Layer
    Database["Players DB\n(jogadores.db)"]:::db

    %% Game Loop Interactions
    GameEngine -->|"load settings"| Config
    GameEngine -->|"load images/fonts"| AssetImg
    GameEngine -->|"load images/fonts"| AssetFont
    GameEngine -->|"update"| Alien
    GameEngine -->|"update"| Arsenal
    GameEngine -->|"update"| Conta
    GameEngine -->|"update"| Drops
    GameEngine -->|"update"| Nave
    GameEngine -->|"update"| Player
    GameEngine -->|"render"| Janelas
    GameEngine -->|"render"| Botoes
    GameEngine -->|"render"| Animations
    Conta -->|"save/query"| Database

    %% Click Events
    click GameEngine "https://github.com/asdt123/projeto-poo-2024-1/blob/master/game.py"
    click Config "https://github.com/asdt123/projeto-poo-2024-1/blob/master/configurações/Config.py"
    click AssetImg "https://github.com/asdt123/projeto-poo-2024-1/tree/master/imagens/"
    click AssetFont "https://github.com/asdt123/projeto-poo-2024-1/tree/master/fontes/"
    click Alien "https://github.com/asdt123/projeto-poo-2024-1/blob/master/modulos/personagens/Alien.py"
    click Arsenal "https://github.com/asdt123/projeto-poo-2024-1/blob/master/modulos/personagens/Arsenal.py"
    click Conta "https://github.com/asdt123/projeto-poo-2024-1/blob/master/modulos/personagens/Conta.py"
    click Drops "https://github.com/asdt123/projeto-poo-2024-1/blob/master/modulos/personagens/Drops.py"
    click Nave "https://github.com/asdt123/projeto-poo-2024-1/blob/master/modulos/personagens/Nave.py"
    click Player "https://github.com/asdt123/projeto-poo-2024-1/blob/master/modulos/personagens/Player.py"
    click Janelas "https://github.com/asdt123/projeto-poo-2024-1/blob/master/modulos/janelas/Janelas.py"
    click Botoes "https://github.com/asdt123/projeto-poo-2024-1/blob/master/modulos/janelas/Botões.py"
    click Animacao "https://github.com/asdt123/projeto-poo-2024-1/blob/master/modulos/janelas/Animação.py"
    click Database "https://github.com/asdt123/projeto-poo-2024-1/blob/master/database/jogadores.db"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#000
    classDef asset fill:#98FB98,stroke:#000
    classDef db fill:#FFA500,stroke:#000,stroke-dasharray: 5 5
    class GameEngine,Config,Alien,Arsenal,Conta,Drops,Nave,Player,Janelas,Botoes,Animacao core
    class AssetImg,AssetFont asset
    class Database db
```
