PROJECT DOCUMENTATION | API DOCUMENTATION
PetScale is a simple and interactive weight tracking application for pet owners. It provides insightful metrics and recommendations based on the weight trends of pets. The app is designed with a clean interface for tracking, adding, and deleting pet weight data efficiently.
-
Dynamic Weight Tracking:
- Track weight trends for individual pets.
- View detailed weight charts with time-series data.
-
Pet-Specific Analytics:
- Key Performance Indicators (KPIs) for each pet:
- Min Weight
- Max Weight
- Average Weight
- Weight Range
- Recommendations for improving pet health.
- Key Performance Indicators (KPIs) for each pet:
-
CRUD Operations:
- Add, update, and delete pets.
- Log weight entries for pets.
- Manage historical weight records.
-
Scalable API:
- RESTful API endpoints for interacting with users, pets, and weights data.
- Supports JSON requests and responses.
- React: Interactive UI components.
- Next.js: Server-side rendering and routing.
- Tailwind CSS: Modern styling framework.
- shadcn/ui: Styling templates
- Prisma: ORM for database operations.
- SQLite: Lightweight database for development and production.
- Node.js: Server environment.
Method | Endpoint | Description |
---|---|---|
GET |
/weight |
Fetch all weight records. |
POST |
/weight |
Create a new weight record. |
GET |
/weight/[weightId] |
Fetch a specific weight record. |
PUT |
/weight/[weightId] |
Update a specific weight record. |
DELETE |
/weight/[weightId] |
Delete a specific weight record. |
Method | Endpoint | Description |
---|---|---|
GET |
/pet |
Fetch all pets. |
POST |
/pet |
Create a new pet. |
GET |
/pet/[petId] |
Fetch a specific pet. |
PUT |
/pet/[petId] |
Update a specific pet. |
DELETE |
/pet/[petId] |
Delete a specific pet. |
For a visual representation of the POST /api/pet
flow, refer to the sequence diagram below:
- Node.js (>= 18.x)
- pnpm (>= 9.12.x)
-
Clone the repository:
git clone https://github.com/your-username/petscale.git cd petscale
-
Install dependencies:
pnpm install
-
Generate the Prisma client:
pnpm prisma:generate
-
Push the Prisma schema to the database:
pnpm prisma db push
Run the app locally:
pnpm dev
Build and start the production server:
pnpm build
pnpm start
The project includes unit tests for critical functionalities:
- Location:
lib/analytics.test.ts
- Testing Framework: Vitest
pnpm test
- Track Weight:
- Use the
Track Weight
button to log your pet's weight.
- Use the
- Add Pet:
- Add a new pet by clicking the
Add Pet
button.
- Add a new pet by clicking the
- Delete Pet:
- Remove a pet using the
Delete Pet
button. All associated weight data will also be deleted.
- Remove a pet using the
.
βββ API.md
βββ api-testing
β βββ OSZIMT-LF12
β β βββ Pet/
β β βββ User/
β β βββ Weight/
βββ app
β βββ api/
β βββ components/
β βββ lib/
βββ prisma/
βββ tests/
- API Documentation: Detailed in
API.md
. - Unit Tests: Available in
lib/analytics.test.ts
. - Integration Tests: Bruno-compatible files in
api-testing/OSZIMT-LF12
.
- Torben Haack - Developer
- ChatGPT - Used for assistance in writing documentation