0Mart00
Verbumix rebrand: emojis removed, multi-jurisdictional legal docs, cookie consent, footer links
9d4e305 |
Download REFACTOR_GUIDE.md from humut/WordGame: direct link, hf CLI and curl.
- Browser
- Download file 3.7 kB
-
https://huggingface.co/spaces/humut/WordGame/resolve/main/REFACTOR_GUIDE.md
- Command line
-
hf download hf://spaces/humut/WordGame/REFACTOR_GUIDE.md
-
curl -L -o REFACTOR_GUIDE.md https://huggingface.co/spaces/humut/WordGame/resolve/main/REFACTOR_GUIDE.md
3.7 kB
| # WordGame Refactoring Guide | |
| ## New Project Structure | |
| The project has been refactored to a modern, scalable structure following Python best practices: | |
| ``` | |
| wordGame/ | |
| βββ src/ | |
| β βββ wordgame/ | |
| β βββ __init__.py # Package initialization | |
| β βββ main.py # FastAPI application entry point | |
| β β | |
| β βββ core/ # Core module | |
| β β βββ __init__.py | |
| β β βββ config.py # Configuration management (pydantic-settings) | |
| β β βββ database.py # Supabase client initialization | |
| β β | |
| β βββ api/ # API layer | |
| β β βββ __init__.py | |
| β β βββ router.py # Main router aggregation | |
| β β βββ routes/ # Route modules | |
| β β βββ __init__.py | |
| β β βββ game_routes.py # Main game logic | |
| β β βββ auth_routes.py # Authentication | |
| β β βββ room_routes.py # Multiplayer rooms | |
| β β βββ slang_routes.py # Slang word import | |
| β β βββ paddle_routes.py # Payment webhooks | |
| β β βββ dashboard_routes.py # User dashboard | |
| β β | |
| β βββ features/ # Feature modules (optional, for complex features) | |
| β βββ user_dashboard/ # Example feature module | |
| β βββ __init__.py | |
| β βββ services/ | |
| β βββ repositories/ | |
| β βββ schemas/ | |
| β βββ utils/ | |
| β βββ templates/ | |
| β | |
| βββ templates/ # HTML templates | |
| βββ static/ # Static assets (CSS, JS, images) | |
| β | |
| βββ .env.example # Environment variables template | |
| βββ .gitignore # Git ignore rules | |
| βββ requirements.txt # Python dependencies | |
| βββ README.md # Project documentation | |
| βββ REFACTOR_GUIDE.md # This file | |
| ``` | |
| ## Key Changes | |
| ### 1. Source Layout (`src/`) | |
| - All Python code is now in `src/wordgame/` | |
| - Prevents import conflicts and follows modern Python packaging | |
| ### 2. Configuration Management | |
| - Uses `pydantic-settings` for environment-based configuration | |
| - All settings in `.env` file (copy from `.env.example`) | |
| - Type-safe configuration with validation | |
| ### 3. Modular Routes | |
| - Each feature has its own route module | |
| - Routes are aggregated in `api/router.py` | |
| - Easy to add/remove features | |
| ### 4. Separation of Concerns | |
| - `core/` - Configuration and database | |
| - `api/` - HTTP routes and request handling | |
| - `features/` - Complex feature modules (optional) | |
| ## Setup Instructions | |
| 1. **Install dependencies:** | |
| ```bash | |
| pip install -r requirements.txt | |
| ``` | |
| 2. **Configure environment:** | |
| ```bash | |
| cp .env.example .env | |
| # Edit .env with your Supabase credentials | |
| ``` | |
| 3. **Run the application:** | |
| ```bash | |
| # From project root | |
| python -m src.wordgame.main | |
| # Or with uvicorn | |
| uvicorn src.wordgame.main:app --reload | |
| ``` | |
| ## Benefits | |
| - **Scalable** - Easy to add new features | |
| - **Maintainable** - Clear separation of concerns | |
| - **Testable** - Each module can be tested independently | |
| - **Type-safe** - Full type hints and pydantic validation | |
| - **Modern** - Follows current Python best practices | |
| ## Migration Notes | |
| The old files (`main.py`, `database.py`, `room.py`, etc.) in the root directory are kept for reference but are no longer used. The new structure in `src/` is the authoritative codebase. |