Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: PLOT-TWIST CI/CD Pipeline

on:
push:
branches: [ "main", "develop", "feature/devops-enhancement" ]
pull_request:
branches: [ "main", "develop" ]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10'

- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt

- name: Lint with flake8
run: |
pip install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics

test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3

- name: Run Basic App Smoke Test
run: |
python -m pip install -r requirements.txt
python -c "from app import app; print('App initialized successfully')"

deploy:
runs-on: ubuntu-latest
needs: test
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/feature/devops-enhancement'
steps:
- uses: actions/checkout@v3

- name: Deploy to Vercel
uses: amondnet/vercel-action@v20
with:
vercel-token: ${{ secrets.VERCEL_TOKEN }}
vercel-org-id: ${{ secrets.VERCEL_ORG_ID }}
vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }}
vercel-args: '--prod'
working-directory: ./
99 changes: 53 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,67 +1,74 @@
# PLOT-TWIST — Branching Story Engine
# PLOT-TWIST: The Git-Integrated Story Engine

PLOT-TWIST is an interactive story game where your choices don't just affect the narrative—they affect the repository itself. Built with Flask and Git integration, it's a "meta" gaming experience for developers.

## 👥 Meet the Team
- **Aastha Dhavan**: Lead Developer & SDLC Manager
- **Taniya Bisht**: UI/UX Designer & Frontend Engineer
- **Janvi**: Database Architect & Backend Logic
## 1. Project Title
**PLOT-TWIST** — A DevOps-Enhanced Branching Narrative Experience.

---

## 🚀 Getting Started
## 2. Problem Statement
Many interactive fiction games lack a truly "meta" connection to the developer's world. **PLOT-TWIST** bridges this gap by using Git branches to represent story timelines. The project also addresses professional development standards by implementing a robust CI/CD pipeline, solving the problem of manual deployment and inconsistent environments in collaborative settings.

### 1. Prerequisites
- Python 3.8+
- Git installed on your system
---

### 2. Setup
```bash
# Clone the repository
git clone https://github.com/aasthadhavan/PLOT-TWIST.git
cd PLOT-TWIST
## 3. Architecture Diagram
![PLOT-TWIST Architecture](C:\Users\aasth\.gemini\antigravity\brain\127a9d8c-adff-4329-936f-a3d3f790dcf7\plot_twist_architecture_1775986869004.png)

# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
---

# Install dependencies
pip install -r requirements.txt
## 4. CI/CD Pipeline Explanation
The project utilizes **GitHub Actions** for an automated 3-stage pipeline:
1. **Build**: Initializes the Python environment and installs dependencies from `requirements.txt`.
2. **Test**: Runs automated linting (Flake8) and a "Smoke Test" to verify the Flask app initializes without errors.
3. **Deploy**: Upon a successful merge to `main` or `feature/devops-enhancement`, the pipeline automatically triggers a production deployment to **Vercel** using the `amondnet/vercel-action`.

# Initialize your environment
cp .env.example .env
# Edit .env and add a secret key
```
---

### 3. Running the Game
```bash
python app.py
```
Visit `http://127.0.0.1:5000` to start your journey.
## 5. Git Workflow Used
We implemented a **Structured Git Workflow**:
- **Main Branch**: Protected production branch.
- **Develop Branch**: Integration branch for team features.
- **Feature Branches**: Individual task branches (e.g., `feature/devops-enhancement`).
- **PR Strategy**: All features require a Pull Request and successful CI pass before merging into `develop` or `main`.

---

## 🛠 Collaboration Guidelines
## 6. Tools Used
- **Backend**: Flask (Python)
- **Database**: SQLite / SQL-Alchemy
- **Auth**: Flask-Login + Werkzeug Hashing
- **DevOps**: GitHub Actions, Docker, Vercel
- **APIs**: Gutendex (Archive Library)
- **SCM**: GitPython

---

To keep our repository healthy between 3 teammates, please follow this workflow:
## 7. Screenshots
### Pipeline Success
*(Place screenshot of GitHub Actions green checkmarks here)*

1. **Main Branch**: `develop` (Always merge feature branches here).
2. **Feature Branches**: Create branches like `feature/your-feature-name`.
3. **Conflict Resolution**: Use `git fetch` and `git rebase develop` before submitting a Pull Request.
4. **Story Branches**: Note that the game engine creates branches in the `story/` namespace. These are for gameplay state and should NOT be merged into `develop`.
### Deployment Output
*(Place screenshot of the working .vercel.app URL here)*

---

## 🏗 Architecture
- **Backend**: Flask
- **Database**: SQLite (via Flask-SQLAlchemy)
- **Auth**: Flask-Login with password hashing
- **SCM Engine**: GitPython (Story branching logic)
- **Public API**: Gutendex (Internal library archive)
## 8. Challenges Faced
- **Database Schema Migration**: Transitioning from plain-text passwords to `password_hash` required a full database wipe and recreation to prevent `SQLAlchemy` errors.
- **Vercel/Flask Integration**: Configuring Vercel's serverless functions to correctly find the Flask `app` object in a nested directory structure (`api/index.py`).
- **Git State Engine**: Designing a Git engine that doesn't conflict with the CI/CD runners' own Git state.

---

## 📝 Roadmap
- [ ] Add more local branching stories to `stories.json`.
- [ ] Implement a global leaderboard.
- [ ] Connect to PostgreSQL for shared team testing.
## ⚙️ Project Structure
```text
PLOT-TWIST/
├── api/ # Vercel Serverless Entry
│ └── index.py
├── instance/ # Local Database Storage
├── templates/ # Light-Mode UI (HTML)
├── .github/workflows/ # CI/CD Pipeline (GitHub Actions)
├── app.py # Main Flask Engine
├── models.py # SQL-Alchemy Models
├── config.py # Central Configuration
├── vercel.json # Vercel Deployment Config
└── README.md # Documentation
```
10 changes: 10 additions & 0 deletions api/index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import os
import sys

# Add the project root to the sys.path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))

from app import app

# Vercel needs the 'app' variable to be the handler
handler = app
Binary file removed instance/plottwist.db
Binary file not shown.
Loading
Loading