This is purely PHP which is considered to be Off-topic but this is my take:
<?php if ( have_posts() ) : ?>
<?php
while ( have_posts() ) :
the_post();
$i = $wp_query->current_post;
echo ( 0 == $i % 3 ) ? '<div class="row">' : '';
?>
<div class="project">
</div> <!-- /.project -->
<?php
echo ( $wp_query->post_count == $i || 2 == $i % 3 ) ? '</div>' : '';
endwhile;
?>
<?php endif; ?>
The $wp_query->current_post
is a built-in query property that stats at 0 and holds the index of the posts array.