Skip to content

Leskiv1/software_documentation_and_design_patterns

Repository files navigation

Software Documentation and Design Patterns

This repository contains a comprehensive project developed as part of the "Software Documentation and Design Patterns" course. The project demonstrates the evolution from architectural design (UML) to the implementation of a multi-tiered web application, utilizing modern programming patterns and message brokers.

Primary Domain (Laboratories 1-3): Steam Gaming Platform (user registration, game catalog, gaming sessions).
Domain (Laboratory 4): Open Data Processing (NYPD Motor Vehicle Collisions).


🛠 Tech Stack

  • Language: Python 3.10+
  • Web Framework: FastAPI, Jinja2
  • Databases: SQLite (SQLAlchemy ORM), Redis, Google Firestore (NoSQL)
  • Message Broker: Apache Kafka
  • Infrastructure: Docker, Docker Compose
  • UI/UX: HTML5, Bootstrap 5
  • Data Generation: Faker

📂 Laboratory Works Overview

Laboratory 1: UML Modeling

Designing the architecture of the "Steam" system using the Unified Modeling Language.

  • Use Case Diagram: User registration and game purchasing.
  • Class Diagram: Objects for game searching, session initiation, and status tracking.
  • Activity Diagram: Demonstration of a gaming session and state recording.
  • Sequence Diagram: The process of periodically saving the game session state to the database.

Laboratory 2: Layered Architecture

Implementing a strict three-tier architecture using Inversion of Control (IoC) and Dependency Injection (DI) patterns.

  • DAL (Data Access Layer): Database interactions with SQLite via SQLAlchemy ORM.
  • BLL (Business Logic Layer): Business logic that manages object creation and data parsing, completely isolated via interfaces.
  • Presentation Layer: API endpoints for the automated import of 1000+ denormalized rows from a CSV file into relational tables.

Laboratory 3: MVC Pattern (Model-View-Controller)

Creating a fully functional web interface for data visualization and management.

  • Implemented controllers to handle user HTTP requests.
  • Created HTML representations (Views) using the Jinja2 template engine and Bootstrap.
  • Implemented full CRUD (Create, Read, Update, Delete) operations for the "Game" entity via web forms.

Laboratory 4: Strategy Pattern

Separating the data reading logic from the storage logic. Demonstrating dynamic, "on-the-fly" integration with various storage systems.

  • Reading real-world dataset (NYPD Motor Vehicle Collisions). Link to dataset here.
  • Dynamically switching the storage destination via the config.json file without modifying the core code.
  • Implemented Strategies:
    • ConsoleStrategy (formatted terminal output).
    • RedisStrategy (writing to an In-memory DB).
    • KafkaStrategy (publishing messages to a broker topic).
    • FirestoreStrategy (saving to a Google Cloud NoSQL database).

🚀 Running Instructions

General Setup (For the entire project)

  1. Clone the repository and navigate to the project directory.
  2. Create and activate a Python virtual environment.
  3. Install the required dependencies:
    pip install -r requirements.txt
    

### Running Labs 2 & 3 (Gaming Platform)

*These tasks are executed in the root project directory.*

1. **Data Generation:** Create a test CSV file (1000+ rows):
```bash
python data_generator/generate_csv.py

  1. Start the Web Server: The steam_app.db database will be created automatically.
python main.py
  1. Data Import (Lab 2): Open a new terminal and run the client script for bulk database population:
python client_test.py
  1. Web Interface (Lab 3): Open your browser and navigate to http://127.0.0.1:8000/games to access the game catalog and use CRUD operations.

Running Lab 4 (Strategy Pattern)

This task is executed in its dedicated folder (e.g., strategy_pattern/).

  1. Environment Setup: Create a .env file for Google Firestore connection (add your firebase_key.json):
FIRESTORE_PROJECT_ID=your-data
FIRESTORE_COLLECTION=nyc_collisions
FIRESTORE_KEY_PATH=firebase_key.json
  1. Start Infrastructure: Spin up the Redis and Kafka containers using Docker:
docker-compose up -d

(Wait 15-20 seconds for Kafka to fully initialize). 3. Select Strategy: Open the config.json file and specify the desired storage type in the storage_type field (options: "console", "redis", "kafka", "firestore"). 4. Execution: Run the main script:

python main.py
  1. Stop Infrastructure: Once finished, tear down the Docker containers:
docker-compose down

About

A comprehensive Python project demonstrating UML design, Layered Architecture, MVC, and the Strategy pattern using FastAPI, Kafka, Redis, and Docker.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors