Skip to content

ForliLabs/casa-studente

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

136 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🏠 CasaStudente β€” Student Housing Platform for ForlΓ¬

CasaStudente is a full-featured student housing marketplace built for the University of Bologna's Forlì campus. It connects students searching for accommodation with verified landlords, offering secure payments, AI-powered search, roommate matching, and multilingual support (IT/EN/ES/FR).

Status: MVP with 70+ features, 24 Prisma models, 137 unit tests, and full E2E coverage.


✨ Key Features

Category Features
Core Listing browser with filters & map, listing detail pages, neighborhood guides
Auth & Security bcrypt password hashing, session cookies, CSRF tokens, role-based access (student / landlord / admin), university verification
Payments Stripe Connect marketplace (checkout, subscriptions, refunds), platform fees, payment receipts
Messaging Conversation threads per listing, real-time unread counts, AI-powered message translation
AI Natural language search (OpenAI), listing description generator, multilingual chat assistant
Roommates Profile-based matching with compatibility algorithm (budget, sleep, cleanliness, social, language)
Reviews & Trust 5-dimension ratings, verified-lease badges, trust score with bronze/silver/gold tiers
Notifications In-app + email (Resend), saved search alerts, notification hub with preference management
Leases & Documents Digital lease contracts (transitorio, 4+4, 3+2), tax regime support (cedolare secca), document vault
Admin User management, content moderation, analytics dashboard, telemetry viewer
Advanced Tenant scoring, insurance policies, dispute resolution, housing groups, tour bookings, market forecasting
Moonshots Guaranteed rent, co-living pods, digital twin apartments, student housing passport, resilience fund, arrival concierge
Infra Sentry error tracking, PostHog analytics, Vercel Blob file storage, PWA offline support, i18n (4 languages)

πŸ— Tech Stack

Layer Technology
Framework Next.js 16 (App Router, Server Components, Server Actions)
Language TypeScript 5
UI React 19, Tailwind CSS 4, Lucide icons, CVA (class-variance-authority)
Database PostgreSQL via Prisma 7 (24 models) + InMemoryStore fallback for dev
Auth bcrypt (cost 12), cookie-based sessions, CSRF protection
Payments Stripe Connect (Express accounts, Checkout, Subscriptions, Webhooks)
AI OpenAI GPT-4o-mini (search parsing, description generation, chat, translation)
Email Resend (verification, receipts, notifications)
Storage Vercel Blob (listing photos, documents, evidence)
Monitoring Sentry (errors) + PostHog (product analytics)
Testing Vitest (unit) + Playwright (E2E)
Deployment Vercel

πŸš€ Getting Started

Prerequisites

  • Node.js β‰₯ 18
  • npm β‰₯ 9
  • PostgreSQL (optional β€” the app falls back to in-memory stores for development)

Installation

# Clone the repository
git clone <repository-url>
cd casa-studente

# Install dependencies
npm install

# Copy environment variables
cp .env.example .env
# Edit .env with your API keys (all external services are optional for local dev)

# Generate Prisma client
npm run db:generate

# Run the development server
npm run dev

Open http://localhost:3000 to view the app.

Demo Accounts

The app seeds demo users automatically (in-memory mode):

Role Email Password
Student martina.lopez@studio.unibo.it password123
Student luca.bianchi@studio.unibo.it password123
Landlord elena.rossi@casastudente.it password123
Admin admin@casastudente.it admin123

πŸ“‚ Project Structure

