- Node.js 22+ (Download)
- .NET 10 SDK (Download)
- Docker (for PostgreSQL and full-stack development) (Download)
- Git (Download)
git clone https://github.com/your-org/perfectfit.git
cd perfectfit# Start PostgreSQL only
docker compose up -d postgres
# Or start the full stack (PostgreSQL + Backend + Frontend)
docker compose up -d
# Verify services are running
docker compose psFull Stack URLs:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080
- PostgreSQL: localhost:5432
cd backend/src/PerfectFit.Web
# Initialize user secrets
dotnet user-secrets init
# Set required secrets
dotnet user-secrets set "Jwt:Secret" "your-secret-key-at-least-32-characters-long"
# Configure Microsoft OAuth (optional - needed for Microsoft sign-in)
dotnet user-secrets set "OAuth:Microsoft:ClientId" "your-microsoft-client-id"
dotnet user-secrets set "OAuth:Microsoft:ClientSecret" "your-microsoft-client-secret"Note: PerfectFit supports three authentication methods:
- Local auth (email/password) - works out of the box
- Microsoft OAuth - requires Azure AD app registration
- Guest - no configuration needed
cd backend
dotnet run --project src/PerfectFit.WebBackend will be available at:
- API: http://localhost:5050 (local dev) or http://localhost:8080 (Docker)
- Swagger: http://localhost:5050/swagger
For quick testing or development without setting up PostgreSQL, you can run the backend with in-memory storage:
cd backend
# Using environment variable
ASPNETCORE_ENVIRONMENT=InMemory dotnet run --project src/PerfectFit.Web
# Or using launch profile (if using VS Code or Visual Studio)
dotnet run --project src/PerfectFit.Web --launch-profile inmemoryNote: In-memory mode uses appsettings.InMemory.json configuration. Data is stored in memory and will be lost when the application restarts. This mode is useful for:
- Frontend development without database setup
- Quick API testing
- Demo purposes
- CI/CD pipelines
You can also enable in-memory mode in any environment by setting UseInMemoryStorage: true in your configuration or environment variables.
cd frontend
# Install dependencies
npm install
# Start development server
npm run devFrontend will be available at http://localhost:3000.
PerfectFit/
├── backend/ # ASP.NET Core backend
├── frontend/ # Next.js frontend
├── docs/ # Documentation
├── plans/ # Project planning
└── docker-compose.yml # Database setup
Open two terminals:
Terminal 1 - Backend:
cd backend
dotnet watch --project src/PerfectFit.WebTerminal 2 - Frontend:
cd frontend
npm run devcd backend
# Run all tests
dotnet test
# Run with verbosity
dotnet test --verbosity normal
# Run specific test project
dotnet test tests/PerfectFit.UnitTests
dotnet test tests/PerfectFit.IntegrationTests
# Run with coverage
dotnet test --collect:"XPlat Code Coverage"cd frontend
# Run linter
npm run lint
# Run tests (when configured)
npm test- Use PascalCase for public members
- Use _camelCase for private fields
- Follow .NET naming conventions
- Use async/await for all I/O operations
- Use meaningful variable names
// Good
public async Task<GameSession> CreateGameAsync(int? userId)
{
var session = GameSession.Create(userId);
await _repository.AddAsync(session);
return session;
}
// Bad
public GameSession Create(int? id)
{
var s = GameSession.Create(id);
_repo.Add(s);
return s;
}- Use camelCase for variables and functions
- Use PascalCase for components and types
- Prefer functional components with hooks
- Use TypeScript strict mode
// Good
interface GameBoardProps {
grid: Grid;
onCellClick: (row: number, col: number) => void;
}
const GameBoard: FC<GameBoardProps> = ({ grid, onCellClick }) => {
// ...
};
// Bad
const gameboard = (props) => {
// ...
};feature/description- New featuresfix/description- Bug fixesrefactor/description- Code refactoringdocs/description- Documentation updates
Use conventional commits:
feat: add leaderboard submission
fix: resolve piece placement validation
docs: update API documentation
refactor: simplify game engine
test: add integration tests for auth
- Create feature branch from
main - Make changes
- Run tests
- Create PR with description
- Address review feedback
- Merge after approval
VS Code:
- Open
backend/folder - Press F5 to start debugging
- Set breakpoints as needed
Visual Studio:
- Open
PerfectFit.sln - Press F5 to debug
- Use breakpoints and watch windows
Logging:
_logger.LogInformation("Creating game for user {UserId}", userId);
_logger.LogError(ex, "Failed to place piece");Browser DevTools:
- React DevTools for component inspection
- Network tab for API requests
- Console for errors and logs
VS Code:
- Add breakpoints in TypeScript files
- Use Chrome DevTools with source maps
Debug Logging:
console.log('Game state:', useGameStore.getState());
console.log('API response:', response);- Create command/query in
PerfectFit.UseCases - Add endpoint in
PerfectFit.Web/Endpoints - Update Swagger documentation
- Add tests
- Create component in
frontend/src/components/ - Add TypeScript types
- Export from index file
- Add to page/layout
cd backend/src/PerfectFit.Web
dotnet ef migrations add MigrationName \
--project ../PerfectFit.Infrastructure
dotnet ef database update \
--project ../PerfectFit.InfrastructureBackend:
cd backend
dotnet restore
dotnet outdated # if dotnet-outdated is installedFrontend:
cd frontend
npm outdated
npm updateSystem.InvalidOperationException: Unable to resolve service
Solution: Check dependency injection in Program.cs and DependencyInjection.cs.
Npgsql.NpgsqlException: Failed to connect
Solution: Ensure Docker is running: docker compose up -d
TypeError: Failed to fetch
Solution:
- Check backend is running
- Verify
NEXT_PUBLIC_API_URLin.env.local - Check CORS configuration
401 Unauthorized
Solution:
- Clear browser localStorage
- Login again
- Check JWT secret is configured
Backend:
- C# Dev Kit
- .NET Extension Pack
Frontend:
- ESLint
- Prettier
- Tailwind CSS IntelliSense
- TypeScript Vue Plugin (Volar)
{
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"[csharp]": {
"editor.defaultFormatter": "ms-dotnettools.csdevkit"
},
"typescript.tsdk": "frontend/node_modules/typescript/lib"
}Open backend/PerfectFit.sln for the best C# development experience.