This guide will walk you through setting up Pytrix for local development and solving your first practice question.
Before you begin, ensure you have the following installed:
| Requirement | Version | How to Check |
|---|---|---|
| Node.js | 20.x or higher | node --version |
| npm | 10.x or higher | npm --version |
| Git | Any recent version | git --version |
Tip
We recommend using nvm to manage Node.js versions.
git clone https://github.com/SH1SHANK/Pytrix.git
cd Pytrixnpm installThis installs all required packages including:
- Next.js 16 and React 19
- Pyodide for Python execution
- Monaco Editor for the code editor
- shadcn/ui components
- Testing frameworks (Vitest, Playwright)
npm run devOpen your browser and navigate to http://localhost:3000.
Note
The first load may take a few seconds as Next.js compiles the application.
When you first access Pytrix, you'll be guided through an onboarding flow:
You'll see a brief introduction to Pytrix and its features.
Pytrix uses a Bring Your Own Key (BYOK) model. You'll need a Google Gemini API key for AI features.
- Go to Google AI Studio
- Sign in with your Google account
- Click "Create API Key"
- Copy the generated key
- Paste your API key in the input field
- Click "Test Connection" to verify it works
- Your key is saved to your browser's localStorage
Important
Your API key is never sent to Pytrix servers. It's stored locally and used to communicate directly with Google's Gemini API.
After configuring your key, the onboarding is complete. You'll be redirected to the Dashboard.
- From the Dashboard, click "Manual Practice" or press
Cmd/Ctrl+Kand type "manual" - Select a Module (e.g., "String Manipulation")
- Choose a Subtopic (e.g., "Basic String Operations")
- Pick a Difficulty (Beginner recommended for first run)
- Click "Generate Question"
- Read the problem description in the Question Panel
- Write your Python solution in the Code Editor
- Click "Run" to execute your code and see output
- Click "Submit" to have the AI evaluate your solution
If you're stuck:
- Click "Get Hint" for progressive hints (up to 2)
- After using hints, "Reveal Solution" becomes available
- The AI provides feedback explaining what went wrong
For a more dynamic experience:
- From the Dashboard, click "Start Auto Mode"
- Questions are generated automatically
- Solve each question and get instant feedback
- Your streak and difficulty adjust based on performance
After cloning, your project structure looks like this:
pytrix/
├── src/
│ ├── app/ # Next.js pages and routes
│ ├── components/ # React components
│ ├── lib/ # Core services and utilities
│ ├── hooks/ # Custom React hooks
│ ├── data/ # Static data (topics.json)
│ └── types/ # TypeScript definitions
├── tests/ # Test suites
├── docs/ # Documentation (you are here)
├── public/ # Static assets
└── ...config files
For detailed architecture, see Architecture.
| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run start |
Start production server |
npm run lint |
Run ESLint |
npm run test |
Run all tests |
npm run test:watch |
Run tests in watch mode |
npm run test:e2e |
Run Playwright E2E tests |
npm run test:coverage |
Generate coverage report |
Pytrix uses a BYOK model and requires no server-side environment variables for normal operation.
If you're a maintainer running real API integration tests:
-
Copy the template:
cp tests/env.test.local.example .env.test.local
-
Edit
.env.test.local:INTERNAL_GEMINI_KEY="your-test-api-key"
Caution
Never commit .env.test.local to version control. It's already in .gitignore.
This occurs when the required security headers are missing. Pytrix needs:
Cross-Origin-Opener-Policy: same-originCross-Origin-Embedder-Policy: require-corp
These are configured in next.config.ts and should work automatically in development.
If using a custom server: Ensure your server sends these headers.
- Verify your key at Google AI Studio
- Check that you copied the complete key (no trailing spaces)
- Ensure your key has the Gemini API enabled
The first load downloads the Pyodide runtime (~15MB). Subsequent loads use the browser cache. This is normal behavior.
- Ensure you're on Node.js 20+
- Clear test cache:
npx vitest --clearCache - Check that all dependencies are installed:
npm ci
# Find the process
lsof -i :3000
# Kill it
kill -9 <PID>
# Or use a different port
npm run dev -- -p 3001Now that you're set up:
- Explore the Dashboard — See your stats and module progress
- Try Auto Mode — Experience adaptive difficulty
- Browse Modules — Explore the curriculum at
/modules - Customize Settings — Adjust preferences at
/support/settings
- Architecture — How Pytrix works under the hood
- API Reference — For developers extending Pytrix
- Contributing — Help improve Pytrix
Pytrix is optimized for deployment on Vercel. See DEPLOYMENT.md for complete deployment documentation including:
- Automatic CI/CD setup
- Preview deployments for PRs
- Production deployment workflow