Skip to content

DaSandner/code-snippet-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Code Snippet Manager

A comprehensive code snippet management system built with modern technologies and security best practices.

🚀 Features

  • Secure Backend: ASP.NET Core API with JWT authentication and comprehensive security measures
  • Modern Frontend: React Admin interface with custom Material-UI theme
  • Clean Architecture: Domain-driven design with CQRS pattern implementation
  • Database: MongoDB with proper data modeling and relationships
  • Security: Complete security audit with all critical vulnerabilities resolved
  • Validation: Comprehensive input validation and sanitization
  • Audit Logging: Security event monitoring and suspicious activity detection

🏗️ Architecture

Backend (ASP.NET Core)

  • Domain Layer: Core business logic and entities
  • Application Layer: CQRS commands/queries and DTOs
  • Infrastructure Layer: Data access and external services
  • API Layer: Controllers and middleware

Frontend (React)

  • React Admin: Admin interface framework
  • Material-UI: Custom theme and components
  • TypeScript: Type-safe development

🔒 Security Features

  • JWT token-based authentication
  • BCrypt password hashing
  • CORS policy configuration
  • Rate limiting
  • Input validation and sanitization
  • Security headers (CSP, X-Frame-Options, etc.)
  • Audit logging for security events
  • Environment variable configuration

📋 Prerequisites

  • .NET 8.0 or later
  • Node.js 18+ and npm
  • MongoDB instance
  • Git

🚀 Quick Start

Backend Setup

  1. Navigate to the API project:

    cd src/Api
  2. Copy environment template:

    cp .env.example .env
  3. Configure your environment variables in .env:

    JWT_SECRET_KEY=your-super-secure-jwt-secret-key-here
    MONGODB_CONNECTION_STRING=mongodb://localhost:27017
    MONGODB_DATABASE=CodeSnippetManager
  4. Run the API:

    dotnet run

Frontend Setup

  1. Navigate to the frontend project:

    cd src/Web.Api
  2. Install dependencies:

    npm install
  3. Start the development server:

    npm run dev

🔧 Configuration

Environment Variables

Variable Description Required
JWT_SECRET_KEY Secret key for JWT token signing Yes
MONGODB_CONNECTION_STRING MongoDB connection string Yes
MONGODB_DATABASE Database name Yes
ASPNETCORE_ENVIRONMENT Environment (Development/Production) No

Security Configuration

The application includes comprehensive security measures:

  • All sensitive data moved to environment variables
  • CORS restricted to specific origins
  • Rate limiting on authentication endpoints
  • Content Security Policy headers
  • Input validation middleware

📁 Project Structure

src/
├── Api/                    # ASP.NET Core Web API
│   ├── Controllers/        # API controllers
│   ├── Middleware/         # Custom middleware
│   └── Properties/
├── Application/            # Application layer (CQRS)
│   ├── Categories/
│   ├── Snippets/
│   ├── Tags/
│   └── Users/
├── Domain/                 # Domain entities and interfaces
│   ├── Categories/
│   ├── Snippets/
│   ├── Tags/
│   └── Users/
├── Infrastructure/         # Data access and external services
│   ├── Repositories/
│   └── Services/
└── Web.Api/               # React frontend
    ├── src/
    │   ├── components/
    │   └── theme.ts
    └── public/

🧪 Testing

Run the domain tests:

cd tests/Domain.Tests
dotnet test

🔐 Security

This project has undergone a comprehensive security audit. All critical and high-priority vulnerabilities have been resolved:

  • ✅ JWT secrets properly externalized
  • ✅ CORS policy restricted
  • ✅ Secure password hashing (BCrypt)
  • ✅ Input validation implemented
  • ✅ Security headers configured
  • ✅ Audit logging enabled

See src/Api/SECURITY_README.md for detailed security documentation.

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

📞 Support

For support and questions, please open an issue on GitHub.


Note: This project follows security best practices and includes comprehensive documentation. Always review the security configuration before deploying to production.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages