Skip to content

Commit 19871a6

Browse files
committed
docs: Update README.md to reflect Alembic migration process and application structure changes
- Revised the database initialization section to specify the use of Alembic for migrations. - Updated application entry point from `app.py` to `main.py`. - Added notes on running migrations manually before starting the application. - Clarified project structure and included details about the new `alembic/` directory for migrations.
1 parent 172399d commit 19871a6

File tree

1 file changed

+31
-11
lines changed

1 file changed

+31
-11
lines changed

README.md

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,16 @@ A web platform for hosting and participating in collaborative online competition
6565

6666
d. Users can then click "Login with Wikimedia" on the login page
6767

68-
7. **Initialize database**
68+
7. **Initialize database with Alembic migrations**
6969
```bash
70-
python init_db.py
70+
# Apply all database migrations
71+
alembic upgrade head
72+
73+
# Or use the helper script
74+
python scripts/migrate.py upgrade head
7175
```
76+
77+
**Note**: The app does not automatically run migrations on startup. You must run Alembic migrations manually before starting the application.
7278

7379
8. **Run the application**
7480

@@ -78,7 +84,7 @@ A web platform for hosting and participating in collaborative online competition
7884

7985
Terminal 1 - Flask Backend:
8086
```bash
81-
python app.py
87+
python main.py
8288
```
8389

8490
Terminal 2 - Vue.js Frontend:
@@ -98,7 +104,7 @@ A web platform for hosting and participating in collaborative online competition
98104
npm install # Only needed first time
99105
npm run build
100106
cd ../backend
101-
python app.py
107+
python main.py
102108
```
103109

104110
Access at: `http://localhost:5000` (Flask serves built Vue.js files)
@@ -109,6 +115,8 @@ A web platform for hosting and participating in collaborative online competition
109115

110116
**Quick Testing Option**: If you want to skip MySQL setup, edit `.env` and change `DATABASE_URL` to `sqlite:///wikicontest.db`
111117

118+
**Database Migrations**: The application uses Alembic for database migrations. Always run `alembic upgrade head` before starting the app to ensure your database schema is up to date. The app does not automatically run migrations on startup.
119+
112120
**Frontend Development**: For the best development experience, run the Vue.js dev server (`npm run dev` in `frontend/` directory) alongside Flask. The dev server proxies API requests to Flask automatically.
113121

114122
## 🔧 Configuration
@@ -146,8 +154,11 @@ The `.env.example` file contains all configuration options. Copy it to `.env` an
146154
## 🧪 Testing
147155

148156
```bash
157+
# Make sure migrations are applied first
158+
alembic upgrade head
159+
149160
# Test the application
150-
python app.py
161+
python main.py
151162
# Open http://localhost:5000 and test:
152163
# - User registration/login
153164
# - Contest creation
@@ -162,21 +173,30 @@ python app.py
162173
export DATABASE_URL=your-production-mysql-url
163174
```
164175

165-
2. **Run with production server**
176+
2. **Apply database migrations**
177+
```bash
178+
alembic upgrade head
179+
```
180+
181+
3. **Run with production server**
166182
```bash
167183
pip install gunicorn
168-
gunicorn -w 4 -b 0.0.0.0:5000 app:app
184+
gunicorn -w 4 -b 0.0.0.0:5000 "app:app"
169185
```
170186

171187
## Project Structure
172188

173189
```
174190
wikicontest/
175191
├── backend/ # Flask application
176-
│ ├── app.py # Main application
177-
│ ├── models/ # Database models
178-
│ ├── routes/ # API endpoints
179-
│ └── middleware/ # Authentication
192+
│ ├── main.py # Application entry point
193+
│ ├── app/ # Application package
194+
│ │ ├── __init__.py # Flask app factory
195+
│ │ ├── models/ # Database models
196+
│ │ ├── routes/ # API endpoints
197+
│ │ └── middleware/ # Authentication
198+
│ ├── alembic/ # Database migrations (Alembic)
199+
│ └── scripts/ # Utility scripts
180200
└── frontend/ # Vue.js frontend
181201
├── src/ # Source files
182202
│ ├── views/ # Page components

0 commit comments

Comments
 (0)