Getting Started with LBS Foundry¶
Welcome to the LBS Foundry development team! This guide will get you up and running with the codebase in no time.
Prerequisites¶
Before you begin, ensure you have the following tools installed:
Required Tools¶
- .NET 10 SDK - Backend development
- Node.js 18+ - Frontend development
- pnpm - Package manager (
npm install -g pnpm) - Git - Version control
- PostgreSQL 14+ - Database
Recommended Tools¶
- Visual Studio 2022 or VS Code - IDE
- Git Extensions - Git GUI
- Docker Desktop - Containerization (optional)
- Postman - API testing
Tip: See prerequisites.md for detailed installation instructions.
Quick Setup (5 minutes)¶
1. Clone the Repository¶
2. Setup Backend¶
# Restore dependencies
dotnet restore LBS.slnx
# Build the solution
dotnet build LBS.slnx
# Run unit tests to verify setup (xUnit v3 — use `dotnet run`, not `dotnet test`)
dotnet run --project src/Tests/LBS.UnitTests/LBS.UnitTests.csproj
3. Setup Frontend (foundry-web)¶
The frontend uses a local TypeScript SDK that must be built before running.
# From repo root - install dependencies and establish workspace links
pnpm install
# Build .NET, generate SDK types, and compile TypeScript SDK
pnpm sdk:refresh
This builds the @luckboxstudios/foundry-sdk package that foundry-web depends on.
Note: You must run
pnpm sdk:refreshwhenever C# contracts change, or after a fresh clone.
4. Configure Database¶
There is no separate migration step. Marten applies the schema automatically on application startup (ApplyAllDatabaseChangesOnStartup() with AutoCreate.All), so the schema is created/updated when a host such as the API starts. Just ensure PostgreSQL is running and the connection string is configured before starting the development environment below.
5. Start Development Environment¶
# Start the Aspire development host (includes all services)
dotnet run --project src/Aspire/LBS.AspireHost/LBS.AspireHost.csproj
That's it! Your development environment should now be running.
Accessing the Applications¶
Once started, you can access:
- Aspire Dashboard: http://localhost:15000 - Service monitoring
- API: http://localhost:5000 - Backend API
- Frontend: http://localhost:5173 - foundry-web (SvelteKit)
- API Docs: http://localhost:5000/swagger - OpenAPI documentation
What's Next?¶
- Architecture Overview — system design, event sourcing, CQRS
- Event Sourcing Guide
- Common Development Tasks — adding queries, commands, importers
- Coding Standards
- Security System
- SDK Local Development — for frontend work
Development Workflow¶
Daily Development¶
# Start development environment
dotnet run --project src/Aspire/LBS.AspireHost/LBS.AspireHost.csproj
# In a separate terminal - Frontend development (from repo root)
pnpm web:dev
# Run tests before committing (xUnit v3 — use `dotnet run`, not `dotnet test`)
dotnet run --project src/Tests/LBS.UnitTests/LBS.UnitTests.csproj
Making Changes¶
- Create a feature branch:
git checkout -b feature/your-feature - Make your changes following our coding standards
- Run tests:
dotnet run --project src/Tests/LBS.UnitTests/LBS.UnitTests.csproj - Commit changes: Use conventional commits
- Create pull request
Authentication Setup¶
The system supports two authentication methods:
1. Clerk Authentication (Human Users)¶
- Used in the frontend application
- JWT-based authentication
- User management handled by Clerk
2. Basic Authentication (Service Accounts)¶
- Used for API access and testing
- Create service accounts programmatically
- See Authentication Guide
Testing Authentication: For a complete guide on testing authentication end-to-end, see Authentication Testing Guide.
Key Concepts to Understand¶
Event Sourcing¶
- All state changes are stored as events
- Complete audit trail and replay capability
- See Event Sourcing Guide
CQRS (Command Query Responsibility Segregation)¶
- Separate models for reading and writing
- Optimized for different use cases
- See Query/Command Alignment Design
Role-based Authorization¶
- Commands and queries can require specific roles
- Automatic authorization enforcement
- See Security Guide
Troubleshooting¶
Common Issues¶
Build Errors
Database Issues
# Recreate the database, then start a host (e.g. LBS.Api) — Marten applies the
# schema automatically on startup via ApplyAllDatabaseChangesOnStartup().
dropdb lbs_foundry_dev
createdb lbs_foundry_dev
dotnet run --project src/Apps/LBS.Api/LBS.Api.csproj
Frontend Issues
# Rebuild the SDK (most common fix)
pnpm sdk:refresh
# Or clear and reinstall everything
rm -rf node_modules sdk/typescript/node_modules src/Apps/foundry-web/node_modules
pnpm install
pnpm sdk:refresh
Complete Troubleshooting Guide
Getting Help¶
- Team Chat: Ask questions in the development channel
- Documentation: Browse our developer guides
- Issues: Report bugs in the project repository
- FAQ: Check our Frequently Asked Questions
Welcome to the Team!¶
You're now ready to start contributing to LBS Foundry! Here are some good first tasks:
- Explore the codebase - Look at existing commands, queries, and aggregates
- Run the test suite - Understand how we test our code
- Try making a small change - Add a simple query or command
- Review our coding standards - Learn our conventions
Happy coding!