Skip to content

olivershooter/reposit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏠 Reposit Property Management System

A TypeScript-based command-line application for managing property and tenant data. Made for Reposit.

📋 Table of Contents

📊 Project Overview

This application processes property and tenant data from CSV files to provide various insights and calculations related to property management.

📁 Files and Their Functions

Main Files

  • 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 region
    • getUniqueRegions: Retrieves a list of all unique regions from the properties data
    • runSpecificRegion: 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

Utility Files

  • src/utils/prompts.ts: Contains utility functions for interactive command-line prompts.

    • promptForRegion: Asks the user to select a region
    • promptForProperty: Asks the user to select a property
    • promptForUnit: Asks the user to select a unit (pence or pounds)

Type Definitions

  • src/types/propertyInterfaces.ts: Contains TypeScript interfaces and types for the application.

    • Property: Interface for property data
    • Tenant: Interface for tenant data
    • RentUnit: Type for rent units (pence or pounds)
    • PropertyStatus: Enum for property statuses

Data Files

  • 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.

Test Files

  • src/tests/: Directory containing test files for each main functionality.
    • Tests use Vitest and mock dependencies for isolated testing

Configuration Files

  • package.json: NPM package configuration with scripts and dependencies.
  • tsconfig.json: TypeScript configuration.
  • vitest.config.ts: Vitest testing configuration.

🚀 How to Run

Prerequisites

  • Node.js (v14 or higher recommended)
  • npm

Installation

  1. Clone the repository
  2. Install dependencies:
    npm install
    

Available Commands

Run the application using npm scripts:

  1. Show available commands:

    npm start
    
  2. 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.

  3. 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.

  4. Check for properties with invalid postcodes:

    npm run validate
    

    This will display a list of property IDs with invalid postcodes.

  5. 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).

Running Tests

Run the tests using:

npm test

Run tests in watch mode:

npm run test:watch

🔨 Build

To compile the TypeScript code to JavaScript:

npm run build

The compiled code will be in the dist directory.

About

Made for a take home

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published