Thank you for considering contributing to JournalXP! We're excited to build a space where mental health and gamification meet, and your help makes a big difference.
- Getting Started
- Development Setup
- Project Structure
- Coding Guidelines
- Commit Guidelines
- Testing
- Pull Request Process
- Code Review
Before contributing, ensure you have:
- Node.js 22+ installed
- npm 10+ installed
- Firebase CLI:
npm install -g firebase-tools - Git for version control
- A Firebase project (or use the existing one for local development)
- Fork this repository on GitHub
- Clone your fork to your local machine:
git clone https://github.com/your-username/JournalXP.git
cd JournalXP- Add the upstream remote:
git remote add upstream https://github.com/Simpleboi/JournalXP.gitThe project uses a monorepo structure. Install dependencies for all workspaces:
# Root dependencies
npm install
# Frontend dependencies
cd frontend && npm install && cd ..
# Functions dependencies
cd functions && npm install && cd ..
# Shared dependencies
cd shared && npm install && cd ..Create frontend/.env:
VITE_API_URL=http://localhost:5000
VITE_API_PROD=https://journalxp-4ea0f.web.app/apiOption 1: Full Stack Development
Terminal 1 - Start Functions Emulator:
npm run emulators
# Or: firebase emulators:start --only functionsTerminal 2 - Start Frontend Dev Server:
npm run dev:front
# Or: cd frontend && npm run devOption 2: Frontend Only
If you're only working on frontend features:
cd frontend && npm run dev- Frontend: http://localhost:5173
- Functions Emulator: http://localhost:5002
- Emulator UI: http://localhost:4000
Understanding the codebase:
JournalXP/
├── frontend/ # React + Vite frontend
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── features/ # Feature modules (habits, journal, etc.)
│ │ ├── pages/ # Route-level components
│ │ ├── context/ # React contexts
│ │ ├── lib/ # Utilities, Firebase config, API helpers
│ │ └── App.tsx # Main app component with routing
│ └── package.json
│
├── functions/ # Firebase Cloud Functions
│ ├── src/
│ │ ├── routes/ # Express API endpoints
│ │ ├── middleware/ # Auth, error handling
│ │ ├── lib/ # Firebase Admin SDK, utilities
│ │ ├── scripts/ # Migration and maintenance scripts
│ │ └── index.ts # Cloud Function entry point
│ └── package.json
│
├── shared/ # Shared TypeScript code
│ ├── types/ # Common type definitions
│ └── utils/ # Shared utility functions
│
└── backend/ # Legacy server (archival, avoid editing)Both frontend and functions use TypeScript path aliases:
@/*→ Points tosrc/directory@shared/*→ Points to../shared/for shared types
Example:
import { UserClient } from "@shared/types/user";
import { authFetch } from "@/lib/authFetch";- Always use TypeScript - No plain JavaScript files
- Define types explicitly - Avoid
anyunless absolutely necessary - Use shared types - Import from
@shared/typeswhen applicable - Interface over Type - Prefer interfaces for object shapes
Example:
// Good
interface HabitFormData {
title: string;
frequency: "daily" | "weekly";
xpReward: number;
}
// Avoid
const createHabit = (data: any) => { ... }- Functional components - Use hooks, avoid class components
- TypeScript for props - Always type your component props
- Destructure props - For cleaner code
- Use contexts - For auth and user data
Example:
interface TaskCardProps {
task: Task;
onComplete: (taskId: string) => void;
}
export const TaskCard: React.FC<TaskCardProps> = ({ task, onComplete }) => {
// Component logic
};- ESLint - Follow the project's ESLint configuration
- Prettier - Use Prettier for consistent formatting
- Naming conventions:
- Components:
PascalCase(e.g.,TaskCard.tsx) - Utilities:
camelCase(e.g.,authFetch.ts) - Constants:
UPPER_SNAKE_CASE(e.g.,MAX_LEVEL) - Types/Interfaces:
PascalCase(e.g.,UserClient)
- Components:
We follow Conventional Commits for clear git history:
feat:- New featurefix:- Bug fixdocs:- Documentation changesstyle:- Code style changes (formatting, no logic change)refactor:- Code refactoringtest:- Adding or updating testschore:- Maintenance tasks, dependency updates
# Feature
git commit -m "feat(habits): add streak counter to habit cards"
# Bug fix
git commit -m "fix(auth): resolve token refresh issue on session timeout"
# Documentation
git commit -m "docs: update README with deployment instructions"
# Refactor
git commit -m "refactor(tasks): simplify task completion logic"Common scopes:
frontend/backend/functions/shared- Feature names:
habits,journal,tasks,pet,auth - Components:
ui,layout,forms
Functions:
cd functions
# Run all tests
npm test
# Watch mode
npm run test:watch
# With coverage
npm run test:coverageFrontend:
cd frontend
npm testFunctions (Jest + Supertest):
import request from "supertest";
import app from "../app";
describe("POST /api/habits", () => {
it("should create a new habit", async () => {
const response = await request(app)
.post("/api/habits")
.set("Authorization", `Bearer ${validToken}`)
.send({ title: "Meditation", frequency: "daily" });
expect(response.status).toBe(201);
expect(response.body.habit).toHaveProperty("id");
});
});Always run type checks before committing:
# Frontend
cd frontend && npm run build
# Functions
cd functions && npm run es-checkCreate a descriptive branch name:
# Feature branch
git checkout -b feature/habit-streak-notifications
# Bug fix branch
git checkout -b fix/journal-entry-validation
# Documentation branch
git checkout -b docs/api-endpoint-guide- Sync with upstream:
git fetch upstream
git rebase upstream/main- Run tests:
cd functions && npm test
cd frontend && npm test- Type check:
cd functions && npm run es-check
cd frontend && npm run build- Build locally:
npm run build- Test with emulators:
npm run emulators:allWhen opening a PR, include:
Title: Follow conventional commits format
feat(habits): add weekly habit summary viewDescription:
## What does this PR do?
Brief description of changes
## Why?
Problem this solves or feature it adds
## Testing
- [ ] Unit tests added/updated
- [ ] Tested locally with emulators
- [ ] Type checks pass
- [ ] No console errors
## Screenshots (if applicable)
[Add screenshots for UI changes]
## Related Issues
Closes #123- Code follows the project's coding guidelines
- Self-review completed
- Comments added for complex logic
- Tests added/updated
- Documentation updated (if needed)
- No console warnings or errors
- Builds successfully
- Tested in local environment
- Functionality: Does it work as intended?
- Code quality: Is it readable and maintainable?
- Performance: Any performance concerns?
- Security: No vulnerabilities or data leaks?
- Tests: Adequate test coverage?
- Documentation: Clear comments and updated docs?
- Be open to suggestions
- Ask questions if feedback is unclear
- Make requested changes in new commits
- Notify reviewers when ready for re-review
Look for issues labeled good first issue:
- Documentation improvements
- UI/UX enhancements
- Bug fixes
- Adding tests
Check the Future Features section in README.md:
- Dark mode implementation
- Advanced meditation tools
- Mobile UI improvements
- Analytics features
Found a bug? Open an issue with:
- Clear description
- Steps to reproduce
- Expected vs actual behavior
- Environment details (browser, OS, etc.)
- Be respectful and inclusive
- Help others learn and grow
- Give constructive feedback
- Celebrate contributions, big and small
If you have questions:
- Open a GitHub Discussion
- Check existing issues
- Reach out to maintainers
Thank you for contributing to JournalXP! Together, we're building a platform that makes mental health journaling accessible and engaging. 💙