Skip to content
50 changes: 50 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
"""
Main entry point for the Bingo application.
"""

import logging
import os

from fastapi.staticfiles import StaticFiles
from nicegui import app, ui

from src.config.constants import FREE_SPACE_TEXT, HEADER_TEXT
from src.core.game_logic import (
bingo_patterns,
board,
board_iteration,
clicked_tiles,
generate_board,
is_game_closed,
today_seed,
)
from src.ui.routes import init_routes
from src.utils.file_operations import read_phrases_file

# Set up logging
logging.basicConfig(
level=logging.DEBUG, format="%(asctime)s - %(levelname)s - %(message)s"
)


# Initialize the application
def init_app():
"""Initialize the Bingo application."""

# Initialize game state
phrases = read_phrases_file()
generate_board(board_iteration, phrases)

# Initialize routes
init_routes()

# Mount the static directory
app.mount("/static", StaticFiles(directory="static"), name="static")

return app


if __name__ in {"__main__", "__mp_main__"}:
# Run the NiceGUI app
init_app()
ui.run(port=8080, title=f"{HEADER_TEXT}", dark=False)
11 changes: 11 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# DEPRECATED: This file is kept for backward compatibility with tests
# New development should use the modular structure in src/ with app.py as the entry point

import warnings

warnings.warn(
"main.py is deprecated. Use the modular structure in src/ with app.py as the entry point",
DeprecationWarning,
stacklevel=2,
)

import asyncio
import datetime
import logging
Expand Down
Empty file added src/__init__.py
Empty file.
Empty file added src/config/__init__.py
Empty file.
41 changes: 41 additions & 0 deletions src/config/constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"""
Configuration constants for the Bingo application.
"""

# Header text and display settings
HEADER_TEXT = "COMMIT !BINGO"
HEADER_TEXT_COLOR = "#0CB2B3"
CLOSED_HEADER_TEXT = "Bingo Is Closed"

# Free space settings
FREE_SPACE_TEXT = "FREE MEAT"
FREE_SPACE_TEXT_COLOR = "#FF7f33"

# Tile appearance settings
TILE_CLICKED_BG_COLOR = "#100079"
TILE_CLICKED_TEXT_COLOR = "#1BEFF5"
TILE_UNCLICKED_BG_COLOR = "#1BEFF5"
TILE_UNCLICKED_TEXT_COLOR = "#100079"

# Page backgrounds
HOME_BG_COLOR = "#100079"
STREAM_BG_COLOR = "#00FF00"

# Font settings
HEADER_FONT_FAMILY = "'Super Carnival', sans-serif"
BOARD_TILE_FONT = "Inter"
BOARD_TILE_FONT_WEIGHT = "700"
BOARD_TILE_FONT_STYLE = "normal"

# UI Class Constants
BOARD_CONTAINER_CLASS = "flex justify-center items-center w-full"
HEADER_CONTAINER_CLASS = "w-full"
CARD_CLASSES = (
"relative p-2 rounded-xl shadow-8 w-full h-full flex items-center justify-center"
)
COLUMN_CLASSES = "flex flex-col items-center justify-center gap-0 w-full"
GRID_CONTAINER_CLASS = "w-full aspect-square p-4"
GRID_CLASSES = "gap-2 h-full grid-rows-5"
ROW_CLASSES = "w-full"
LABEL_SMALL_CLASSES = "fit-text-small text-center select-none"
LABEL_CLASSES = "fit-text text-center select-none"
Empty file added src/core/__init__.py
Empty file.
Loading
Loading