|
Tip
|
Detailed documentation is available in the docs/ folder, including the API JSON Exchange Reference, Database Integration guide, and Deployment Guide (Docker & Kubernetes). |
The Shopping List Server is an ASP.NET Core Web API designed to support a shopping list application. It provides comprehensive user management, authentication, shopping list creation and sharing, real-time updates via SignalR, push notifications through Firebase Cloud Messaging (FCM), email verification, and secure file storage. The server uses Entity Framework Core for database interactions with support for both PostgreSQL and SQLite, and includes Docker deployment options for scalability.
This project enables users to create, manage, and share shopping lists with fine-grained permissions, authenticate via JWT or social providers (Google, Facebook, Apple), and receive real-time notifications about list changes.
Future Plans: A React-based frontend is planned to provide a modern web interface complementing the existing mobile app.
-
User Management: Registration, authentication, profile updates, and contact management. Supports social logins (Google, Facebook, Apple) and email verification.
-
Authentication: JWT-based authentication with support for external OAuth2 providers. Includes password hashing with salt, alternative passwords, and secure token management.
-
Shopping Lists: Create, update, delete, and share shopping lists. Supports permissions for read, write, delete, and member management.
-
Permissions System: Fine-grained access control using bit flags (e.g., Read, Write, Delete, AddPermission, ModifyPermission) for shopping list sharing.
-
Real-Time Updates: SignalR integration for live synchronization of shopping list changes across connected clients.
-
Push Notifications: Firebase Cloud Messaging (FCM) for sending notifications to users' devices about list updates.
-
Email Services: Automated email verification, password reset, and HTML email templates using SMTP.
-
Object Storage: Profile pictures are stored in S3-compatible object storage (MinIO in the cluster) and served through short-lived pre-signed URLs. The API itself keeps no user data on disk, so it is stateless and needs no PersistentVolumeClaim.
-
Database Migrations: Entity Framework Core migrations for schema evolution, supporting both PostgreSQL and SQLite databases.
-
Security: HTTPS redirection, CORS support, secure handling of sensitive data, and environment-specific configurations.
-
Deployment: Docker support for containerized deployment, with options for local development and external server production.
-
Entities and Models (see Entity Models for full schema):
-
[
User](Models/User.cs): Represents users with properties like email, name, color, verification status, and FCM tokens. -
[
ShoppingList](Models/ShoppingData/ShoppingList.cs): Shopping list metadata and content (name, category, date, notes). -
[
ShoppingListProduct](Models/ShoppingData/ShoppingListProduct.cs): The list’s item rows (name, category, count, checked, position). One row per item, so a count change is a single-row update. -
[
ShoppingListPermission](Models/ShoppingData/ShoppingListPermission.cs): Manages user permissions for lists. -
[
FcmToken](Models/FcmToken.cs): Stores Firebase tokens for push notifications. -
[
ImageInfo](Models/ImageInfo.cs): Handles user profile images. -
[
UserContact](Models/UserContact.cs): Manages user contacts and sharing. -
[
EMailVerificationToken](Models/EMailVerificationToken.cs): Handles email verification tokens.
-
-
Services Layer: Business logic is encapsulated in services with dependency injection:
-
[
UserService](Services/UserService.cs): User CRUD operations and contact management. -
[
AuthenticationService](Services/AuthenticationService.cs): JWT token generation and validation. -
[
PushNotificationService](Services/PushNotificationService.cs): FCM integration for notifications. -
[
ShoppingService](Services/ShoppingService.cs): Shopping list operations and permissions. -
[
EMailVerificationService](Services/EMailVerificationService.cs): Email verification and templates. -
[
S3ObjectStorage](Services/S3ObjectStorage.cs): Profile-picture storage in MinIO / S3 and pre-signed URL creation.
-
-
Controllers: API endpoints handle HTTP requests:
-
[
UsersController](Controllers/UsersController.cs): User authentication, registration, and management. -
[
ShoppingController](Controllers/ShoppingController.cs): Shopping list CRUD and permissions. -
[
VerifyController](Controllers/VerifyController.cs): Email verification endpoints. -
[
ShoppingHub_Controller](Controllers/ShoppingHub_Controller.cs): SignalR hub for real-time updates.
-
-
Database Context: [
AppDb](Database/AppDb.cs) manages database operations with lazy loading, UTC time conversion, and migration support. See Database Integration for the full schema. -
Authentication Flow: JWT tokens for session management with claims-based authorization. Social authentication via OAuth2 with provider-specific models (GoogleUser, FacebookProfile, AppleAccount).
-
Permissions: Enum-based flags for shopping list access, allowing combinations like WriteAndAddPermission. Permissions are checked at the service layer. See Permission Types for the full enum definition.
-
Hubs: SignalR hubs for real-time communication between clients and server, enabling live updates on shopping list changes.
-
Email and Notifications: HTML page generation for emails using [
HtmlPageFactory](Logic/HtmlPageFactory.cs), FCM integration for push messages. -
Storage: Shopping lists (metadata and items) live in PostgreSQL; profile pictures live in S3-compatible object storage. Nothing is written to the API’s own filesystem.
-
Error Handling: Global exception handling with custom status messages in [
StatusMessages.cs](Models/StatusMessages.cs). -
Configuration: Environment-specific settings in [
appsettings.json](appsettings.json) and [appsettings.Development.json](appsettings.Development.json), with secrets isolated in [auth/](auth/) folder.
-
.NET 10.0 SDK
-
PostgreSQL or SQLite database
-
Docker (for containerized deployment)
-
Firebase project (for push notifications)
-
Email server credentials (for SMTP)
The API can run from source on the host while PostgreSQL keeps running in Docker. This is the
setup the VS Code configurations use, and it is what makes breakpoints in Controllers/,
Services/ and Logic/ work.
-
Install dependencies:
` dotnet restore` -
Start the local stack — one VS Code task, Terminal → Run Task… → local: start. It
-
stops the Docker API container (it publishes the same port 5677),
-
starts
db(PostgreSQL) andadminerif they are not running, -
runs the API on http://localhost:5677 with
ASPNETCORE_ENVIRONMENT=Development.The equivalent command is: ``` docker compose stop shoppinglistserver docker compose up -d --no-deps db adminer dotnet run --project WebApi.csproj --no-launch-profile ``` `--no-launch-profile` keeps the URL from [`Program.cs`](Program.cs); the profile in `Properties/launchSettings.json` would move the API to ports 5000/5001.
-
-
Debugging: choose .NET Launch (local) and press F5. The pre-launch task builds and stops the Docker API container; PostgreSQL and Adminer stay up.
Adminer is available at http://localhost:8080. Sign in with system PostgreSQL, server db,
user shoppinglist, database shoppinglistserver and the password from DB_PASSWORD
(sl_dev_pw_2026 for the local stack).
[appsettings.Development.json](appsettings.Development.json) connects to that database through
the loopback port the compose file publishes (127.0.0.1:5432) and carries a development-only
JWT secret; it is not used by the deployed image. UseSQLite: true switches a local run to a
file database instead.
The API is stateless: shopping lists (including every item) live in PostgreSQL, and profile pictures
live in S3-compatible object storage. docker-compose.yml starts a local MinIO on
http://localhost:9000 (console http://localhost:9001) alongside PostgreSQL, so no volume has to be
shared with the container. Configure the store under AppSettings:ObjectStorage in
[appsettings.Development.json](appsettings.Development.json); the bucket is created automatically on
startup.
Test connectivity:
curl -I http://localhost:5677/users/test-
Edit [
appsettings.json](appsettings.json):-
Set
"UseDocker": "True". -
Configure database and certificates.
-
-
Place SSL certificates in
/etc/letsencrypt/kestrel/(copy from Certbot live folder). -
Set Docker host (if deploying remotely):
` export DOCKER_HOST=ssh://<user>@<server>` -
Initial deployment:
` docker-compose up --build && docker-compose rm -fsv` -
Update server code:
` docker-compose up -d --no-deps --build shoppinglistserver`
Test with:
curl -I https://<certbot-address>:5678/users/test-
Install PostgreSQL on the server and create schema/user as per [
appsettings.json](appsettings.json). -
Place certificates in the specified paths.
-
Build and run:
` dotnet publish -c Release dotnet ShoppingListServer.dll`
See Database Integration for complete schema documentation and migration history.
-
Create schema:
CREATE SCHEMA shoppinglistserver; -
Grant user access.
-
Migrations are applied automatically on startup. Manual update:
` dotnet ef database update` -
Add new migrations:
` dotnet ef migrations add <MigrationName>`
For complete JSON request/response formats with examples, see API JSON Exchange Reference.
-
Authentication:
-
POST /users/authenticate: Authenticate user (public). -
POST /users/register: Register user (public).
-
-
Users:
-
GET /users: Get all users (admin only). -
GET /users/{id}: Get user by ID (authenticated). -
PUT /users: Update user (authenticated). -
POST /users/generate_share_id: Generate contact share ID (authenticated). -
POST /users/contact/{userId}: Add/remove contact (authenticated).
-
-
Shopping Lists:
-
POST /shopping/list: Create/update list (authenticated). -
GET /shopping/list/{id}: Get list (authenticated). -
DELETE /shopping/list/{id}: Delete list (authenticated). -
POST /shopping/test_firebase_push_message: Test FCM (anonymous).
-
-
Verification:
-
GET /verify/em/{urlCode}: Verify email (anonymous).
-
Connect to /shoppingserver/update for real-time updates on shopping list changes. See SignalR Real-Time Messages for all event types and payload formats.
Contributions are welcome. Follow standard .NET practices, ensure tests pass, and update migrations as needed.


