Overview
This guide will walk you through setting up Happy Habitat from scratch, including database configuration, backend setup, frontend deployment, and creating your first admin account.This quickstart assumes you’re setting up a development environment. For production deployment, see the production notes at the end of this guide.
Prerequisites
Before you begin, ensure you have the following installed:- .NET 8.0 SDK: Download here
- Node.js 18+: Download here
- SQL Server 2019+: Download Express or use an existing instance
- Git: For cloning the repository
Step 1: Clone the Repository
happy-habitat-backend/: .NET backend applicationhappy-habitat-frontend/: Angular frontend application
Step 2: Configure the Database
Create the Database
Happy Habitat uses SQL Server with Windows Authentication by default. You can configure SQL Server authentication if needed.Update Connection String
Open
happy-habitat-backend/HappyHabitat.API/appsettings.json and configure the database connection:Configure Database Recreation (Development Only)
In
appsettings.json, you can enable automatic database recreation for development:Step 3: Configure the Backend
JWT Configuration
Set JWT Secret Key
In development, a default JWT key is provided. For production, you MUST set a secure key:Development (
appsettings.json):Run the Backend
- Apply any pending database migrations
- Seed initial data (roles, vehicle types, ticket categories)
- Create the default admin user
- Start listening on
http://localhost:5080
Swagger documentation is available at
http://localhost:5080 when running in development mode.Initial Admin Account
The system automatically creates a default admin account during first startup:- Username:
elgrandeahc - Password:
abc123 - Email:
[email protected] - Role: System Administrator
Step 4: Set Up the Frontend
Configure API Endpoint
The frontend is pre-configured to connect to
http://localhost:5080/api.To change this, edit src/environments/environment.ts:Step 5: First Login
Step 6: Create Your First Community
Now that you’re logged in as a system administrator:Fill in Community Details
Provide the following information:
- Name (Nombre): Your community name
- Description (Descripcion): Brief description
- Address (Direccion): Physical address
- Contact: Main contact name
- Email: Community email
- Phone: Contact phone number
- Type (TipoComunidad): e.g., “Condominium”, “Apartment Complex”
- Number of Units (CantidadViviendas): Total residential units
Seeded Data
The initial seeder (InitialSeeder.cs:20) automatically creates:
User Roles
SYSTEM_ADMIN: System AdministratorADMIN_COMPANY: Company AdministratorCOMITEE_MEMBER: Committee MemberRESIDENT: ResidentRENTER: TenantVIGILANCE: Security Personnel
Vehicle Types
- Car
- Motorcycle
- Truck
- SUV
- Van
Ticket Categories
- Areas comunes (Common Areas)
- Amenidades (Amenities)
- Mantenimiento (Maintenance)
- Mascotas (Pets)
- Pregunta / comentario (Question / Comment)
- Ruido (Noise)
- Servicios (Utilities)
- Sugerencia (Suggestion)
- Vigilancia (Security)
- Otro (Other)
Ticket Statuses
- Nuevo (New)
- En revisión (Under Review)
- En investigación (Under Investigation)
- En proceso (In Progress)
- Cancelado (Cancelled)
- Resuelto (Resolved)
Development Tools
Swagger API Documentation
When running in development mode, access interactive API documentation at:Swagger includes JWT Bearer authentication. Click Authorize, enter
Bearer <your-token>, and test authenticated endpoints.Dummy Data Seeder
In development mode, theDummySeeder runs automatically to populate test data. To disable this, comment out lines 270-275 in Program.cs:270.
Running Seed Only
To run database migrations and seeders without starting the server:Production Deployment
Required Production Configuration
-
JWT Key: Set a strong, unique secret key
-
CORS Origins: Specify your frontend domain(s)
-
Database Recreation: MUST be false
The application will refuse to start if this is
truein production (seeProgram.cs:248-252). -
Connection String: Use secure credentials
- Consider using environment variables or Azure Key Vault
- Enable SSL/TLS for database connections
-
HTTPS: Enable HTTPS redirection (automatically enabled in production, see
Program.cs:220-223)
Environment Variables
You can override appsettings.json values using environment variables:Build for Production
Backend:dist/happy-habitat/.
Next Steps
Architecture Overview
Learn about the system architecture and design patterns
User Management
Learn how to create and manage users and roles
Community Setup
Configure communities, amenities, and settings
API Reference
Explore the REST API endpoints
Troubleshooting
Database connection fails
Database connection fails
- Verify SQL Server is running
- Check connection string in
appsettings.json - Ensure Windows Authentication is enabled or use SQL auth
- Verify firewall allows SQL Server connections (port 1433)
CORS errors in browser
CORS errors in browser
- Ensure backend is running on the expected port (5080)
- Check
Cors:Originsconfiguration inappsettings.json - Verify frontend
apiUrlinenvironment.tsmatches backend URL
JWT authentication fails
JWT authentication fails
- Verify
Jwt:Keyis set correctly in backend configuration - Check token expiration (configured in
JwtService.cs) - Clear browser local storage and try logging in again
Migration errors
Migration errors
- Ensure Entity Framework tools are installed:
dotnet tool install --global dotnet-ef - Run migrations from the correct directory
- Check database permissions for the connection user