Developer DocumentationΒΆ
Everything you need to develop, test, and contribute to ReViewPoint.
π Quick Start (30 seconds)ΒΆ
# Clone and start everything
git clone https://github.com/filip-herceg/ReViewPoint.git
cd ReViewPoint
pnpm run dev:postgres # Starts everything: DB + Backend + Frontend
π Access Your Development Environment:
- π± Main Application: http://localhost:5173 β Start here!
- π Documentation Site: http://127.0.0.1:8001/ReViewPoint/
- π§ Backend API: http://localhost:8000
- π API Docs (Swagger): http://localhost:8000/docs
π Essential ResourcesΒΆ
- Development Guidelines
Code standards, testing, Git workflow, environment setup
- Testing Guide
Backend tests, frontend tests, E2E tests, coverage reports
- API Reference
Complete REST API documentation with examples
- Contributing
How to contribute code, documentation, and report issues
- FAQ
Common questions, troubleshooting, and solutions
- Architecture Deep Dive
Backend and frontend architecture, code organization
ποΈ Architecture OverviewΒΆ
Tech StackΒΆ
Layer | Technology | Purpose |
---|---|---|
Frontend | React 18 + TypeScript + Vite | Modern UI with hot reload |
Backend | FastAPI + Python 3.11+ | High-performance async API |
Database | PostgreSQL / SQLite | Reliable data persistence |
Testing | Pytest + Vitest + Playwright | Comprehensive test coverage |
CI/CD | GitHub Actions | Automated quality gates |
Project StructureΒΆ
ReViewPoint/
βββ backend/ # FastAPI backend
β βββ src/ # Source code
β βββ tests/ # Backend tests (135+ tests)
β βββ alembic/ # Database migrations
βββ frontend/ # React frontend
β βββ src/ # Source code
β βββ tests/ # Frontend tests (672+ tests)
β βββ e2e/ # End-to-end tests
βββ docs/ # Documentation (you are here!)
Development WorkflowΒΆ
graph LR
A[Clone Repo] --> B[Run pnpm run dev:postgres]
B --> C[Backend: localhost:8000]
B --> D[Frontend: localhost:5173]
C --> E[Make Changes]
D --> E
E --> F[Run Tests]
F --> G[Submit PR]
β‘ VS Code IntegrationΒΆ
ReViewPoint includes 24 VS Code tasks for streamlined development:
Most Used TasksΒΆ
ReViewPoint: Start Development
- Full stack with PostgreSQLReViewPoint: Run All Tests
- Backend + Frontend testsReViewPoint: Install Dependencies
- One-command setupReViewPoint: Format All Code
- Backend + Frontend formatting
Access via Ctrl+Shift+P
β "Tasks: Run Task"
π§ͺ Testing StrategyΒΆ
Test Type | Framework | Coverage | Command |
---|---|---|---|
Backend Unit | pytest | 86%+ | pnpm run test:backend |
Frontend Unit | Vitest | 80%+ | cd frontend && pnpm test |
E2E Tests | Playwright | Critical paths | cd frontend && pnpm run test:e2e |
All Tests | Combined | Full suite | pnpm run test:all |
π§ Development EnvironmentΒΆ
PrerequisitesΒΆ
- Node.js 18+ with pnpm 8+
- Python 3.11+ with Hatch
- Docker (for PostgreSQL)
- VS Code (recommended)
Database OptionsΒΆ
# Option 1: SQLite (simple, no Docker)
pnpm run dev
# Option 2: PostgreSQL (production-like)
pnpm run dev:postgres
Hot Reload DevelopmentΒΆ
Both backend and frontend support hot reload:
- Backend: FastAPI auto-reloads on Python file changes
- Frontend: Vite HMR for instant React updates
- Database: Automatic migrations on startup
π― Common Development TasksΒΆ
Adding a New FeatureΒΆ
- Create feature branch:
git checkout -b feature/your-feature
- Backend changes: Add to
backend/src/
- Frontend changes: Add to
frontend/src/
- Write tests: Backend in
backend/tests/
, Frontend infrontend/tests/
- Test locally:
pnpm run test:all
- Submit PR: Follow Contributing Guidelines
DebuggingΒΆ
# Backend debugging with logs
cd backend && hatch run python -m debugpy --listen 5678 --wait-for-client -m uvicorn src.main:app --reload
# Frontend debugging
cd frontend && pnpm run dev --debug
# Database debugging
pnpm run db:reset # Reset and rebuild database
Code QualityΒΆ
# Lint and format everything
pnpm run lint:all
pnpm run format:all
# Type checking
cd backend && hatch run mypy src/
cd frontend && pnpm run type-check
π Production DeploymentΒΆ
ReViewPoint is production-ready with:
- Docker containerization for easy deployment
- Environment-specific configs for dev/staging/prod
- Automated CI/CD with GitHub Actions
- Health checks and monitoring endpoints
- Security best practices (JWT, rate limiting, CORS)
π‘ Getting HelpΒΆ
Stuck? Here's where to get help:
- Check the FAQ - Common issues and solutions
- Browse Testing Guide - For test-related questions
- Review Contributing Guide - For contribution process
- Create GitHub Issue - For bugs or feature requests
- Search the codebase - Well-documented inline comments
Ready to contribute? Start with the Contributing Guide and make your first PR!
Architecture OverviewΒΆ
ReViewPoint follows a modern full-stack architecture with clear separation of concerns:
graph TB
subgraph "Frontend Layer"
UI[React/TypeScript UI]
Components[Component Library]
State[Zustand State Management]
end
subgraph "API Layer"
REST[FastAPI REST API]
Auth[JWT Authentication]
Upload[File Upload Service]
end
subgraph "Data Layer"
DB[(PostgreSQL Database)]
Files[File Storage System]
Cache[Redis Cache]
end
UI --> REST
Components --> REST
State --> REST
REST --> DB
REST --> Files
REST --> Cache
Core Design PrinciplesΒΆ
- Type Safety First: Full TypeScript coverage with strict checking
- Test-Driven Development: Comprehensive test suites for all components
- Performance Optimized: Async/await patterns, optimized queries, hot reload
- Developer Experience: Automated workflows, comprehensive tooling, clear documentation
- Production Ready: Docker containers, environment management, CI/CD ready
Project Structure Deep DiveΒΆ
Root Directory LayoutΒΆ
ReViewPoint/
βββ backend/ # FastAPI Python backend
βββ frontend/ # React TypeScript frontend
βββ docs/ # Documentation (MkDocs)
βββ scripts/ # Development automation
βββ tests/ # Integration tests
βββ uploads/ # File upload storage
βββ package.json # Root workspace configuration
Backend Architecture (backend/
)ΒΆ
The backend follows a layered architecture pattern:
backend/
βββ src/
β βββ api/ # FastAPI route handlers
β β βββ auth.py # Authentication endpoints
β β βββ users.py # User management
β β βββ uploads.py # File upload endpoints
β βββ core/ # Core application logic
β β βββ auth.py # Authentication service
β β βββ cache.py # Caching layer
β β βββ config.py # Configuration management
β βββ models/ # SQLAlchemy database models
β β βββ user.py # User model
β β βββ file.py # File model
β β βββ base.py # Base model class
β βββ repositories/ # Data access layer
β βββ schemas/ # Pydantic request/response schemas
β βββ services/ # Business logic layer
β βββ main.py # FastAPI application entry point
βββ tests/ # Backend tests (135+ tests)
βββ config/ # Environment configuration
βββ deployment/ # Docker and deployment configs
Key Backend TechnologiesΒΆ
- FastAPI: Modern, fast web framework for building APIs
- SQLAlchemy 2.0: Modern Python SQL toolkit with async support
- Alembic: Database migration tool
- PostgreSQL: Primary production database
- JWT: Secure authentication with token-based auth
- Pytest: Comprehensive testing framework
Frontend Architecture (frontend/
)ΒΆ
The frontend uses a component-based architecture:
frontend/
βββ src/
β βββ components/ # Reusable UI components
β β βββ ui/ # Basic UI elements
β β βββ layout/ # Layout components
β β βββ auth/ # Authentication components
β β βββ uploads/ # File upload components
β βββ pages/ # Route-level components
β βββ lib/ # Core libraries and utilities
β β βββ api/ # API client configuration
β β βββ auth/ # Authentication logic
β β βββ utils/ # Helper functions
β βββ hooks/ # Custom React hooks
β βββ types/ # TypeScript type definitions
β βββ App.tsx # Main application component
βββ tests/ # Frontend tests
βββ e2e/ # End-to-end tests (Playwright)
Key Frontend TechnologiesΒΆ
- React 18: Modern React with concurrent features
- TypeScript: Type-safe JavaScript development
- Vite: Fast build tool and development server
- Tailwind CSS: Utility-first CSS framework
- Zustand: Lightweight state management
- React Router: Client-side routing
- Vitest: Fast unit testing framework
- Playwright: End-to-end testing
Development WorkflowsΒΆ
Daily DevelopmentΒΆ
We've automated the most common development tasks through VS Code tasks and npm scripts:
Start Complete Development EnvironmentΒΆ
# Option 1: PostgreSQL (recommended)
pnpm run dev:postgres
# Option 2: SQLite (simpler, no Docker required)
pnpm run dev
Backend DevelopmentΒΆ
# Start backend only
pnpm run backend
# Run tests (fast SQLite mode)
cd backend && hatch run fast:test
# Run tests (full PostgreSQL mode)
cd backend && hatch run pytest
# Lint and format
cd backend && hatch run ruff check . --fix
cd backend && hatch run ruff format .
Frontend DevelopmentΒΆ
# Start frontend only
cd frontend && pnpm run dev
# Run tests
cd frontend && pnpm run test
# Lint and format
cd frontend && pnpm run lint
cd frontend && pnpm run format
# Type checking
cd frontend && pnpm run type-check
Testing StrategyΒΆ
We maintain comprehensive testing at multiple levels:
Backend Testing (135+ tests)ΒΆ
- Fast Tests (SQLite in-memory, 30-60 seconds)
- Full Tests (PostgreSQL, 2-5 minutes)
- Coverage Reports
Frontend TestingΒΆ
- Unit Tests (Vitest)
- E2E Tests (Playwright)
- Coverage Reports
VS Code IntegrationΒΆ
We provide 28 pre-configured VS Code tasks for all development operations:
Most Used TasksΒΆ
- ReViewPoint: Start Both (Backend + Frontend) - PostgreSQL (Default, Ctrl+Shift+P β "Tasks: Run Task")
- ReViewPoint: Run All Tests
- ReViewPoint: Lint Backend
- ReViewPoint: Lint Frontend
Complete Task CategoriesΒΆ
- Development Tasks (4): Starting services
- Testing Tasks (7): All types of test execution
- Quality Tasks (5): Linting, formatting, type checking
- Build Tasks (4): Production builds
- Database Tasks (6): Migrations, switching databases
- Utility Tasks (2): Dependency management, cleaning
Database ArchitectureΒΆ
Schema DesignΒΆ
Our database follows normalized design principles with clear relationships:
erDiagram
User {
uuid id PK
string username UK
string email UK
string password_hash
enum role
timestamp created_at
timestamp updated_at
}
File {
uuid id PK
uuid user_id FK
string filename
string content_type
integer file_size
string file_path
timestamp uploaded_at
}
UsedPasswordResetToken {
uuid id PK
uuid user_id FK
string token_hash
timestamp used_at
}
User ||--o{ File : uploads
User ||--o{ UsedPasswordResetToken : uses
Migration ManagementΒΆ
We use Alembic for database versioning:
# Create new migration
cd backend && hatch run alembic revision --autogenerate -m "Description"
# Apply migrations
cd backend && hatch run alembic upgrade head
# View migration history
cd backend && hatch run alembic history
Database SwitchingΒΆ
Easy switching between development databases:
# Switch to PostgreSQL (production-like)
pnpm run db:postgres
# Switch to SQLite (simpler development)
pnpm run db:sqlite
API Design & DocumentationΒΆ
API ArchitectureΒΆ
Our API follows RESTful principles with comprehensive documentation:
- Base URL:
http://localhost:8000/api/v1
- Authentication: JWT Bearer tokens
- Documentation: Auto-generated OpenAPI/Swagger at
/docs
- Response Format: Consistent JSON with proper HTTP status codes
API Endpoints OverviewΒΆ
Authentication (/auth
)ΒΆ
POST /auth/register
- User registrationPOST /auth/login
- User loginPOST /auth/refresh
- Token refreshPOST /auth/logout
- User logoutPOST /auth/password-reset-request
- Request password resetPOST /auth/password-reset-confirm
- Confirm password reset
Users (/users
)ΒΆ
GET /users/me
- Get current user profilePUT /users/me
- Update current user profileGET /users/{user_id}
- Get user by ID (admin)GET /users/
- List users (admin)
File Uploads (/uploads
)ΒΆ
POST /uploads/
- Upload fileGET /uploads/{file_id}
- Get file metadataGET /uploads/{file_id}/download
- Download fileDELETE /uploads/{file_id}
- Delete file
Type SafetyΒΆ
We generate TypeScript types from the OpenAPI schema:
This ensures compile-time type safety between frontend and backend.
Security ImplementationΒΆ
Authentication & AuthorizationΒΆ
- JWT Tokens: Secure token-based authentication
- Password Security: Bcrypt hashing with proper salting
- Role-Based Access Control (RBAC): User roles and permissions
- Token Refresh: Secure token rotation
- Password Reset: Secure password reset flow with token invalidation
File Upload SecurityΒΆ
- File Type Validation: Strict file type checking
- File Size Limits: Configurable upload size limits
- Virus Scanning: Integration points for virus scanning
- Access Control: File access based on user permissions
- Secure Storage: Files stored outside web root
API SecurityΒΆ
- Input Validation: Pydantic schema validation
- SQL Injection Prevention: SQLAlchemy parameterized queries
- CORS Configuration: Properly configured CORS policies
- Rate Limiting: API rate limiting (configurable)
- HTTPS Enforcement: Production HTTPS configuration
Performance & OptimizationΒΆ
Backend PerformanceΒΆ
- Async Operations: Full async/await pattern usage
- Database Optimization: Optimized queries, connection pooling
- Caching Layer: Redis integration for session and data caching
- Background Tasks: Celery integration for async task processing
Frontend PerformanceΒΆ
- Code Splitting: Automatic route-based code splitting
- Bundle Optimization: Vite-optimized bundling
- Lazy Loading: Component and route lazy loading
- Image Optimization: Optimized image loading and caching
Contributing GuidelinesΒΆ
Code StandardsΒΆ
- Type Safety: All code must be fully typed
- Test Coverage: All new features require tests
- Documentation: All public APIs must be documented
- Code Review: All changes require review
- Linting: Code must pass all linting checks
Development ProcessΒΆ
- Feature Branches: Work on feature branches
- Commit Messages: Use conventional commit format
- Pull Requests: Use PR templates
- Testing: All tests must pass
- Documentation: Update docs with changes
Getting HelpΒΆ
- Documentation: Start with this documentation
- Code Examples: Check existing code patterns
- Issues: Create GitHub issues for bugs
- Discussions: Use GitHub discussions for questions
- Code Review: Request reviews early and often
Troubleshooting Common IssuesΒΆ
Database IssuesΒΆ
PostgreSQL won't start:
Migration errors:
# Reset database (destroys data!)
cd backend && hatch run alembic downgrade base
cd backend && hatch run alembic upgrade head
Development Server IssuesΒΆ
Port conflicts:
- Backend: Change port in
backend/config/.env
- Frontend: Change port in
frontend/vite.config.ts
Hot reload not working:
- Restart the development server
- Check file watchers (VS Code settings)
Testing IssuesΒΆ
Tests failing:
# Clear test cache
cd backend && hatch run pytest --cache-clear
# Reset test database
cd backend && hatch run fast:test --create-db
Next StepsΒΆ
For New DevelopersΒΆ
- Setup: Follow the Installation Guide
- Architecture: Read the Backend and Frontend documentation
- Testing: Review the Testing Guide
- Contributing: Check the Contributing Guidelines
For Advanced UsersΒΆ
- Deployment: Review deployment documentation
- Performance: Study performance optimization guides
- Security: Understand security implementation details
- Scaling: Learn about horizontal scaling options
This developer overview provides the foundation for understanding and contributing to ReViewPoint. For specific technical details, explore the linked documentation sections.