Skip to content

OldSchool1705/usersDB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ConsoleUserManager

A simple C# console application for managing users using PostgreSQL. This project demonstrates secure password hashing, basic CRUD functionality, and clean architecture using principles like SOLID and separation of concerns.

Features

  • Add new users (name, email, password)
  • Secure password hashing with SHA256
  • Email uniqueness check
  • View all users
  • Automatic table creation on startup

Tech Stack

  • .NET Core / .NET 6+
  • PostgreSQL
  • Npgsql (PostgreSQL driver for .NET)

Getting Started

Prerequisites

Database Setup

  1. Create a PostgreSQL database named Users.
  2. Update the connection string in the code if necessary:
string connectionString = "Host=localhost;Port=5432;Database=Users;Username=postgres;Password=326451;";

Run the Project

dotnet build
dotnet run

Project Structure

├── Program.cs                   // Entry point
├── App.cs                      // CLI logic and menu
├── Services/
│   └── UserService.cs          // Business logic for user operations
├── Repositories/
│   └── UserRepository.cs       // Data access layer for PostgreSQL
├── Models/
│   └── User.cs                 // User entity
├── Utils/
│   └── PasswordHasher.cs       // SHA256 hashing utility
└── Database/
    └── DatabaseInitializer.cs  // Table creation logic

Architecture Principles

  • SOLID: Each class has a single responsibility.
  • Separation of Concerns: Clear separation between data, business logic, and user interface.
  • Extensibility: The design makes it easy to extend, test, and refactor.

Example Usage

Add User

Enter name: John
Enter email: john@example.com
Enter password: mysecurepassword

View Users

ID: 1
Name: John
Email: john@example.com
Created At: 2025-04-03 10:20:33

Notes

  • Passwords are stored securely as SHA256 hashes.
  • Duplicate emails are not allowed.

License

This project is open-source and provided as-is for learning and experimentation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages