This document provides a concise, step-by-step guide to set up, run, and test the project locally. It is intended for contributors preparing a development environment and does not replace higher-level documentation such as README.md, CONTRIBUTING.md, or ARCHITECTURE.md.
- Node.js 20.x (recommended)
- npm 9+ or pnpm 9+
- Python 3.10+ (required only to run the optional ML demo)
Use a version manager (for example nvm or volta) to manage Node.js versions.
This guide uses npm commands by default.
If you prefer pnpm, equivalent commands may be used where supported by the project:
pnpm installStart the frontend:
cd frontend
pnpm devStart the backend:
cd backend
pnpm dev- Clone the repository and install workspace dependencies:
# Replace <REPO_URL> with the repository origin
git clone <REPO_URL>
cd story-spark-ai
npm install-
Configure environment variables.
-
Ensure the local database is available and properly configured.
-
Start the frontend:
cd frontend
npm run dev- Start the backend:
cd backend
npm run devFollow the output of each command for service URLs and status messages.
frontend/— React + Vite application (UI)backend/— Express API, services, and ML helpersARCHITECTURE.md— architecture and design documentation
Before starting any services, copy the example environment files and populate the required values.
Example (macOS / Linux):
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.envExample (PowerShell):
Copy-Item backend\.env.example backend\.env
Copy-Item frontend\.env.example frontend\.envTypical development placeholders:
MONGODB_URI(e.g.mongodb://localhost:27017/storyspark-dev)JWT_SECRET(a random string for local development)OPENAI_API_KEYorGOOGLE_GEMINI_KEY(if available)
If API keys are not provided, features that depend on external services will not function; core frontend and backend functionality can still be exercised.
Ensure the database service required by the project is running before starting the backend.
Example local MongoDB connection string:
mongodb://localhost:27017/storyspark-dev
Verify that the MONGODB_URI value in backend/.env matches your local database configuration.
cd frontend
npm run devOpen the URL printed by Vite (commonly http://localhost:5173).
cd backend
npm run devCheck backend/package.json for exact script names (for example dev, start, or build).
After starting both services, verify that the development environment is working correctly.
Frontend:
- Open the Vite development URL in your browser.
- Confirm that the application loads without errors.
Backend:
- Confirm that the server starts successfully.
- Check startup logs for successful initialization and database connection messages.
Run backend tests:
cd backend
npm testRun Python/ML tests (if present). From the repository root run:
pytest backend/ml/testsOr, if you prefer to change directory first:
cd backend
pytest ml/testsRun linters and formatters as defined in project manifests (for example npm run lint).
If you frequently run both services together, you may add a local dev:all script to the root package.json.
Add the following dev:all script to your root package.json (inside the existing scripts section):
{
"scripts": {
"dev:all": "concurrently \"cd frontend && npm run dev\" \"cd backend && npm run dev\""
}
}Install concurrently as a development dependency if this pattern is used.
- Streamlit
FileNotFoundError: verify that required ML artifacts are available under the configured artifacts directory (for examplebackend/ml/saved/). - Rate limiting during local testing: review rate-limiter middleware in
backend/src/app/middlewareand adjust settings for development if necessary. - Seeding an admin user: review and run the seed script in
backend/scripts/seed-admin.tsif needed. - Windows path issues: use PowerShell examples above or WSL when applicable.
Before creating your first pull request, ensure that:
- Dependencies are installed successfully.
- Environment variables are configured.
- Database services are running and accessible.
- Frontend starts successfully.
- Backend starts successfully.
- Tests pass locally.
- Linters pass locally.
-
CONTRIBUTING.mdhas been reviewed.
- Follow the project's
CONTRIBUTING.mdfor PR conventions and code style. - Keep changes focused and incremental; open an issue for larger proposals before implementing.
- When adding environment variables, update
backend/.env.exampleand this document accordingly.
- Project overview:
README.md - Contribution guidelines:
CONTRIBUTING.md - Architecture:
ARCHITECTURE.md