Mosque in the local community

How to detect and answer the needs of the local communities? What functions other than prayer facilities should a mosque provide for its local community? How to reach out the non-Muslim community? How a mosque can support a deeper sense of citizenship?