Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

LBHackney-IT/social-care-case-viewer-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LBHackney-IT

Social Care Case Viewer API

The Social Care Service API provides service API capabilities for the Social Care Frontend which is part of the Social Care system (see Social Care System Architecture for more details).

C4 Component Diagram

Table of contents

Getting started

Prerequisites

Dockerised dependencies

  • PostgreSQL 12
  • MongoDB

Installation

  1. Clone this repository
$ git clone git@github.com:LBHackney-IT/social-care-case-viewer-api.git

Usage

Running the application

There are two ways of running the application: using dotnet or using docker.

Using dotnet run

Using the dotnet command will not automatically connect the API to any local database instances.

To serve the API locally with dotnet, run dotnet run from within the SocialCareCaseViewerApi project directory, i.e:

$ cd SocialCareCaseViewerApi && dotnet run

The application will be served at http://localhost:5000.

Using docker

Run the API locally with connected local dev databases using this command:

$ make serve

The application will be served at http://localhost:3000.

N.B: This would only spin up the Application, Postgres & MongoDB locally in docker. It doesn't include setup for spinning up other APIs that this service connects to in Staging or in Production.

Running the tests

There are two ways of running the tests: using the terminal and using an IDE.

Using the terminal

To run all tests, use:

$ make test

To run some tests i.e. single or a group, run the test databases in the background:

$ make start-test-dbs

And then you can filter through tests, using the --filter argument of the dotnet test command:

# E.g. for a specific test, use the test method name
$ dotnet test --filter GivenHttpClientReturnsValidResponseThenGatewayReturnsListCaseNotesResponse
# E.g. for a file, use the test class name
$ dotnet test --filter SocialCarePlatformAPIGatewayTests

If your docker test postgres database is out of sync with the schema on your current branch run

$ make restart-test-pg-db

See Microsoft's documentation on running selective unit tests for more information.

Using an IDE

Run the test databases in the background, using:

$ make start-test-dbs

This will allow you to run the tests as normal in your IDE.

Documentation

Architecture

As this service API is a part of the Social Care System, higher level documentation lives in a separate repository called Social Care System Architecture.

To find out more about the process and tooling for our diagrams, see Process documentation in Social Care System Architecture.

API design

We use SwaggerHub to document the API design, of which we have two versions:

  • Hosted by SwaggerHub - for designing endpoints as a contract before we create a new feature
  • Self-hosted - for actual endpoint design which is auto-generated using comments

Databases

The service API has two databases (as seen in the C4 component diagram):

MongoDB (DocumentDB in AWS)

This database stores:

  1. Case history. An audit log of each time an event recorded against a person.
  2. Google Form submission meta data. E.g: Form name, who created it, timestamp.
  3. Full data of forms submitted using the new system.

PostgreSQL (RDS PostgreSQL in AWS)

This database stores:

  1. Stores person data. E.g: Addresses, telephone number, worker allocations.

Connecting to a database

Sometimes we need to directly connect to a database for an environment to diagnose an issue or because we need to make a manual update. This is possible to do via the AWS console, see Connecting to a database documentation.

Updating the database schema

We currently don't have database migrations set up for the databases which means changes to the schema are documented in the repository and done manually via the AWS console.

If you need to make changes e.g. add a new table to the PostgreSQL database, then see Updating the database schema for how we manage this and do this via the AWS console.

Making manual updates

From time to time, we are required to make manual data updates because it's something that's not possible through the UI of the Social Care System. However, this is something we only want to do when really necessary as it requires directly connecting to the database and running SQL statements.

To keep track of these changes, we document them in /database/manual-updates. If you need to make a manual data update, then:

  1. Duplicate our template file
  2. Rename the duplicated file by replacing the date and the title
  3. Fill in the sections of the file
  4. Commit, push and create a PR

Deployment

We have two environments:

  • Staging (StagingAPIs AWS account)
  • Production (Mosaic-Production AWS account)

and two deployment branches:

  • master which deploys to Staging and Production
  • development which deploys to Staging

This means pull request merges into master and development both trigger a deployment to Staging, but only master can trigger a deployment for Production.

To deploy to Production, we first ensure that changes are verified in Staging and then we merge development into master.

We use CircleCI to handle deployment, see CircleCI config.

Infrastructure

For deploying the Lambdas and related resources, we used the Serverless framework (see serverless.yml).

For managing the database in Staging, we use Terraform that is defined within /terraform/staging in this repository.

For managing the database and other resources in Production, we use Terraform that is defined within the Infrastructure repository.

Related repositories

Name Purpose
LBH Social Care Frontend Provides the UI/UX of the Social Care System.
Infrastructure Provides a single place for AWS infrastructure defined using Terraform as infrastructure as code as part of Hackney's new AWS account strategy. NB: Due to its recent introduction, the Social Care System has infrastructure across multiple places.
API Playbook Provides guidance to the standards of APIs within Hackney.

Active contributors

License

MIT License

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages