Skip to content

Kaua26323/MindFlow

Repository files navigation

🧠 MindFlow

Alt text

πŸ’» About the Project

MindFlow is a Full Stack web application developed for the structured management of thoughts, publications, and ideas. Built with a focus on Clean Architecture and S.O.L.I.D. principles, the project ensures a clear separation of concerns. This facilitates scalability, code maintenance, and the rigorous implementation of automated tests.

The user interface is Server-Side Rendered (SSR) using the Express Handlebars template engine and styled with the Tailwind CSS, providing a fast, dynamic, and responsive user experience.

✨ Features

  • πŸ” Authentication and Registration β€” Secure, session-based login system using Argon2 password hashing.
  • πŸ’Ύ Persistent Sessions β€” Session management and storage in PostgreSQL via connect-pg-simple.
  • πŸ“ Post Management (CRUD) β€” Creation, reading, updating, and deletion of publications on the user's dashboard.
  • ⭐ Favorites System β€” Ability to save publications for quick access.
  • πŸ”’ CSRF Protection β€” Built-in defense against Cross-Site Request Forgery.
  • 🎨 Responsive Interface (UI) β€” Modern and adaptable layout, built and styled with Tailwind CSS v4.
  • βœ… Form Validation β€” Rigorous data input validation and static typing using Zod.

πŸ—οΈ Applied Design Patterns:

  • Use Cases (Interactors): All business logic flows are isolated into atomic and testable Use Cases within the Application layer.
  • Adapter Pattern: Isolation of external libraries, such as data validation (Zod) and hashing algorithms (Argon2), ensuring that the business logic does not depend on third-party frameworks.
  • Repository Pattern: Complete abstraction of database logic, facilitating provider switching and the creation of mocks (Harness) for testing.
  • Factory Pattern: Clean and centralized dependency injection to instantiate Controllers, Use Cases, and Repositories.

πŸ› οΈ Technologies Used

Backend

Technology Purpose
Node.js Runtime environment
Express 5 Web framework
TypeScript Static typing
Drizzle ORM Database ORM
PostgreSQL Relational database
Zod Schema validation
Argon2 Password hashing

Frontend

Technology Purpose
Handlebars Server-side templating
Tailwind CSS v4 Utility-first CSS

Testing

Technology Purpose
Vitest Unit and integration tests
Supertest HTTP integration tests
Playwright End-to-end tests

Tooling

Technology Purpose
Docker Compose Local database containers
ESLint + Prettier Linting and formatting
tsup Build bundler
tsx TypeScript execution in dev

πŸš€ How to Install

Prerequisites

1. Clone the repository

git clone https://github.com/Kaua26323/MindFlow.git
cd MindFlow

2. Install dependencies

npm install

3. Configure environment variables

cp .env.example .env.development

Check the src/env/configs.ts file for more details on how we handle environments

4. Start the database

npm run docker:dev

5. Run migrations

npm run drizzle:migrate:dev

6. Start the application

# Start the server (with hot reload)
npm run dev

# In a separate terminal, compile CSS in watch mode
npm run dev:css

The application will be available at http://localhost:3000 (or the port defined in your .env).


πŸ§ͺ Quality and Testing

The project has three layers of testing:

Unit tests

npm run test:unit

Integration tests

# Start the test database first
npm run docker:test
npm run drizzle:migrate:dev

npm run test:int

End-to-end tests (Playwright)

# Run in headless mode
npm run test:e2e

# Run in headed mode (visible browser)
npm run test:e2e:headed

# Run with Playwright UI
npm run test:e2e:ui

# Debug mode
npm run test:e2e:debug

Run all tests

npm test

πŸ“‚ Project Structure

The project adopts Clean Architecture principles.

src/
β”œβ”€β”€ application/           # APPLICATION LAYER (Pure Business Rules)
β”‚   β”œβ”€β”€ ports/             # Abstraction contracts for external tools (e.g., hash.port.ts, validator.port.ts)
β”‚   β”œβ”€β”€ repositories/      # Abstract persistence interfaces (e.g., user.repository.ts, post.repository.ts)
β”‚   └── useCases/          # Implementation of system Use Cases, containing isolated application logic
β”‚       β”œβ”€β”€ favorites/     # Favorites use cases (e.g., add-post.use-case.ts, remove-post.use-case.ts)
β”‚       β”œβ”€β”€ posts/         # Posts use cases (e.g., create-post.use-case.ts, update-post.use-case.ts)
β”‚       └── users/         # Users use cases (e.g., create-user.use-case.ts, user-login.use-case.ts)
β”‚
β”œβ”€β”€ infra/                 # INFRASTRUCTURE LAYER (Technical Details and Frameworks)
β”‚   β”œβ”€β”€ adapters/          # Concrete implementations of application Ports (e.g., argon2-hash.adapter.ts, zod-validator.adapter.ts)
β”‚   β”œβ”€β”€ db/                # Data persistence subsystem
β”‚   β”‚   └── drizzle/       # Drizzle ORM configuration, relational schema definitions, and SQL migrations
β”‚   β”‚       β”œβ”€β”€ migrations/# Auto-generated SQL files for database version control
β”‚   β”‚       └── schemas/   # Relational table mapping (users, posts, favoritesPosts)
β”‚   β”œβ”€β”€ repositories/      # Repository implementations using the database driver (drizzle-user.repository.ts)
β”‚   β”œβ”€β”€ factories/         # Dependency injection factories coupling adapters and use cases to controllers
β”‚   └── web/               # Specific payload validation schemas for HTTP requests via Zod
β”‚
β”œβ”€β”€ web/                   # PRESENTATION LAYER (Web Interface and Routing)
β”‚   β”œβ”€β”€ controllers/       # HTTP Controllers that receive view inputs, invoke use cases, and return responses
β”‚   β”œβ”€β”€ middlewares/       # Express interceptors (authentication, global error handling, flash messages management)
β”‚   β”œβ”€β”€ public/            # Directly served static files (Tailwind compiled CSS, favicons, manifests)
β”‚   β”œβ”€β”€ routes/            # Express route definitions and grouping (user-routes.ts, post-routes.ts, etc.)
β”‚   └── views/             # Visual layer using Server-Side Rendering (SSR) template engine
β”‚       β”œβ”€β”€ dashboard/     # User logged-in area screens (post creation, listing, and editing)
β”‚       β”œβ”€β”€ errors/        # Visual error handling pages (404, 500)
β”‚       β”œβ”€β”€ favorites/     # Interface displaying user's favorited items
β”‚       β”œβ”€β”€ layouts/       # System's base structural HTML5 template (main.handlebars)
β”‚       └── partials/      # Reusable components (navigationBar.handlebars and modular SVG icons)
β”‚
β”œβ”€β”€ env/                   # Fail-fast validation and static typing of environment variables using Zod schemas
└── errors/                # Abstractions and specializations of internal application errors (AppError)

πŸ“Έ Screenshots

Alt text Alt text Alt text Alt text Alt text

πŸ“„ License

This project is licensed under the MIT License.

About

MindFlow is a Full Stack web application developed for the structured management of thoughts, publications, and ideas. Built with a focus on Clean Architecture and S.O.L.I.D. principles

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors