A backend solution recruitment task for property management with integrated weather data, built using NestJS, MongoDB, and Docker.
- Framework: NestJS 10
- Database: MongoDB 7
- ODM: Mongoose
- Containerization: Docker + Compose
- Environment: Node.js 20
- GraphQL: API with schema-first design
To run this project, ensure you have the following installed:
- Node.js: v20+
- Docker Desktop: v4.25+ (for macOS/Windows)
- NestJS CLI:
npm install -g @nestjs/cli
Follow these steps to get the project up and running locally:
git clone https://github.com/Repith/property-manager.git
cd property-managernpm installCreate a .env file in the root directory with the following variables:
MONGODB_URI=mongodb://root:covertree@localhost:27017/property-manager?authSource=admin
WEATHERAPI_API_KEY=your_weatherapi_key_here
NODE_ENV=developmentReplace your_weatherapi_key_here with your API key from WeatherAPI.
docker compose up --build
This will:
- Build and start the API service.
- Spin up a MongoDB database instance.
- Automatically apply the seed script to populate the database.
- GraphQL API:
- Query properties, filter, and sort them.
- Retrieve detailed weather information for properties.
- Property Management:
- Add, delete, and query properties with associated weather data.
- Weather Integration:
- Seamlessly fetch weather data from WeatherAPI during property creation.
- Seed Data:
- Populate the database with example properties upon startup.
The application requires the following environment variables:
| Variable Name | Description | Example Value |
|---|---|---|
MONGODB_URI |
MongoDB connection URI | mongodb://mongo:27017/property-manager |
WEATHERAPI_API_KEY |
API key for WeatherAPI | your_api_key_here |
NODE_ENV |
Environment mode (development/production) | development |
Once the application is running, you can access the GraphQL Playground at:
http://localhost:4000/graphql
- Query all properties:
query GetAllProperties {
properties {
_id
city
state
zipCode
weatherData {
temp_c
wind_kph
condition {
text
}
}
createdAt
}
}- Query sorted properties:
query GetSortedProperties {
properties(sort: { sortByCreatedAt: DESC }) {
_id
city
createdAt
}
}- Filter properties by city/state/zip:
query GetFilteredProperties {
properties(filter: { city: "Phoenix", state: "AZ" }) {
_id
city
state
zipCode
}
}- Get details of a specific property:
query GetProperty($id: String!) {
property(id: $id) {
_id
city
state
zipCode
createdAt
weatherData {
temp_c
temp_f
is_day
condition{
text
icon
}
wind_kph
wind_dir
humidity
cloud
feelslike_c
uv
}
}
}- Add a new property::
mutation CreateProperty($input: CreatePropertyInput!) {
createProperty(input: $input) {
city
state
zipCode
}
}- Delete a property::
mutation DeleteProperty($id: String!) {
deleteProperty(id: $id)
}Seed the database The database will automatically seed with example data on startup. If you need to rerun the seed script manually:
npm run seedRun the project locally To start the project without Docker:
npm run start:devEnsure your local MongoDB is running, and set the MONGODB_URI variable accordingly in .env.
Start services
docker compose up --buildWeatherAPI: Ensure you have a valid API key with sufficient request quota. MongoDB: The database runs on Docker and requires no manual setup.