A TypeScript-based command-line application for managing property and tenant data. Made for Reposit.
This application processes property and tenant data from CSV files to provide various insights and calculations related to property management.
-
src/main.ts: The entry point of the application. Handles command-line arguments and routes to the appropriate functionality.
-
src/getAverageRentByRegion.ts: Calculates the average monthly rent for properties in a specific region.
getAverageRentByRegion
: Calculates average rent for a given regiongetUniqueRegions
: Retrieves a list of all unique regions from the properties datarunSpecificRegion
: Wrapper function to run the average rent calculation for a region
-
src/calculateMonthlyRentPerTenant.ts: Calculates how much each tenant should pay for a specific property.
- Divides the property's monthly rent by the number of tenants
- Can return the result in either pence or pounds
-
src/checkForValidPostcodes.ts: Validates property postcodes using the UK postcode format.
- Returns a list of property IDs with invalid postcodes
-
src/propertyStatus.ts: Determines the status of a property based on tenant occupancy and tenancy end date.
- Possible statuses: Vacant, Partially Vacant, Active, or Overdue
-
src/utils/prompts.ts: Contains utility functions for interactive command-line prompts.
promptForRegion
: Asks the user to select a regionpromptForProperty
: Asks the user to select a propertypromptForUnit
: Asks the user to select a unit (pence or pounds)
-
src/types/propertyInterfaces.ts: Contains TypeScript interfaces and types for the application.
Property
: Interface for property dataTenant
: Interface for tenant dataRentUnit
: Type for rent units (pence or pounds)PropertyStatus
: Enum for property statuses
- src/assets/technical-challenge-properties-september-2024.csv: CSV file containing property data.
- src/assets/technical-challenge-tenants-september-2024.csv: CSV file containing tenant data.
- src/tests/: Directory containing test files for each main functionality.
- Tests use Vitest and mock dependencies for isolated testing
- package.json: NPM package configuration with scripts and dependencies.
- tsconfig.json: TypeScript configuration.
- vitest.config.ts: Vitest testing configuration.
- Node.js (v14 or higher recommended)
- npm
- Clone the repository
- Install dependencies:
npm install
Run the application using npm scripts:
-
Show available commands:
npm start
-
Calculate average rent by region:
npm run region
This will prompt you to select a region and then display the average monthly rent for properties in that region.
-
Calculate monthly rent per tenant for a property:
npm run monthly
This will prompt you to select a property and a unit (pence or pounds), then display how much each tenant should pay.
-
Check for properties with invalid postcodes:
npm run validate
This will display a list of property IDs with invalid postcodes.
-
Check the status of a property:
npm run status
This will prompt you to select a property and then display its status (vacant, partially vacant, active, or overdue).
Run the tests using:
npm test
Run tests in watch mode:
npm run test:watch
To compile the TypeScript code to JavaScript:
npm run build
The compiled code will be in the dist
directory.