How mhamednasser/nutrix works
Project Type and Purpose
• Nutrix is a backend Web API (ASP.NET Core / .NET 8) that powers an AI-driven fitness & nutrition platform.
• It exposes REST endpoints for authentication, user management, workouts, meal logging, AI-powered plan generation, analytics, and more.
• It uses Entity Framework Core with SQL Server (or PostgreSQL), integrates Google Gemini AI, supports JWT & OAuth, and is containerized via Docker.
File Structure
• Top-level:
• graduationProject.sln | solution file
• graduationProject/Program.cs, launchSettings.json | ASP.NET Core startup
• Controllers/ | HTTP API layer
• Services/, Repositories/, Interfaces/ | Business logic & data layer
• Models/, Data/, Migrations/ | EF Core data model & seed data
• Configurations/ | strongly-typed settings (JWT, Database, Email, Gemini, OAuth)
• DTOs/ | request/response definitions
• Extensions/ | controller or service extension methods
• Dockerfile, docker-compose.yml | container setup
• Architectural patterns:
• Layered (API → Services → Repositories → Database)
• Dependency Injection (Interfaces + Services)
• Configuration separation (Settings classes)
• External integrations visible in code:
• Google Gemini AI + ChatBotService + PythonApiService
• EmailService (SMTP/Gmail)
• JwtService + GoogleAuthSettings
• Logging / Health Checks via built-in ASP.NET features
Extract Additional Insights from README
• Confirms tech stack: .NET 8, ASP.NET Core, EF Core, SQL Server, Docker, Google Gemini AI
• Highlights containerization (Docker Compose) for API + database
• Specifies key external dependencies: OAuth 2.0, SMTP, Gemini AI, cloud deployment options
Main Components
a. API Layer
• Controllers: AuthController, UserController, ExercisesController, AI-Controllers (Chat, Plan), etc.
• Swagger UI & Health-check endpoints
b. Business Logic Layer
• Services: ChallengeService, PlanGenerationService (and mock), ChatBotService, EmailService, JwtService, PythonApiService
• Interfaces for each service
c. Data Access Layer
• Repositories (GeneralPlanRepository, others)
• EF Core Migrations & AppDbContext → SQL Server database
d. External Services
• Google Gemini AI (Meal-Plan, Workout, Chat)
• Email (SMTP / third-party email provider)
• Google OAuth 2.0 for social login
e. Infrastructure / DevOps
• Docker container for API
• Docker container for SQL Server
• Docker Compose orchestration
• Environment configuration (.env, appsettings)
• Cloud targets (Azure/AWS/GCP)
Relationships & Data Flow
• User (Mobile/Web) → HTTPS request → API Gateway (ASP.NET Core)
• API Layer → AuthService (JWT validation, OAuth handshake)
• On protected endpoints → Services invoked → Repositories → Database
• AI endpoints → ChatBotService / PlanGenerationService → Google Gemini AI (external HTTP)
• PythonApiService (if external Python microservice exists)
• EmailService → SMTP provider
• Data flow returns through Service → Controller → HTTP response → User
• Container orchestration ensures isolation between API & DB
Architectural Patterns & Design Principles
• Layered architecture with clear separation of concerns
• Dependency Injection for testability and extensibility
• Repository pattern + Unit of Work (via DbContext)
• Configuration via strongly-typed settings
• DTO pattern for request/response contracts
• Multi-stage Docker builds for lean production images
• Health checks & structured logging for operations
Step-by-Step Creation
1. Sketch the edge components (Clients, External services)
2. Layer in API → Services → Data blocks
4. Encapsulate API + DB in Docker Compose boundary