casa-studente/
β”œβ”€β”€ prisma/
β”‚   β”œβ”€β”€ schema.prisma          # 24 models, full relational schema
β”‚   └── seed.ts                # Database seeding script
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                   # Next.js App Router pages & API routes
β”‚   β”‚   β”œβ”€β”€ api/               # REST API endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/          # Authentication (logout)
β”‚   β”‚   β”‚   β”œβ”€β”€ health/        # Health check
β”‚   β”‚   β”‚   β”œβ”€β”€ institutional/ # Public data APIs (rents, vacancy, forecasts)
β”‚   β”‚   β”‚   β”œβ”€β”€ landlord/      # Landlord-specific APIs
β”‚   β”‚   β”‚   β”œβ”€β”€ listings/      # Listing CRUD
β”‚   β”‚   β”‚   β”œβ”€β”€ moonshots/     # Experimental features
β”‚   β”‚   β”‚   β”œβ”€β”€ upload/        # File upload
β”‚   β”‚   β”‚   └── webhooks/      # Stripe webhooks
β”‚   β”‚   β”œβ”€β”€ admin/             # Admin dashboard pages
β”‚   β”‚   β”œβ”€β”€ auth/              # Login, register, verify pages
β”‚   β”‚   β”œβ”€β”€ dashboard/         # User dashboard (30+ sub-pages)
β”‚   β”‚   β”œβ”€β”€ listings/          # Listing browse & detail
β”‚   β”‚   β”œβ”€β”€ neighborhoods/     # Zone guides + quiz
β”‚   β”‚   └── ...                # Community, calendar, roommates, etc.
β”‚   β”œβ”€β”€ components/            # 22 React components
β”‚   β”œβ”€β”€ generated/             # Prisma-generated client
β”‚   β”œβ”€β”€ lib/                   # Core business logic
β”‚   β”‚   β”œβ”€β”€ actions/           # 29 Server Action modules
β”‚   β”‚   β”œβ”€β”€ repositories/      # 10 data access repositories
β”‚   β”‚   β”œβ”€β”€ services/          # 7 external service integrations
β”‚   β”‚   β”œβ”€β”€ stores/            # 25 in-memory domain stores
β”‚   β”‚   β”œβ”€β”€ auth.ts            # Authentication logic
β”‚   β”‚   β”œβ”€β”€ db.ts              # InMemoryStore base class
β”‚   β”‚   β”œβ”€β”€ i18n.ts            # Internationalization (4 languages)
β”‚   β”‚   β”œβ”€β”€ password.ts        # bcrypt hashing + legacy migration
β”‚   β”‚   β”œβ”€β”€ rate-limit.ts      # In-memory rate limiter
β”‚   β”‚   β”œβ”€β”€ utils.ts           # Tailwind class utilities
β”‚   β”‚   └── validation.ts      # Zod schemas for all inputs
β”‚   └── middleware.ts          # Security headers, CSP, route protection
β”œβ”€β”€ tests/unit/                # 9 test suites, 137 test cases
β”œβ”€β”€ e2e/                       # Playwright E2E specs
└── package.json

πŸ§ͺ Testing

# Run all unit tests
npm test

# Watch mode
npm run test:watch

# Coverage report
npm run test:coverage

# E2E tests (requires dev server running)
npm run test:e2e

# Type checking
npm run typecheck

# Linting
npm run lint

Test Coverage

Suite Tests Covers
db.test.ts 10 InMemoryStore CRUD, filtering, seeding
password.test.ts 14 bcrypt hashing, legacy format migration, CSRF tokens
validation.test.ts 23 Zod schemas (listings, payments, reviews, messages, AI)
stores.test.ts 16 Domain stores (conversations, reviews, payments, notifications)
features.test.ts 19 Compatibility algorithm, trust scoring, distance calculations
i18n.test.ts 18 Translation keys, locale detection, formatting
rate-limit.test.ts 15 Rate limiting with window expiration
ai-service.test.ts 14 NL search fallback, description generation, chat
moonshots.test.ts 8 Experimental feature stores

πŸ”§ Scripts

Command Description
npm run dev Start development server
npm run build Production build
npm start Start production server
npm run lint Run ESLint
npm test Run unit tests (Vitest)
npm run test:e2e Run E2E tests (Playwright)
npm run typecheck TypeScript type checking
npm run db:generate Generate Prisma client
npm run db:migrate Run database migrations
npm run db:push Push schema to database
npm run db:seed Seed database
npm run db:studio Open Prisma Studio

🌐 Environment Variables

See .env.example for all available variables. All external services are optional β€” the app provides graceful fallbacks:

Variable Service Required?
DATABASE_URL PostgreSQL No (uses InMemoryStore)
STRIPE_SECRET_KEY Stripe payments No (mock mode)
RESEND_API_KEY Email delivery No (console logging)
OPENAI_API_KEY AI features No (template fallback)
BLOB_READ_WRITE_TOKEN File storage No (mock URLs)
SENTRY_DSN Error tracking No (console only)
POSTHOG_API_KEY Product analytics No (console only)

πŸ“– Documentation

  • API Reference β€” Complete REST API & Server Actions documentation
  • Architecture β€” System architecture with Mermaid diagrams

🚒 Deployment

The app is configured for Vercel deployment:

# Build for production
npm run build

# Or deploy via Vercel CLI
npx vercel

Required Vercel settings:

  • Framework Preset: Next.js
  • Build Command: npm run build
  • Output Directory: .next
  • Environment Variables: Set all required keys in the Vercel dashboard

πŸ“„ License

Source code is publicly available. No open-source license has been selected yet.

About

Student housing platform for university towns, matching students with landlords and verified rooms.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages