Installation Guide
This guide will help you set up Accountability for local development.Prerequisites
Before you begin, ensure you have the following installed:- Node.js: v20 or higher
- pnpm: v10.17.1 or higher (package manager)
- Docker: Latest version (for testcontainers during testing)
- Git: For cloning the repository
Quick Start
Install Dependencies
Use pnpm to install all dependencies:This installs dependencies for all packages in the monorepo:
packages/core- Core accounting logic (Effect)packages/persistence- Database layer (@effect/sql + PostgreSQL)packages/api- Effect HttpApi serverpackages/web- React UI (TanStack Start)
The project uses pnpm workspaces. The root
package.json specifies the exact package manager version: [email protected]Start Development Server
Run the development server:This starts:
- TanStack Start development server on
http://localhost:3000 - Hot module reloading (HMR) for frontend and API
- Automatic route generation
The dev server runs the full-stack application. No separate backend server is needed.
Project Structure
Understand the monorepo layout:Database Setup
Accountability uses PostgreSQL with automatic schema migration.Automated Testing Database
For unit and integration tests, the database is managed automatically:Testcontainers
The test suite uses testcontainers to automatically:
- Start a PostgreSQL container before tests
- Run migrations to create schema
- Execute tests
- Tear down container after tests
Development Database (Optional)
For local development with persistent data, you can set up a PostgreSQL database:Configure Connection
Set the
DATABASE_URL environment variable:.env
The application will use this connection string if provided. Otherwise, it uses the testcontainer instance.
Run Migrations
Migrations run automatically when the application starts. You can also run them manually:Available migrations:
Migration0001_CreateOrganizations- Organizations tableMigration0002_CreateCompanies- Companies tableMigration0003_CreateAccounts- Chart of accountsMigration0004_CreateFiscalPeriods- Fiscal periodsMigration0005_CreateJournalEntries- Journal entries and linesMigration0006_CreateExchangeRates- Currency exchange ratesMigration0007_CreateConsolidation- Consolidation groupsMigration0008_CreateIntercompany- Intercompany transactionsMigration0009_CreateConsolidationRuns- Consolidation runsMigration0010_CreateAuthUsers- Authentication usersMigration0011_CreateAuthIdentities- User identitiesMigration0012_CreateAuthSessions- User sessionsMigration0013_CreateAuditLog- Audit logMigration0017_CreateAuthorization- Authorization policies
Running Tests
Accountability has comprehensive test coverage.Unit and Integration Tests
Tests use Vitest with Effect testing utilities (
@effect/vitest). The test suite automatically:- Starts PostgreSQL testcontainer
- Runs migrations
- Executes tests
- Tears down container
End-to-End Tests
E2E tests use Playwright:Code Generation
Accountability uses code generation for routes and API clients.Generate Routes
TanStack Router uses file-based routing with generated route tree:packages/web/src/routeTree.gen.ts from files in packages/web/src/routes/.
Routes are automatically regenerated during development with HMR. Manual generation is only needed after adding new route files.
Generate API Client
The typed API client is generated from the OpenAPI spec:packages/web/src/api/schema.ts from the Effect HttpApi OpenAPI export.
Development Workflow
Making Changes
Backend Changes (Effect)
When modifying core business logic:
- Edit files in
packages/core/src/ - Write tests in
packages/core/test/ - Run tests:
pnpm test - Ensure 100% test coverage for new code
Backend uses Effect. Read
specs/guides/effect-guide.md for patterns and best practices.Database Changes
When modifying the database schema:
- Create new migration in
packages/persistence/src/Migrations/ - Name it
Migration####_Description.ts(next sequential number) - Write migration using
@effect/sql - Export from
packages/persistence/package.json - Update repository in
packages/persistence/src/Services/
API Changes
When adding/modifying endpoints:
- Define schemas in
packages/api/src/schemas/ - Implement endpoint in
packages/api/src/endpoints/ - Register in API builder
- Regenerate OpenAPI client:
pnpm generate:api
API uses Effect HttpApi. Read
specs/guides/api-guide.md for conventions.Frontend Changes
When modifying the UI:
- Edit components in
packages/web/src/components/ - Edit routes in
packages/web/src/routes/ - Use
api.GET()/api.POST()for API calls - Use loaders for SSR data fetching
- Write E2E tests in
packages/web/test/e2e/
Frontend uses React + TanStack Start. Read
specs/guides/frontend-guide.md for patterns.Code Quality
Building for Production
Environment Variables
Accountability uses environment variables for configuration:| Variable | Description | Default |
|---|---|---|
DATABASE_URL | PostgreSQL connection string | Testcontainer (in tests) |
PORT | Server port | 3000 |
NODE_ENV | Environment (development/production) | development |
SESSION_SECRET | Secret for session signing | (required in production) |
Troubleshooting
Port Already in Use
Database Connection Failed
Tests Hanging
Type Errors After API Changes
Next Steps
Effect Guide
Learn Effect patterns for backend development
specs/guides/effect-guide.mdFrontend Guide
React and TanStack Start patterns
specs/guides/frontend-guide.mdTesting Guide
Unit, integration, and E2E testing
specs/guides/testing-guide.mdAPI Guide
Effect HttpApi conventions
specs/guides/api-guide.mdAdditional Resources
Read the Specs
All specifications are in thespecs/ directory:
- Guides: How-to documentation for development
- Architecture: System design and domain model
- Pending: Features not yet implemented
- Completed: Historical reference for completed work
Key Files
| File | Purpose |
|---|---|
CLAUDE.md | Claude Code development guide |
package.json | Workspace scripts and dependencies |
vitest.config.ts | Test configuration |
tsconfig.json | TypeScript compiler options |
External Documentation
- Effect Documentation
- TanStack Start Documentation
- TanStack Router Documentation
- @effect/sql Documentation
- Vitest Documentation
- Playwright Documentation
Reference repositories are available in
repos/ directory:repos/effect/- Effect-TS source coderepos/tanstack-router/- TanStack Router/Start source code