Welcome to the Daily Diet application! This project enables users to track their meals, categorize them as inside or outside the diet, and retrieve insightful metrics for better dietary planning.
-
CRUD Operations for Meals
Easily create, view, update, and delete meals. -
Diet Classification
Tag meals as:- Inside diet (
yes) - Outside diet (
no)
- Inside diet (
-
Metrics Dashboard
- Total meals count.
- Meals categorized by diet type.
- Longest streak of meals within the diet.
-
Date and Time Validation
- ISO 8601 compliant date handling.
- Time format validation (
HH:mm:ss).
-
Node.js
Backend built with modern JavaScript standards. -
Fastify
Fast and low overhead web framework, for Node.js. -
Knex.js
SQL query builder used for database interaction. -
Zod
Schema validation for robust request handling.
📂 /src
├── 📂 middlewares
│ └── check-user-id-exists.ts # Middleware to validate if the user ID exists in requests
├── 📂 routes
│ └── 📄 meals.ts # Route definitions for meal-related endpoints
├── 📂 env
│ └── 📄 index.ts # Environment variable configuration and management
├── 📂 @types
│ └── 📄 knex.d.ts # Custom TypeScript definitions for Knex.js
├── 📄 server.ts # Entry point to start the server
├── 📄 database.ts # Database configuration and connection setup
└── 📄 app.ts # Main application file; sets up middlewares and routes
http://localhost:3334
POST /meals
Request Body:
{
"name": "Grilled Chicken",
"description": "Healthy and delicious",
"date": "2024-12-02",
"hour": "12:30:00",
"diet": "yes"
}Response:
201 Created
GET /metrics
Response:
{
"totalMeals": 15,
"insideMeals": 10,
"outsideMeals": 5,
"bestDietSequence": 5
}We use Vitest for unit and integration tests. To run the tests, execute:
npm test- Node.js (v18 or newer)
- PostgreSQL
- Clone the repository:
git clone https://github.com/DevAnseSenior/daily-diet.git cd daily-diet - Install dependencies:
npm install
- Configure the database:
- Create a
.envfile and add your database credentials:DATABASE_URL=your-database-url - Run migrations:
npm run migrate
- Create a
- Start the server:
npm start
- Add user authentication.
- Implement meal sharing between users.
- Enhance metrics with visualizations.
This project is licensed under the MIT License.
If you have any questions or suggestions, feel free to reach out:
- GitHub: DevAnseSenior
- Linked: Anderson Coelho