A modern, enterprise-grade inventory and stock management system built with ASP.NET Core Razor Pages. LunaSpaceX provides multi-location store support with comprehensive CRUD operations, user authentication, and real-time inventory tracking.
- Multi-Location Store Management: Support for multiple physical locations (Rangsit, Siam, etc.)
- Inventory Tracking: Real-time stock monitoring and management
- User Authentication: Integrated ASP.NET Core Identity with secure account management
- Responsive UI: Bootstrap-based responsive design for desktop and mobile
- Database-First Architecture: Entity Framework Core with SQL Server integration
- RESTful CRUD Operations: Create, Read, Update, Delete operations for all entities
- β Built on .NET 6.0 LTS framework
- β Razor Pages for clean, maintainable server-side rendering
- β Entity Framework Core with SQL Server provider
- β ASP.NET Core Identity for authentication & authorization
- β Bootstrap 4/5 for responsive styling
- β jQuery Validation for client-side form validation
- β Scoped CSS for component-level styling
- Prerequisites
- Installation
- Project Structure
- Configuration
- Running the Application
- Architecture
- Database
- API Endpoints
- Development
- Contributing
- License
Before you begin, ensure you have the following installed:
- .NET SDK 6.0 or higher (Download)
- SQL Server 2019 or later (or Azure SQL Database)
- Visual Studio 2022 / VS Code with C# extension
- Git for version control
- OS: Windows 10/11, macOS, or Linux
- RAM: 4GB minimum (8GB recommended)
- Disk Space: 500MB+ for development environment
git clone https://github.com/yourusername/LunaSpaceX.git
cd LunaSpaceXdotnet restoreEdit appsettings.json or appsettings.Development.json:
{
"ConnectionStrings": {
"DefaultConnection": "Server=YOUR_SERVER;Database=YOUR_DATABASE;Trusted_Connection=True;MultipleActiveResultSets=true"
}
}For Azure SQL Database:
{
"ConnectionStrings": {
"DefaultConnection": "Server=tcp:your-server.database.windows.net,1433;Initial Catalog=your-database;Persist Security Info=False;User ID=your-username;Password=your-password;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
}
}dotnet ef database updatedotnet buildLunaSpaceX/
βββ Pages/ # Razor Pages views and logic
β βββ Shared/ # Shared layouts and partials
β β βββ _Layout.cshtml # Master layout template
β β βββ _Layout.cshtml.css # Scoped layout styles
β β βββ _LoginPartial.cshtml # Authentication UI partial
β βββ Rangsit/ # Rangsit store inventory pages
β β βββ IndexRangsit.cshtml(.cs) # Stock listing
β β βββ CreateRangsit.cshtml(.cs)# New stock form
β β βββ EditRangsit.cshtml(.cs) # Edit stock form
β β βββ DeleteRangsit.cshtml # Delete confirmation
β βββ Siam/ # Siam store inventory pages
β β βββ IndexSiam.cshtml(.cs) # Stock listing
β β βββ CreateSiam.cshtml(.cs) # New stock form
β β βββ EditSiam.cshtml(.cs) # Edit stock form
β β βββ DeleteSiam.cshtml # Delete confirmation
β βββ Index.cshtml(.cs) # Homepage
β βββ Privacy.cshtml(.cs) # Privacy policy
β βββ Error.cshtml(.cs) # Error page
βββ Data/ # Data access layer
β βββ ApplicationDbContext.cs # EF Core DbContext
β βββ Migrations/ # Database migration scripts
βββ Areas/ # Feature areas
β βββ Identity/ # ASP.NET Core Identity pages
βββ Properties/
β βββ launchSettings.json # Launch profile configuration
β βββ serviceDependencies.json # Service dependencies
β βββ serviceDependencies.local.json
βββ wwwroot/ # Static assets
β βββ css/ # Stylesheets
β β βββ site.css # Global styles
β βββ js/ # JavaScript files
β β βββ site.js # Global scripts
β βββ libs/ # Third-party libraries
β β βββ bootstrap/ # Bootstrap framework
β β βββ jquery/ # jQuery library
β β βββ jquery-validation/ # Client-side validation
β βββ imgs/ # Images and assets
βββ Program.cs # Application entry point & configuration
βββ LunaSpaceX.csproj # Project file (.NET configuration)
βββ LunaSpaceX.sln # Solution file
βββ appsettings.json # Production configuration
βββ appsettings.Development.json # Development configuration
βββ README.md # This file
appsettings.json (Production):
{
"ConnectionStrings": {
"DefaultConnection": "Production connection string here"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*"
}appsettings.Development.json (Development):
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=aspnet-LunaSpaceX-dev;Trusted_Connection=True;"
},
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft.AspNetCore": "Debug"
}
}
}The application uses ASP.NET Core Identity with the following configuration in Program.cs:
builder.Services.AddDefaultIdentity<IdentityUser>(options =>
options.SignIn.RequireConfirmedAccount = true)
.AddEntityFrameworkStores<ApplicationDbContext>();Key Settings:
- Email confirmation required for new accounts
- Password complexity enforced by Identity defaults
- Session timeout configurable per deployment
dotnet run --configuration DevelopmentThe application will be available at:
- HTTP:
http://localhost:5000 - HTTPS:
https://localhost:5001
dotnet run --configuration Release- Set
LunaSpaceXas the startup project - Select your desired configuration (Debug/Release)
- Press
F5to run with debugging, orCtrl+F5without debugging
Create a Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:6.0 AS runtime
WORKDIR /app
COPY bin/Release/net6.0/publish .
EXPOSE 80 443
ENTRYPOINT ["dotnet", "LunaSpaceX.dll"]Build and run:
docker build -t lunaspacex:latest .
docker run -p 80:80 -p 443:443 lunaspacex:latest- Razor Pages Pattern: Page-per-feature organization with code-behind models
- Repository-like Pattern: Direct database queries via EF Core DbContext
- Dependency Injection: Built-in .NET DI container for service registration
- Identity-based Authorization: Claims-based access control
βββββββββββββββββββββββββββββββββββββββ
β Presentation Layer (Razor Pages) β
β - Views (.cshtml) β
β - Page Models (.cshtml.cs) β
βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββ
β Application Layer β
β - Page Handlers (OnGet, OnPost) β
β - Business Logic β
βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββ
β Data Access Layer (EF Core) β
β - ApplicationDbContext β
β - DbSet<T> entities β
βββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββββββ
β Data Storage (SQL Server) β
β - Stocks table β
β - Identity tables β
βββββββββββββββββββββββββββββββββββββββ
The application uses the following primary entities:
Stocks Table:
CREATE TABLE stocks (
itemid INT PRIMARY KEY IDENTITY(1,1),
item NVARCHAR(MAX),
storeid INT,
supplier NVARCHAR(MAX),
[...]
);Store Locations:
storeid = 1: Rangsitstoreid = 2: Siam
View all applied migrations:
dotnet ef migrations listCreate a new migration:
dotnet ef migrations add YourMigrationNameApply pending migrations:
dotnet ef database updateRollback last migration:
dotnet ef database update PreviousMigrationName| Method | Endpoint | Description |
|---|---|---|
GET |
/Rangsit |
List all Rangsit stocks |
GET |
/Siam |
List all Siam stocks |
GET |
/Rangsit/Create |
Show create form (Rangsit) |
POST |
/Rangsit/Create |
Create new stock (Rangsit) |
GET |
/Rangsit/Edit/{id} |
Show edit form (Rangsit) |
POST |
/Rangsit/Edit/{id} |
Update stock (Rangsit) |
GET |
/Rangsit/Delete/{id} |
Show delete confirmation |
POST |
/Rangsit/Delete/{id} |
Delete stock |
Similar endpoints exist for /Siam/*
| Method | Endpoint | Description |
|---|---|---|
GET |
/Identity/Account/Login |
Login page |
POST |
/Identity/Account/Login |
Submit login |
GET |
/Identity/Account/Register |
Registration page |
POST |
/Identity/Account/Register |
Create account |
POST |
/Identity/Account/Logout |
Logout user |
| Method | Endpoint | Description |
|---|---|---|
GET |
/ |
Homepage |
GET |
/Privacy |
Privacy policy |
GET |
/Error |
Error page |
- C# Naming: PascalCase for public members, camelCase for local variables
- File Organization: One class per file
- Indentation: 4 spaces
- Async/Await: Use async patterns for I/O operations
# Clean previous builds
dotnet clean
# Restore dependencies
dotnet restore
# Build the solution
dotnet build
# Run tests (if any)
dotnet test
# Package for release
dotnet publish -c Release -o ./publishVisual Studio:
- Set breakpoints (F9)
- Run with debugging (F5)
- Step through code (F10/F11)
VS Code:
- Install C# extension
- Create
.vscode/launch.json - Press F5 to start debugging
# Check for .NET CLI tools
dotnet tool list -g
# Update .NET CLI tools
dotnet tool update -g dotnet-ef
# Analyze project structure
dotnet sln list
# View project dependencies
dotnet list referenceWe welcome contributions from the community! Here's how to get started:
- Fork the repository
- Clone your fork locally
- Create a new feature branch:
git checkout -b feature/your-feature-name
# Create feature branch
git checkout -b feature/amazing-feature
# Make your changes
# Write clean, well-documented code
# Test thoroughly
# Commit with clear messages
git commit -m "feat: add amazing feature"
# Push to your fork
git push origin feature/amazing-feature
# Create a Pull Request on GitHubFollow Conventional Commits:
feat: add new inventory filter
fix: resolve stock update bug
docs: update database schema docs
refactor: simplify database query logic
test: add tests for stock CRUD operations
- Ensure all tests pass
- Follow project code style
- Add/update documentation as needed
- Respond to review feedback
- Merge after approval
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License permits:
- β Commercial use
- β Modification
- β Distribution
- β Private use
With the conditions:
- π License and copyright notice must be included
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Advanced filtering and search
- Export to Excel/CSV
- Mobile app (React Native)
- Real-time notifications
- Audit logging
- API endpoint documentation (Swagger/OpenAPI)
- Unit and integration tests
- Docker containerization
- Query optimization
- Caching layer (Redis)
- Pagination for large datasets
- Async/await patterns throughout
- ASP.NET Core Documentation
- Entity Framework Core
- Razor Pages Guide
- ASP.NET Core Identity
- .NET Best Practices
Built with β€οΈ using ASP.NET Core & SQL Server
β If you find this project helpful, please consider giving it a star!